X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=audio_mixer.h;h=9793646c9bac3493651e39643a610c7df75c5d0f;hb=d41e4825e6e02a693661ae7b055b081411e8b1dc;hp=17f95280e28eba8a9a85756cb24c626a6f3f858c;hpb=ba675cdb4f3156d9906c72746b535f54a1aff800;p=nageru diff --git a/audio_mixer.h b/audio_mixer.h index 17f9528..9793646 100644 --- a/audio_mixer.h +++ b/audio_mixer.h @@ -46,7 +46,7 @@ enum EQBand { class AudioMixer { public: - AudioMixer(unsigned num_cards); + AudioMixer(unsigned num_capture_cards, unsigned num_ffmpeg_inputs); void reset_resampler(DeviceSpec device_spec); void reset_meters(); @@ -142,6 +142,18 @@ public: return locut_enabled[bus]; } + bool is_mono(unsigned bus_index); + + void set_stereo_width(unsigned bus_index, float width) + { + stereo_width[bus_index] = width; + } + + float get_stereo_width(unsigned bus_index) + { + return stereo_width[bus_index]; + } + void set_eq(unsigned bus_index, EQBand band, float db_gain) { assert(band >= 0 && band < NUM_EQ_BANDS); @@ -289,6 +301,7 @@ public: float fader_volume_db; bool muted; bool locut_enabled; + float stereo_width; float eq_level_db[NUM_EQ_BANDS]; float gain_staging_db; bool level_compressor_enabled; @@ -317,7 +330,7 @@ private: AudioDevice *find_audio_device(DeviceSpec device_spec); void find_sample_src_from_device(const std::map> &samples_card, DeviceSpec device_spec, int source_channel, const float **srcptr, unsigned *stride); - void fill_audio_bus(const std::map> &samples_card, const InputMapping::Bus &bus, unsigned num_samples, float *output); + void fill_audio_bus(const std::map> &samples_card, const InputMapping::Bus &bus, unsigned num_samples, float stereo_width, float *output); void reset_resampler_mutex_held(DeviceSpec device_spec); void apply_eq(unsigned bus_index, std::vector *samples_bus); void update_meters(const std::vector &samples); @@ -327,13 +340,14 @@ private: std::vector get_active_devices() const; void set_input_mapping_lock_held(const InputMapping &input_mapping); - unsigned num_cards; + unsigned num_capture_cards, num_ffmpeg_inputs; mutable std::timed_mutex audio_mutex; ALSAPool alsa_pool; AudioDevice video_cards[MAX_VIDEO_CARDS]; // Under audio_mutex. AudioDevice alsa_inputs[MAX_ALSA_CARDS]; // Under audio_mutex. + std::unique_ptr ffmpeg_inputs; // Under audio_mutex. std::atomic locut_cutoff_hz{120}; StereoFilter locut[MAX_BUSES]; // Default cutoff 120 Hz, 24 dB/oct. @@ -375,6 +389,7 @@ private: std::atomic fader_volume_db[MAX_BUSES] {{ 0.0f }}; std::atomic mute[MAX_BUSES] {{ false }}; float last_fader_volume_db[MAX_BUSES] { 0.0f }; // Under audio_mutex. + std::atomic stereo_width[MAX_BUSES] {{ 0.0f }}; // Default 1.0f (is set in constructor). std::atomic eq_level_db[MAX_BUSES][NUM_EQ_BANDS] {{{ 0.0f }}}; float last_eq_level_db[MAX_BUSES][NUM_EQ_BANDS] {{ 0.0f }};