add libardour code for going completely silent after a compile-time defined number of seconds
This commit is contained in:
parent
fbceec674a
commit
8a5b5145cc
@ -232,6 +232,16 @@ class LIBARDOUR_API AudioEngine : public SessionHandlePtr, public PortManager
|
|||||||
|
|
||||||
LatencyMeasurement measuring_latency () const { return _measuring_latency; }
|
LatencyMeasurement measuring_latency () const { return _measuring_latency; }
|
||||||
|
|
||||||
|
/* These two are used only in builds where SILENCE_AFTER_SECONDS was
|
||||||
|
* set. BecameSilent will be emitted when the audioengine goes silent.
|
||||||
|
* reset_silence_countdown() can be used to reset the silence
|
||||||
|
* countdown, whose duration will be reduced to half of its previous
|
||||||
|
* value.
|
||||||
|
*/
|
||||||
|
|
||||||
|
PBD::Signal0<void> BecameSilent;
|
||||||
|
void reset_silence_countdown ();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AudioEngine ();
|
AudioEngine ();
|
||||||
|
|
||||||
@ -293,6 +303,12 @@ class LIBARDOUR_API AudioEngine : public SessionHandlePtr, public PortManager
|
|||||||
BackendMap _backends;
|
BackendMap _backends;
|
||||||
AudioBackendInfo* backend_discover (const std::string&);
|
AudioBackendInfo* backend_discover (const std::string&);
|
||||||
void drop_backend ();
|
void drop_backend ();
|
||||||
|
|
||||||
|
#ifdef SILENCE_AFTER
|
||||||
|
framecnt_t _silence_countdown;
|
||||||
|
uint32_t _silence_hit_cnt;
|
||||||
|
#endif
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace ARDOUR
|
} // namespace ARDOUR
|
||||||
|
@ -559,7 +559,6 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop
|
|||||||
bool transport_stopped() const { return _transport_speed == 0.0f; }
|
bool transport_stopped() const { return _transport_speed == 0.0f; }
|
||||||
bool transport_rolling() const { return _transport_speed != 0.0f; }
|
bool transport_rolling() const { return _transport_speed != 0.0f; }
|
||||||
|
|
||||||
void set_silent (bool yn);
|
|
||||||
bool silent () { return _silent; }
|
bool silent () { return _silent; }
|
||||||
|
|
||||||
TempoMap& tempo_map() { return *_tempo_map; }
|
TempoMap& tempo_map() { return *_tempo_map; }
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include <exception>
|
#include <exception>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
#include <glibmm/timer.h>
|
#include <glibmm/timer.h>
|
||||||
#include <glibmm/pattern.h>
|
#include <glibmm/pattern.h>
|
||||||
@ -63,6 +64,10 @@ using namespace PBD;
|
|||||||
gint AudioEngine::m_meter_exit;
|
gint AudioEngine::m_meter_exit;
|
||||||
AudioEngine* AudioEngine::_instance = 0;
|
AudioEngine* AudioEngine::_instance = 0;
|
||||||
|
|
||||||
|
#ifdef SILENCE_AFTER
|
||||||
|
#define SILENCE_AFTER_SECONDS 10
|
||||||
|
#endif
|
||||||
|
|
||||||
AudioEngine::AudioEngine ()
|
AudioEngine::AudioEngine ()
|
||||||
: session_remove_pending (false)
|
: session_remove_pending (false)
|
||||||
, session_removal_countdown (-1)
|
, session_removal_countdown (-1)
|
||||||
@ -89,8 +94,13 @@ AudioEngine::AudioEngine ()
|
|||||||
, _hw_devicelist_update_thread(0)
|
, _hw_devicelist_update_thread(0)
|
||||||
, _hw_devicelist_update_count(0)
|
, _hw_devicelist_update_count(0)
|
||||||
, _stop_hw_devicelist_processing(0)
|
, _stop_hw_devicelist_processing(0)
|
||||||
|
#ifdef SILENCE_AFTER_SECONDS
|
||||||
|
, _silence_countdown (0)
|
||||||
|
, _silence_hit_cnt (0)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
g_atomic_int_set (&m_meter_exit, 0);
|
g_atomic_int_set (&m_meter_exit, 0);
|
||||||
|
reset_silence_countdown ();
|
||||||
start_hw_event_processing();
|
start_hw_event_processing();
|
||||||
discover_backends ();
|
discover_backends ();
|
||||||
}
|
}
|
||||||
@ -148,6 +158,10 @@ AudioEngine::sample_rate_change (pframes_t nframes)
|
|||||||
|
|
||||||
SampleRateChanged (nframes); /* EMIT SIGNAL */
|
SampleRateChanged (nframes); /* EMIT SIGNAL */
|
||||||
|
|
||||||
|
#ifdef SILENCE_AFTER_SECONDS
|
||||||
|
_silence_countdown = nframes * SILENCE_AFTER_SECONDS;
|
||||||
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -349,9 +363,30 @@ AudioEngine::process_callback (pframes_t nframes)
|
|||||||
last_monitor_check = next_processed_frames;
|
last_monitor_check = next_processed_frames;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef SILENCE_AFTER_SECONDS
|
||||||
|
|
||||||
|
bool was_silent = (_silence_countdown == 0);
|
||||||
|
|
||||||
|
if (_silence_countdown >= nframes) {
|
||||||
|
_silence_countdown -= nframes;
|
||||||
|
} else {
|
||||||
|
_silence_countdown = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!was_silent && _silence_countdown == 0) {
|
||||||
|
_silence_hit_cnt++;
|
||||||
|
BecameSilent (); /* EMIT SIGNAL */
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_silence_countdown == 0 || _session->silent()) {
|
||||||
|
PortManager::silence (nframes);
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
if (_session->silent()) {
|
if (_session->silent()) {
|
||||||
PortManager::silence (nframes);
|
PortManager::silence (nframes);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (session_remove_pending && session_removal_countdown) {
|
if (session_remove_pending && session_removal_countdown) {
|
||||||
|
|
||||||
@ -375,6 +410,19 @@ AudioEngine::process_callback (pframes_t nframes)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
AudioEngine::reset_silence_countdown ()
|
||||||
|
{
|
||||||
|
#ifdef SILENCE_AFTER_SECONDS
|
||||||
|
double sr = 48000; /* default in case there is no backend */
|
||||||
|
|
||||||
|
sr = sample_rate();
|
||||||
|
|
||||||
|
_silence_countdown = max (60 * sr, /* 60 seconds */
|
||||||
|
sr * (SILENCE_AFTER_SECONDS / pow (2, _silence_hit_cnt)));
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
AudioEngine::launch_device_control_app()
|
AudioEngine::launch_device_control_app()
|
||||||
@ -1081,6 +1129,7 @@ AudioEngine::set_sample_rate (float sr)
|
|||||||
if (!_backend) {
|
if (!_backend) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return _backend->set_sample_rate (sr);
|
return _backend->set_sample_rate (sr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user