From 016d1d48c067c0f36a9e5ad269c18f0eaddf800b Mon Sep 17 00:00:00 2001 From: Holger Wirtz Date: Fri, 8 Apr 2022 14:51:31 +0200 Subject: [PATCH] Fixes for wrong panning calculation. --- src/Synth_Dexed.mk | 2 +- src/minidexed.cpp | 30 ++++++++++++++++++++---------- src/minidexed.h | 2 +- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/src/Synth_Dexed.mk b/src/Synth_Dexed.mk index b411b0b..498038a 100644 --- a/src/Synth_Dexed.mk +++ b/src/Synth_Dexed.mk @@ -30,6 +30,6 @@ INCLUDE += -I $(SYNTH_DEXED_DIR) INCLUDE += -I $(CMSIS_CORE_INCLUDE_DIR) INCLUDE += -I $(CMSIS_DSP_INCLUDE_DIR) INCLUDE += -I $(CMSIS_DSP_PRIVATE_INCLUDE_DIR) -CXXFLAGS += -DARM_MATH_NEON +CXXFLAGS += -DARM_MATH_NEON -DHAVE_NEON EXTRACLEAN = $(SYNTH_DEXED_DIR)/*.[od] $(CMSIS_DSP_SOURCE_DIR)/SupportFunctions/*.[od] $(CMSIS_DSP_SOURCE_DIR)/SupportFunctions/*.[od] $(CMSIS_DSP_SOURCE_DIR)/BasicMathFunctions/*.[od] $(CMSIS_DSP_SOURCE_DIR)/FastMathFunctions/*.[od] $(CMSIS_DSP_SOURCE_DIR)/FilteringFunctions/*.[od] $(CMSIS_DSP_SOURCE_DIR)/CommonTables/*.[od] diff --git a/src/minidexed.cpp b/src/minidexed.cpp index 8f71675..f33a5ca 100644 --- a/src/minidexed.cpp +++ b/src/minidexed.cpp @@ -58,6 +58,7 @@ CMiniDexed::CMiniDexed (CConfig *pConfig, CInterruptSystem *pInterrupt, m_nProgram[i] = 0; m_nVolume[i] = 100; m_nPan[i] = 64; + m_fPan[i] = 0.5f; m_nMasterTune[i] = 0; m_nMIDIChannel[i] = CMIDIDevice::Disabled; @@ -113,8 +114,6 @@ CMiniDexed::CMiniDexed (CConfig *pConfig, CInterruptSystem *pInterrupt, } #endif - SetParameter (ParameterCompressorEnable, 1); - // BEGIN setup reverb reverb = new AudioEffectPlateReverb(pConfig->GetSampleRate()); SetParameter (ParameterReverbEnable, 1); @@ -125,6 +124,8 @@ CMiniDexed::CMiniDexed (CConfig *pConfig, CInterruptSystem *pInterrupt, SetParameter (ParameterReverbDiffusion, 65); SetParameter (ParameterReverbLevel, 80); // END setup reverb + + SetParameter (ParameterCompressorEnable, 1); }; bool CMiniDexed::Initialize (void) @@ -368,7 +369,8 @@ void CMiniDexed::SetPan (unsigned nPan, unsigned nTG) assert (nTG < CConfig::ToneGenerators); m_nPan[nTG] = nPan; - + m_fPan[nTG]=mapfloat(nPan,0,127,0.0,1.0); + m_UI.ParameterChanged (); } @@ -672,11 +674,20 @@ void CMiniDexed::ProcessSound (void) m_GetChunkTimer.Start (); } - int16_t SampleBuffer[nFrames]; - m_pTG[0]->getSamples (nFrames, SampleBuffer); + float32_t SampleBuffer[nFrames]; + m_pTG[0]->getSamples (SampleBuffer, nFrames); - if ( m_pSoundDevice->Write (SampleBuffer, sizeof SampleBuffer) - != (int) sizeof SampleBuffer) + // Convert dual float array (left, right) to single int16 array (left/right) + float32_t tmp_float[nFrames*2]; + int16_t tmp_int[nFrames*2]; + for(uint16_t i=0; iWrite (tmp_int, sizeof(tmp_int)) != (int) sizeof(tmp_int)) { LOGERR ("Sound data dropped"); } @@ -758,15 +769,14 @@ void CMiniDexed::ProcessSound (void) m_PanoramaSpinLock.Acquire (); // calculate left panorama of this TG - arm_scale_f32(m_OutputLevel[i], 1.0f-pan_float[i], tmpBuffer, nFrames); + arm_scale_f32(m_OutputLevel[i], 1.0f-m_fPan[i], tmpBuffer, nFrames); // add left panorama output of this TG to sum output arm_add_f32(SampleBuffer[indexL], tmpBuffer, SampleBuffer[indexL], nFrames); // calculate right panorama of this TG - arm_scale_f32(m_OutputLevel[i], pan_float[i], tmpBuffer, nFrames); + arm_scale_f32(m_OutputLevel[i], m_fPan[i], tmpBuffer, nFrames); // add right panaorama output of this TG to sum output arm_add_f32(SampleBuffer[indexR], tmpBuffer, SampleBuffer[indexR], nFrames); - m_PanoramaSpinLock.Release (); } // END stereo panorama diff --git a/src/minidexed.h b/src/minidexed.h index 0953c6a..1aed730 100644 --- a/src/minidexed.h +++ b/src/minidexed.h @@ -143,7 +143,7 @@ private: unsigned m_nProgram[CConfig::ToneGenerators]; unsigned m_nVolume[CConfig::ToneGenerators]; unsigned m_nPan[CConfig::ToneGenerators]; - float32_t pan_float[CConfig::ToneGenerators]; + float32_t m_fPan[CConfig::ToneGenerators]; int m_nMasterTune[CConfig::ToneGenerators]; unsigned m_nMIDIChannel[CConfig::ToneGenerators];