mirror of
https://github.com/eried/portapack-mayhem.git
synced 2024-10-01 01:26:06 -04:00
Finalised all Mic Boost(WM) and Mic ALC(AK)
This commit is contained in:
parent
745574d3c4
commit
6b75249b0a
@ -187,7 +187,7 @@ void MicTXView::rxaudio(bool is_on) {
|
||||
|
||||
baseband::run_image(portapack::spi_flash::image_tag_mic_tx);
|
||||
audio::output::stop();
|
||||
audio::input::start(ak_alc_GUI_selected ); // set up audio input = mic config of any audio coded AK4951/WM8731, (in WM8731 parameter will be ignored)
|
||||
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.
|
||||
portapack::pin_i2s0_rx_sda.mode(3);
|
||||
configure_baseband();
|
||||
}
|
||||
@ -282,36 +282,39 @@ MicTXView::MicTXView(
|
||||
mic_gain = v / 10.0;
|
||||
configure_baseband();
|
||||
};
|
||||
options_gain.set_selected_index(1); // x1.0
|
||||
options_gain.set_selected_index(1); // x1.0 preselected default.
|
||||
|
||||
ak_alc_GUI_selected = 0; // 0,..11 AK-ALC options,
|
||||
|
||||
if (audio::debug::codec_name() =="WM8731") {
|
||||
if (audio::debug::codec_name() =="WM8731") {
|
||||
options_wm8731_boost_mode.on_change = [this](size_t, int8_t v) {
|
||||
|
||||
switch(v) {
|
||||
case 0: // +00 dB’s reference level , (when +20dB's boost ON)
|
||||
shift_bits_s16 = 8; // same as original conditions fw 1.5.4 , using WM mic boost ON(+20dB's) and shift bits (>>8),
|
||||
break; // now mic-boost off(+00dBs) shift bits (8) (+20+0dB's)=20 dBs ref => +00dB's
|
||||
case 1:
|
||||
switch(v) {
|
||||
case 0: // +12 dB’s respect reference level orig fw 1.5.x fw FM : when +20dB's boost ON) and shift bits (>>8),
|
||||
shift_bits_s16 = 6; // now mic-boost on (+20dBs) and shift bits (>>6), +20+12=32 dB’s (orig fw +20 dBs+ 0dBs)=> +12dB's respect ref.
|
||||
break;
|
||||
case 1: // +06 dB’s reference level , (when +20dB's boost ON)
|
||||
shift_bits_s16 = 7; // now mic-boost on (+20dBs) and shift bits (>>7), +20+06=26 dB’s (orig fw +20 dBs+ 0dBs) => +06dB's respect ref.
|
||||
break;
|
||||
case 2:
|
||||
shift_bits_s16 = 4; // +04 dB’s respect ref level , (when +20dB's boost OFF)
|
||||
break; // now mic-boost off (+00dBs) shift bits (4) (+0+24dB's)=24 dBs => +04dB's respect ref.
|
||||
case 2:
|
||||
case 3:
|
||||
shift_bits_s16 = 5; // -02 dB’s respect ref level , (when +20dB's boost OFF)
|
||||
break; // now mic-boost off (+00dBs) shift bits (5) (+0+18dB's)=18 dBs => -02dB's respect ref.
|
||||
case 3:
|
||||
case 4:
|
||||
shift_bits_s16 = 6; // -08 dB’s respect ref level , (when +20dB's boost OFF)
|
||||
break; // now mic-boost off (+00dBs) shift bits (6) (+0+12dB's)=12 dBs => -08dB's respect ref.
|
||||
}
|
||||
configure_baseband(); // sending var-parameters msg , to audio_tx to M4 CPU Proc -
|
||||
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_0ff
|
||||
configure_baseband(); // to update in real timme,sending msg , var-parameters >>shift_bits FM msg ,to audio_tx from M0 to M4 Proc -
|
||||
};
|
||||
options_wm8731_boost_mode.set_selected_index(2); // preset GUI index.
|
||||
options_wm8731_boost_mode.set_selected_index(3); // preset GUI index 3 as default WM -> -02 dB's .
|
||||
} else {
|
||||
shift_bits_s16 = 8; // Initialized default fixed >>8 for FM tx mod , shift audio data for AK (using top 8 bits s16 data)
|
||||
shift_bits_s16 = 8; // Initialized default fixed >>8_FM for FM tx mod , shift audio data for AK4951 ,using top 8 bits s16 data (>>8)
|
||||
options_ak4951_alc_mode.on_change = [this](size_t, int8_t v) {
|
||||
ak_alc_GUI_selected = v; // 0,..11 AK-ALC options,
|
||||
audio::input::start(ak_alc_GUI_selected ); // Set up proper ALC mode in AK4951
|
||||
configure_baseband(); // sending var-parameters msg , to audiotx to M4-
|
||||
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.
|
||||
};
|
||||
}
|
||||
|
||||
@ -567,8 +570,7 @@ MicTXView::MicTXView(
|
||||
set_tx(false);
|
||||
|
||||
audio::set_rate(audio::Rate::Hz_24000);
|
||||
audio::input::start(ak_alc_GUI_selected ); // originally , audio::input::start(); (we added parameter)
|
||||
|
||||
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.
|
||||
}
|
||||
|
||||
MicTXView::~MicTXView() {
|
||||
|
@ -83,7 +83,7 @@ private:
|
||||
bool rx_enabled { false };
|
||||
uint32_t tone_key_index { };
|
||||
float mic_gain { 1.0 };
|
||||
uint8_t ak_alc_GUI_selected { 0 };
|
||||
uint8_t ak4951_alc_and_wm8731_boost_GUI { 0 };
|
||||
uint32_t audio_level { 0 };
|
||||
uint32_t va_level { };
|
||||
uint32_t attack_ms { };
|
||||
@ -190,12 +190,13 @@ private:
|
||||
|
||||
OptionsField options_wm8731_boost_mode {
|
||||
{ 22 * 8, 1 * 8 }, // Coordinates are: int:x (px), int:y (px)
|
||||
4,
|
||||
5,
|
||||
{
|
||||
{ "ON +00dB", 0 }, // WM8731 Mic Boost ON ,original condition, easy to saturate ADC sat in high voice ,relative G = +00 dB's (ref level) sampling 24Khz
|
||||
{ "OFF+04dB", 1 }, // WM8731 Mic Boost OFF to avoid ADC sat in high voice ,relative G = +04 dB's (respect ref level) sampling 24Khz
|
||||
{ "OFF-02dB", 2 }, // WM8731 Mic Boost OFF to avoid ADC sat in high voice ,relative G = -02 dB's (respect ref level)
|
||||
{ "OFF-08dB", 3 }, // WM8731 Mic Boost OFF to avoid ADC sat in high voice ,relative G = -12 dB's (respect ref level)
|
||||
{ "ON +12dB", 0 }, // WM8731 Mic Boost ON ,original+12dBs condition, easy to saturate ADC sat in high voice ,relative G = +12 dB's respect ref level
|
||||
{ "ON +06dB", 1 }, // WM8731 Mic Boost ON ,original+6 dBs condition, easy to saturate ADC sat in high voice ,relative G = +06 dB's respect ref level
|
||||
{ "OFF+04dB", 2 }, // WM8731 Mic Boost OFF to avoid ADC sat in high voice ,relative G = +04 dB's (respect ref level) , always effective sampling 24khz
|
||||
{ "OFF-02dB", 3 }, // WM8731 Mic Boost OFF to avoid ADC sat in high voice ,relative G = -02 dB's (respect ref level)
|
||||
{ "OFF-08dB", 4 }, // WM8731 Mic Boost OFF to avoid ADC sat in high voice ,relative G = -12 dB's (respect ref level)
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -43,13 +43,13 @@ void Modulator::set_over(uint32_t new_over) {
|
||||
}
|
||||
|
||||
void Modulator::set_gain_shiftbits_vumeter_beep(float new_audio_gain ,uint8_t new_audio_shift_bits_s16, bool new_play_beep ) {
|
||||
//new_audio_shift_bits_s16 are the direct shift bits (FM mod >>x) , and can be 8 fixed (AK) or 4,5,6 (WM boost OFF) or 8 (WM boost ON)
|
||||
//new_audio_shift_bits_s16 are the direct shift bits (FM mod >>x) , and it is fixed to >>8_FM (AK) or 4,5,6, (WM boost OFF) or 6,7 (WM boost ON)
|
||||
audio_gain = new_audio_gain ;
|
||||
audio_shift_bits_s16_FM = new_audio_shift_bits_s16; //FM : >>8(AK) fixed , >>4,5,6 (WM boost OFF)
|
||||
if (new_audio_shift_bits_s16==8) { //FM : we are in AK codec IC => for AM-SSB-DSB we were using >>2 fixed (wm boost ON) .
|
||||
audio_shift_bits_s16_AM_DSB_SSB = 2; //AM-DSB-SSB: >>2(AK) fixed , >>0,1,2 (WM boost OFF)
|
||||
} else {
|
||||
audio_shift_bits_s16_AM_DSB_SSB = (new_audio_shift_bits_s16-4) ; //AM-DSB-SSB: >>0,1,2 (WM boost OFF)
|
||||
audio_shift_bits_s16_AM_DSB_SSB = (new_audio_shift_bits_s16-4) ; //AM-DSB-SSB: >>0,1,2 (WM boost OFF), >>2,3 (WM boost ON)
|
||||
}
|
||||
play_beep = new_play_beep;
|
||||
}
|
||||
|
@ -345,19 +345,28 @@ public:
|
||||
void speaker_disable() {};
|
||||
|
||||
|
||||
void microphone_enable(int8_t alc_mode) override {
|
||||
(void)alc_mode; // to avoid "unused warning" when compiling. (@WM8731 we do not use that parameter)
|
||||
// TODO: Implement,
|
||||
}
|
||||
void microphone_enable(int8_t wm8731_boost_GUI) override {
|
||||
microphone_mute(true); // c/m to reduce "plop noise" when changing wm8731_boost_GUI.
|
||||
// chThdSleepMilliseconds(20); // does not help to reduce the "plop noise"
|
||||
microphone_boost((wm8731_boost_GUI<2) ? 1 : 0 ); // 1 = Enable Boost (+20 dBs) . 0 = Disable Boost (0dBs).
|
||||
chThdSleepMilliseconds(120); // >50 msegs, very effective , >100 msegs minor improvement ,120 msegs trade off speed .
|
||||
microphone_mute(false);
|
||||
// (void)alc_mode; In prev. fw version , when we did not use at all param., to avoid "unused warning" when compiling.)
|
||||
}
|
||||
|
||||
void microphone_disable() override {
|
||||
// TODO: Implement
|
||||
}
|
||||
|
||||
// void microphone_mute(const bool mute) {
|
||||
// map.r.analog_audio_path_control.mutemic = (mute ? 0 : 1);
|
||||
// write(Register::AnalogAudioPathControl);
|
||||
// }
|
||||
void microphone_boost(const bool boost) {
|
||||
map.r.analog_audio_path_control.micboost = (boost ? 1 : 0);
|
||||
write(Register::AnalogAudioPathControl);
|
||||
}
|
||||
|
||||
void microphone_mute(const bool mute) {
|
||||
map.r.analog_audio_path_control.mutemic = (mute ? 1 : 0); //1 = Enable Mute , 0 = Disable Mute
|
||||
write(Register::AnalogAudioPathControl);
|
||||
}
|
||||
|
||||
// void set_adc_source(const ADCSource adc_source) {
|
||||
// map.r.analog_audio_path_control.insel = toUType(adc_source);
|
||||
|
Loading…
Reference in New Issue
Block a user