From a5fb30c0c246da95c2bd981dc23545155de6e3ee Mon Sep 17 00:00:00 2001 From: Holger Wirtz Date: Thu, 7 Apr 2022 11:37:41 +0200 Subject: [PATCH] Fixes for float signal path. --- src/effect_platervbstereo.cpp | 15 +++++++-------- src/effect_platervbstereo.h | 11 ++--------- src/minidexed.cpp | 27 ++++++++++++++------------- src/minidexed.h | 1 + 4 files changed, 24 insertions(+), 30 deletions(-) diff --git a/src/effect_platervbstereo.cpp b/src/effect_platervbstereo.cpp index 5f4ec46..be92e6e 100644 --- a/src/effect_platervbstereo.cpp +++ b/src/effect_platervbstereo.cpp @@ -153,14 +153,13 @@ AudioEffectPlateReverb::AudioEffectPlateReverb(float32_t samplerate) lfo2_phase_acc = 0; lfo2_adder = (UINT32_MAX + 1)/(samplerate * LFO2_FREQ_HZ); - reverb_level = 0.0; + reverb_level = 0.0f; } // #define sat16(n, rshift) signed_saturate_rshift((n), 16, (rshift)) -void AudioEffectPlateReverb::doReverb(float32_t* audioblockL, float32_t* audioblockR, uint16_t len) +void AudioEffectPlateReverb::doReverb(float32_t* blockL, float32_t* blockR, uint16_t len) { - int i; float32_t input, acc, temp1, temp2; uint16_t temp16; float32_t rv_time; @@ -203,7 +202,7 @@ void AudioEffectPlateReverb::doReverb(float32_t* audioblockL, float32_t* audiobl rv_time = rv_time_k; - for (i=0; i < len; i++) + for (uint16_t i=0; i < len; i++) { // do the LFOs lfo1_phase_acc += lfo1_adder; @@ -236,7 +235,7 @@ void AudioEffectPlateReverb::doReverb(float32_t* audioblockL, float32_t* audiobl y += (int64_t)y1 * idx; lfo2_out_cos = (int32_t) (y >> (32-8)); // 16bit output - input = audioblockL[i] * input_attn; + input = blockL[i] * input_attn; // chained input allpasses, channel L acc = in_allp1_bufL[in_allp1_idxL] + input * in_allp_k; @@ -259,7 +258,7 @@ void AudioEffectPlateReverb::doReverb(float32_t* audioblockL, float32_t* audiobl in_allp_out_L = acc; if (++in_allp4_idxL >= sizeof(in_allp4_bufL)/sizeof(float32_t)) in_allp4_idxL = 0; - input = audioblockR[i] * input_attn; + input = blockR[i] * input_attn; // chained input allpasses, channel R acc = in_allp1_bufR[in_allp1_idxR] + input * in_allp_k; @@ -406,7 +405,7 @@ void AudioEffectPlateReverb::doReverb(float32_t* audioblockL, float32_t* audiobl temp1 = acc - master_lowpass_l; master_lowpass_l += temp1 * master_lowpass_f; - audioblockL[i]+=master_lowpass_l * reverb_level; + blockL[i] = blockL[i] + (master_lowpass_l * reverb_level); // Channel R #ifdef TAP1_MODULATED @@ -450,6 +449,6 @@ void AudioEffectPlateReverb::doReverb(float32_t* audioblockL, float32_t* audiobl temp1 = acc - master_lowpass_r; master_lowpass_r += temp1 * master_lowpass_f; - audioblockR[i]+=master_lowpass_r * reverb_level; + blockR[i] = blockR[i] + (master_lowpass_r * reverb_level); } } diff --git a/src/effect_platervbstereo.h b/src/effect_platervbstereo.h index 8db1bca..19a7baf 100644 --- a/src/effect_platervbstereo.h +++ b/src/effect_platervbstereo.h @@ -61,34 +61,28 @@ class AudioEffectPlateReverb { public: AudioEffectPlateReverb(float32_t samplerate); - void doReverb(float32_t* audioblockL, float32_t* audioblockR, uint16_t len); + void doReverb(float32_t* blockL, float32_t* blockR, uint16_t len); void size(float n) { n = constrain(n, 0.0f, 1.0f); n = mapfloat(n, 0.0f, 1.0f, 0.2f, rv_time_k_max); float32_t attn = mapfloat(n, 0.0f, rv_time_k_max, 0.5f, 0.25f); - //__disable_irq(); rv_time_k = n; input_attn = attn; - //__enable_irq(); } void hidamp(float n) { n = constrain(n, 0.0f, 1.0f); - //__disable_irq(); lp_hidamp_k = 1.0f - n; - //__enable_irq(); } void lodamp(float n) { n = constrain(n, 0.0f, 1.0f); - //__disable_irq(); lp_lodamp_k = -n; rv_time_scaler = 1.0f - n * 0.12f; // limit the max reverb time, otherwise it will clip - //__enable_irq(); } void lowpass(float n) @@ -102,10 +96,8 @@ public: { n = constrain(n, 0.0f, 1.0f); n = mapfloat(n, 0.0f, 1.0f, 0.005f, 0.65f); - //__disable_irq(); in_allp_k = n; loop_allp_k = n; - //__enable_irq(); } void level(float n) @@ -117,6 +109,7 @@ public: bool get_bypass(void) {return bypass;} void set_bypass(bool state) {bypass = state;}; void tgl_bypass(void) {bypass ^=1;} + float32_t get_level(void) {return reverb_level;} private: bool bypass = false; float32_t reverb_level; diff --git a/src/minidexed.cpp b/src/minidexed.cpp index eef5fa4..3701833 100644 --- a/src/minidexed.cpp +++ b/src/minidexed.cpp @@ -115,7 +115,7 @@ CMiniDexed::CMiniDexed (CConfig *pConfig, CInterruptSystem *pInterrupt, #endif // BEGIN setup tg_mixer - tg_mixer = new AudioStereoMixer<8>(); + //tg_mixer = new AudioStereoMixer<8>(); // END setup tg_mixer // BEGIN setup reverb @@ -124,7 +124,7 @@ CMiniDexed::CMiniDexed (CConfig *pConfig, CInterruptSystem *pInterrupt, SetParameter (ParameterReverbHighDamp, 50); SetParameter (ParameterReverbLowDamp, 50); SetParameter (ParameterReverbLowPass, 30); - SetParameter (ParameterReverbDiffusion, 65); + SetParameter (ParameterReverbDiffusion, 20); SetParameter (ParameterReverbLevel, 80); // END setup reverb }; @@ -702,18 +702,19 @@ void CMiniDexed::ProcessSound (void) assert (CConfig::ToneGenerators == 8); - for (uint16_t i = 0; i < nFrames; i++) + // BEGIN stereo panorama + for (uint8_t i = 0; i < CConfig::ToneGenerators; i++) { - for(uint8_t n=0; ndoReverb(SampleBuffer[0],SampleBuffer[1],nFrames); + reverb->doReverb(SampleBuffer[indexL],SampleBuffer[indexR],nFrames); m_ReverbSpinLock.Release (); // END adding reverb @@ -722,12 +723,12 @@ void CMiniDexed::ProcessSound (void) int16_t tmp_int[nFrames*2]; for(uint16_t i=0; iWrite (tmp_int, sizeof tmp_int) != (int) sizeof tmp_int) + if (m_pSoundDevice->Write (tmp_int, sizeof(tmp_int)) != (int) sizeof(tmp_int)) { LOGERR ("Sound data dropped"); } diff --git a/src/minidexed.h b/src/minidexed.h index 987b27a..17923b2 100644 --- a/src/minidexed.h +++ b/src/minidexed.h @@ -173,6 +173,7 @@ private: AudioEffectPlateReverb* reverb; AudioStereoMixer<8>* tg_mixer; + CSpinLock m_PanoramaSpinLock; CSpinLock m_ReverbSpinLock; };