Add "Hear Mic" feature to the Mic App (#1518)

* Add "Hear Mic" feature to the Mic App

* Following consensus change about ternary operators
This commit is contained in:
Brumi-2021 2023-10-21 01:43:22 +02:00 committed by GitHub
parent 86d4b17257
commit efcedd9005
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 108 additions and 7 deletions

View file

@ -184,6 +184,10 @@ void MicTXView::rxaudio(bool is_on) {
baseband::run_image(portapack::spi_flash::image_tag_mic_tx);
audio::output::stop();
audio::input::start(ak4951_alc_and_wm8731_boost_GUI); // When detected AK4951 => set up ALC mode; when detected WM8731 => set up mic_boost ON/OFF.
if (mic_to_HP_enabled)
audio::input::loopback_mic_to_hp_enable();
else
audio::input::loopback_mic_to_hp_disable();
portapack::pin_i2s0_rx_sda.mode(3);
configure_baseband();
}
@ -215,6 +219,7 @@ MicTXView::MicTXView(
&field_frequency,
&options_tone_key,
&check_rogerbeep,
&check_mic_to_HP, // check box to activate "hear mic"
&check_common_freq_tx_rx, // added to handle common or separate freq- TX/RX
&check_rxactive,
&field_volume,
@ -242,6 +247,7 @@ MicTXView::MicTXView(
&field_frequency,
&options_tone_key,
&check_rogerbeep,
&check_mic_to_HP, // check box to activate "hear mic"
&check_common_freq_tx_rx, // added to handle common or separate freq- TX/RX
&check_rxactive,
&field_volume,
@ -287,7 +293,11 @@ MicTXView::MicTXView(
}
ak4951_alc_and_wm8731_boost_GUI = v; // 0..4, WM8731_boost dB's options, (combination boost on/off, and effective gain in captured data >>x)
audio::input::start(ak4951_alc_and_wm8731_boost_GUI); // Detected (WM8731), set up the proper wm_boost on/off, 0..4 (0,1) boost_on, (2,3,4) boost_off
configure_baseband(); // to update in real time, sending msg, var-parameters >>shift_bits FM msg, to audio_tx from M0 to M4 Proc -
if (mic_to_HP_enabled)
audio::input::loopback_mic_to_hp_enable();
else
audio::input::loopback_mic_to_hp_disable();
configure_baseband(); // to update in real time, sending msg, var-parameters >>shift_bits FM msg, to audio_tx from M0 to M4 Proc -
};
options_wm8731_boost_mode.set_selected_index(3); // preset GUI index 3 as default WM -> -02 dB's.
} else {
@ -295,7 +305,11 @@ MicTXView::MicTXView(
options_ak4951_alc_mode.on_change = [this](size_t, int8_t v) {
ak4951_alc_and_wm8731_boost_GUI = v; // 0..11, AK4951 Mic -Automatic volume Level Control options,
audio::input::start(ak4951_alc_and_wm8731_boost_GUI); // Detected (AK4951) ==> Set up proper ALC mode from 0..11 options
configure_baseband(); // sending fixed >>8_FM, var-parameters msg, to audiotx from this M0 to M4 process.
if (mic_to_HP_enabled)
audio::input::loopback_mic_to_hp_enable();
else
audio::input::loopback_mic_to_hp_disable();
configure_baseband(); // sending fixed >>8_FM, var-parameters msg, to audiotx from this M0 to M4 process.
};
}
@ -475,6 +489,20 @@ MicTXView::MicTXView(
rogerbeep_enabled = v;
};
check_mic_to_HP.on_select = [this](Checkbox&, bool v) {
mic_to_HP_enabled = v;
if (mic_to_HP_enabled)
audio::input::loopback_mic_to_hp_enable();
else
audio::input::loopback_mic_to_hp_disable();
if (mic_to_HP_enabled) { // When user click to "hear mic to HP", we will select the higher acoustic sound Option MODE ALC or BOOST-
if (audio::debug::codec_name() == "WM8731") {
options_wm8731_boost_mode.set_selected_index(0); // In WM we always go to Boost +12 dBs respect reference level
} else if (ak4951_alc_and_wm8731_boost_GUI == 0) // In AK we are changing only that ALC index =0, because in that option, there is no sound.
options_ak4951_alc_mode.set_selected_index(1); // alc_mode =0 , means no ALC,no DIGITAL filter block (by passed), and that mode has no loopback mode.
}
};
check_common_freq_tx_rx.on_select = [this](Checkbox&, bool v) {
bool_same_F_tx_rx_enabled = v;
field_rxfrequency.hidden(v); // Hide or show separated freq RX field. (When no hide user can enter down indep. freq for RX)
@ -501,8 +529,10 @@ MicTXView::MicTXView(
check_rxactive.on_select = [this](Checkbox&, bool v) {
// vumeter.set_value(0); //Start with a clean vumeter
rx_enabled = v;
check_mic_to_HP.hidden(rx_enabled); // Hide or show "Hear Mic" checkbox depending if we activate the receiver (we should better not activate both things)
check_mic_to_HP.set_value(false); // If activate receiver sound , reset the possible activation of "Hear to Mic" .
// check_va.hidden(v); //Hide or show voice activation
rxaudio(v); // Activate-Deactivate audio rx accordingly
rxaudio(v); // Activate-Deactivate audio RX (receiver) accordingly
set_dirty(); // Refresh interface
};
@ -603,6 +633,10 @@ MicTXView::MicTXView(
audio::set_rate(audio::Rate::Hz_24000);
audio::input::start(ak4951_alc_and_wm8731_boost_GUI); // When detected AK4951 => set up ALC mode; when detected WM8731 => set up mic_boost ON/OFF.
if (mic_to_HP_enabled)
audio::input::loopback_mic_to_hp_enable();
else
audio::input::loopback_mic_to_hp_disable();
}
MicTXView::MicTXView(