static inline uint64_t DeviceSpec_to_key(const DeviceSpec &device_spec)
{
return (uint64_t(device_spec.type) << 32) | device_spec.index;
static inline uint64_t DeviceSpec_to_key(const DeviceSpec &device_spec)
{
return (uint64_t(device_spec.type) << 32) | device_spec.index;
bool add_audio(DeviceSpec device_spec, const uint8_t *data, unsigned num_samples, bmusb::AudioFormat audio_format, int64_t frame_length);
bool add_silence(DeviceSpec device_spec, unsigned samples_per_frame, unsigned num_frames, int64_t frame_length);
bool add_audio(DeviceSpec device_spec, const uint8_t *data, unsigned num_samples, bmusb::AudioFormat audio_format, int64_t frame_length);
bool add_silence(DeviceSpec device_spec, unsigned samples_per_frame, unsigned num_frames, int64_t frame_length);
+ // If a given device is offline for whatever reason and cannot deliver audio
+ // (by means of add_audio() or add_silence()), you can call put it in silence mode,
+ // where it will be taken to only output silence. Note that when taking it _out_
+ // of silence mode, the resampler will be reset, so that old audio will not
+ // affect it. Same true/false behavior as add_audio().
+ bool silence_card(DeviceSpec device_spec, bool silence);
+
std::vector<float> get_output(double pts, unsigned num_samples, ResamplingQueue::RateAdjustmentPolicy rate_adjustment_policy);
void set_fader_volume(unsigned bus_index, float level_db) { fader_volume_db[bus_index] = level_db; }
std::vector<float> get_output(double pts, unsigned num_samples, ResamplingQueue::RateAdjustmentPolicy rate_adjustment_policy);
void set_fader_volume(unsigned bus_index, float level_db) { fader_volume_db[bus_index] = level_db; }
- std::map<DeviceSpec, DeviceInfo> get_devices() const;
+
+ // Note: This operation holds all ALSA devices (see ALSAPool::get_devices()).
+ // You will need to call set_input_mapping() to get the hold state correctly,
+ // or every card will be held forever.
+ std::map<DeviceSpec, DeviceInfo> get_devices();
+
+ // See comments on ALSAPool::get_card_state().
+ ALSAPool::Device::State get_alsa_card_state(unsigned index)
+ {
+ return alsa_pool.get_card_state(index);
+ }
+
void set_name(DeviceSpec device_spec, const std::string &name);
void set_input_mapping(const InputMapping &input_mapping);
void set_name(DeviceSpec device_spec, const std::string &name);
void set_input_mapping(const InputMapping &input_mapping);
void set_locut_enabled(unsigned bus, bool enabled)
{
locut_enabled[bus] = enabled;
void set_locut_enabled(unsigned bus, bool enabled)
{
locut_enabled[bus] = enabled;
+ void set_eq(unsigned bus_index, EQBand band, float db_gain)
+ {
+ assert(band >= 0 && band < NUM_EQ_BANDS);
+ eq_level_db[bus_index][band] = db_gain;
+ }
+
+ float get_eq(unsigned bus_index, EQBand band) const
+ {
+ assert(band >= 0 && band < NUM_EQ_BANDS);
+ return eq_level_db[bus_index][band];
+ }
+
unsigned capture_frequency = OUTPUT_FREQUENCY;
// Which channels we consider interesting (ie., are part of some input_mapping).
std::set<unsigned> interesting_channels;
unsigned capture_frequency = OUTPUT_FREQUENCY;
// Which channels we consider interesting (ie., are part of some input_mapping).
std::set<unsigned> interesting_channels;
AudioDevice *find_audio_device(DeviceSpec device_spec);
void find_sample_src_from_device(const std::map<DeviceSpec, std::vector<float>> &samples_card, DeviceSpec device_spec, int source_channel, const float **srcptr, unsigned *stride);
void fill_audio_bus(const std::map<DeviceSpec, std::vector<float>> &samples_card, const InputMapping::Bus &bus, unsigned num_samples, float *output);
void reset_resampler_mutex_held(DeviceSpec device_spec);
AudioDevice *find_audio_device(DeviceSpec device_spec);
void find_sample_src_from_device(const std::map<DeviceSpec, std::vector<float>> &samples_card, DeviceSpec device_spec, int source_channel, const float **srcptr, unsigned *stride);
void fill_audio_bus(const std::map<DeviceSpec, std::vector<float>> &samples_card, const InputMapping::Bus &bus, unsigned num_samples, float *output);
void reset_resampler_mutex_held(DeviceSpec device_spec);
void measure_bus_levels(unsigned bus_index, const std::vector<float> &left, const std::vector<float> &right);
void send_audio_level_callback();
void measure_bus_levels(unsigned bus_index, const std::vector<float> &left, const std::vector<float> &right);
void send_audio_level_callback();
StereoFilter locut[MAX_BUSES]; // Default cutoff 120 Hz, 24 dB/oct.
std::atomic<bool> locut_enabled[MAX_BUSES];
StereoFilter locut[MAX_BUSES]; // Default cutoff 120 Hz, 24 dB/oct.
std::atomic<bool> locut_enabled[MAX_BUSES];
std::atomic<float> compressor_threshold_dbfs[MAX_BUSES];
std::atomic<bool> compressor_enabled[MAX_BUSES];
std::atomic<float> compressor_threshold_dbfs[MAX_BUSES];
std::atomic<bool> compressor_enabled[MAX_BUSES];
+ // Note: The values here are not in dB.
+ struct PeakHistory {
+ float current_level = 0.0f; // Peak of the last frame.
+ float historic_peak = 0.0f; // Highest peak since last reset; no falloff.
+ float current_peak = 0.0f; // Current peak of the peak meter.
+ float last_peak = 0.0f;
+ float age_seconds = 0.0f; // Time since "last_peak" was set.
+ };
+ PeakHistory peak_history[MAX_BUSES][2]; // Separate for each channel. Under audio_mutex.
+
double final_makeup_gain = 1.0; // Under compressor_mutex. Read/write by the user. Note: Not in dB, we want the numeric precision so that we can change it slowly.
bool final_makeup_gain_auto = true; // Under compressor_mutex.
InputMapping input_mapping; // Under audio_mutex.
std::atomic<float> fader_volume_db[MAX_BUSES] {{ 0.0f }};
double final_makeup_gain = 1.0; // Under compressor_mutex. Read/write by the user. Note: Not in dB, we want the numeric precision so that we can change it slowly.
bool final_makeup_gain_auto = true; // Under compressor_mutex.
InputMapping input_mapping; // Under audio_mutex.
std::atomic<float> fader_volume_db[MAX_BUSES] {{ 0.0f }};
CorrelationMeasurer correlation; // Under audio_measure_mutex.
Resampler peak_resampler; // Under audio_measure_mutex.
std::atomic<float> peak{0.0f};
CorrelationMeasurer correlation; // Under audio_measure_mutex.
Resampler peak_resampler; // Under audio_measure_mutex.
std::atomic<float> peak{0.0f};
-
- // Under audio_measure_mutex. Note that Ebu_r128_proc has a broken
- // copy constructor (it uses the default, but holds arrays),
- // so we can't just use raw Ebu_r128_proc elements, but need to use
- // unique_ptrs.
- std::vector<std::unique_ptr<Ebu_r128_proc>> bus_r128;