|
|
|
@ -1354,33 +1354,20 @@ void CMiniDexed::ProcessSound (void) |
|
|
|
|
float32_t tmp_float[nFrames*Channels]; |
|
|
|
|
int32_t tmp_int[nFrames*Channels]; |
|
|
|
|
|
|
|
|
|
if(nMasterVolume > 0.0) |
|
|
|
|
// Convert dual float array (8 chan) to single int16 array (8 chan)
|
|
|
|
|
for(uint16_t i=0; i<nFrames;i++) |
|
|
|
|
{ |
|
|
|
|
// Convert dual float array (8 chan) to single int16 array (8 chan)
|
|
|
|
|
for(uint16_t i=0; i<nFrames;i++) |
|
|
|
|
// TGs will alternate on L/R channels for each output
|
|
|
|
|
// reading directly from the TG OutputLevel buffer with
|
|
|
|
|
// no additional processing.
|
|
|
|
|
for (uint8_t tg = 0; tg < Channels; tg++) |
|
|
|
|
{ |
|
|
|
|
// TGs will alternate on L/R channels for each output
|
|
|
|
|
// reading directly from the TG OutputLevel buffer with
|
|
|
|
|
// no additional processing.
|
|
|
|
|
for (uint8_t tg = 0; tg < Channels; tg++) |
|
|
|
|
{ |
|
|
|
|
if(nMasterVolume >0.0 && nMasterVolume <1.0) |
|
|
|
|
{ |
|
|
|
|
tmp_float[(i*Channels)+tg]=m_OutputLevel[tg][i] * nMasterVolume; |
|
|
|
|
} |
|
|
|
|
else if(nMasterVolume == 1.0) |
|
|
|
|
{ |
|
|
|
|
tmp_float[(i*Channels)+tg]=m_OutputLevel[tg][i]; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
tmp_float[(i*Channels)+tg]=m_OutputLevel[tg][i] * nMasterVolume; |
|
|
|
|
} |
|
|
|
|
arm_float_to_q23(tmp_float,tmp_int,nFrames*Channels); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
arm_fill_q31(0, tmp_int, nFrames*Channels); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
arm_float_to_q23(tmp_float,tmp_int,nFrames*Channels); |
|
|
|
|
|
|
|
|
|
// Prevent PCM510x analog mute from kicking in
|
|
|
|
|
for (uint8_t tg = 0; tg < Channels; tg++)
|
|
|
|
|
{ |
|
|
|
@ -1404,78 +1391,64 @@ void CMiniDexed::ProcessSound (void) |
|
|
|
|
float32_t tmp_float[nFrames*2]; |
|
|
|
|
int32_t tmp_int[nFrames*2]; |
|
|
|
|
|
|
|
|
|
if(nMasterVolume > 0.0) |
|
|
|
|
{ |
|
|
|
|
// get the mix buffer of all TGs
|
|
|
|
|
float32_t *SampleBuffer[2]; |
|
|
|
|
tg_mixer->getBuffers(SampleBuffer); |
|
|
|
|
// get the mix buffer of all TGs
|
|
|
|
|
float32_t *SampleBuffer[2]; |
|
|
|
|
tg_mixer->getBuffers(SampleBuffer); |
|
|
|
|
|
|
|
|
|
tg_mixer->zeroFill(); |
|
|
|
|
tg_mixer->zeroFill(); |
|
|
|
|
|
|
|
|
|
for (uint8_t i = 0; i < m_nToneGenerators; i++) |
|
|
|
|
{ |
|
|
|
|
tg_mixer->doAddMix(i,m_OutputLevel[i]); |
|
|
|
|
} |
|
|
|
|
// END TG mixing
|
|
|
|
|
|
|
|
|
|
// BEGIN adding reverb
|
|
|
|
|
if (m_nParameter[ParameterReverbEnable]) |
|
|
|
|
{ |
|
|
|
|
float32_t ReverbBuffer[2][nFrames]; |
|
|
|
|
for (uint8_t i = 0; i < m_nToneGenerators; i++) |
|
|
|
|
{ |
|
|
|
|
tg_mixer->doAddMix(i,m_OutputLevel[i]); |
|
|
|
|
} |
|
|
|
|
// END TG mixing
|
|
|
|
|
|
|
|
|
|
float32_t *ReverbSendBuffer[2]; |
|
|
|
|
reverb_send_mixer->getBuffers(ReverbSendBuffer); |
|
|
|
|
// BEGIN adding reverb
|
|
|
|
|
if (m_nParameter[ParameterReverbEnable]) |
|
|
|
|
{ |
|
|
|
|
float32_t ReverbBuffer[2][nFrames]; |
|
|
|
|
|
|
|
|
|
reverb_send_mixer->zeroFill(); |
|
|
|
|
float32_t *ReverbSendBuffer[2]; |
|
|
|
|
reverb_send_mixer->getBuffers(ReverbSendBuffer); |
|
|
|
|
|
|
|
|
|
for (uint8_t i = 0; i < m_nToneGenerators; i++) |
|
|
|
|
{ |
|
|
|
|
reverb_send_mixer->doAddMix(i,m_OutputLevel[i]); |
|
|
|
|
} |
|
|
|
|
reverb_send_mixer->zeroFill(); |
|
|
|
|
|
|
|
|
|
m_ReverbSpinLock.Acquire (); |
|
|
|
|
for (uint8_t i = 0; i < m_nToneGenerators; i++) |
|
|
|
|
{ |
|
|
|
|
reverb_send_mixer->doAddMix(i,m_OutputLevel[i]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
reverb->doReverb(ReverbSendBuffer[indexL],ReverbSendBuffer[indexR],ReverbBuffer[indexL], ReverbBuffer[indexR],nFrames); |
|
|
|
|
m_ReverbSpinLock.Acquire (); |
|
|
|
|
|
|
|
|
|
// scale down and add left reverb buffer by reverb level
|
|
|
|
|
arm_scale_f32(ReverbBuffer[indexL], reverb->get_level(), ReverbBuffer[indexL], nFrames); |
|
|
|
|
arm_add_f32(SampleBuffer[indexL], ReverbBuffer[indexL], SampleBuffer[indexL], nFrames); |
|
|
|
|
// scale down and add right reverb buffer by reverb level
|
|
|
|
|
arm_scale_f32(ReverbBuffer[indexR], reverb->get_level(), ReverbBuffer[indexR], nFrames); |
|
|
|
|
arm_add_f32(SampleBuffer[indexR], ReverbBuffer[indexR], SampleBuffer[indexR], nFrames); |
|
|
|
|
reverb->doReverb(ReverbSendBuffer[indexL],ReverbSendBuffer[indexR],ReverbBuffer[indexL], ReverbBuffer[indexR],nFrames); |
|
|
|
|
|
|
|
|
|
m_ReverbSpinLock.Release (); |
|
|
|
|
} |
|
|
|
|
// END adding reverb
|
|
|
|
|
// scale down and add left reverb buffer by reverb level
|
|
|
|
|
arm_scale_f32(ReverbBuffer[indexL], reverb->get_level(), ReverbBuffer[indexL], nFrames); |
|
|
|
|
arm_add_f32(SampleBuffer[indexL], ReverbBuffer[indexL], SampleBuffer[indexL], nFrames); |
|
|
|
|
// scale down and add right reverb buffer by reverb level
|
|
|
|
|
arm_scale_f32(ReverbBuffer[indexR], reverb->get_level(), ReverbBuffer[indexR], nFrames); |
|
|
|
|
arm_add_f32(SampleBuffer[indexR], ReverbBuffer[indexR], SampleBuffer[indexR], nFrames); |
|
|
|
|
|
|
|
|
|
// swap stereo channels if needed prior to writing back out
|
|
|
|
|
if (m_bChannelsSwapped) |
|
|
|
|
{ |
|
|
|
|
indexL=1; |
|
|
|
|
indexR=0; |
|
|
|
|
} |
|
|
|
|
m_ReverbSpinLock.Release (); |
|
|
|
|
} |
|
|
|
|
// END adding reverb
|
|
|
|
|
|
|
|
|
|
// Convert dual float array (left, right) to single int16 array (left/right)
|
|
|
|
|
for(uint16_t i=0; i<nFrames;i++) |
|
|
|
|
{ |
|
|
|
|
if(nMasterVolume >0.0 && nMasterVolume <1.0) |
|
|
|
|
{ |
|
|
|
|
tmp_float[i*2]=SampleBuffer[indexL][i] * nMasterVolume; |
|
|
|
|
tmp_float[(i*2)+1]=SampleBuffer[indexR][i] * nMasterVolume; |
|
|
|
|
} |
|
|
|
|
else if(nMasterVolume == 1.0) |
|
|
|
|
{ |
|
|
|
|
tmp_float[i*2]=SampleBuffer[indexL][i]; |
|
|
|
|
tmp_float[(i*2)+1]=SampleBuffer[indexR][i]; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
arm_float_to_q23(tmp_float,tmp_int,nFrames*2); |
|
|
|
|
// swap stereo channels if needed prior to writing back out
|
|
|
|
|
if (m_bChannelsSwapped) |
|
|
|
|
{ |
|
|
|
|
indexL=1; |
|
|
|
|
indexR=0; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
|
|
|
|
|
// Convert dual float array (left, right) to single int16 array (left/right)
|
|
|
|
|
for(uint16_t i=0; i<nFrames;i++) |
|
|
|
|
{ |
|
|
|
|
arm_fill_q31(0, tmp_int, nFrames * 2); |
|
|
|
|
tmp_float[i*2]=SampleBuffer[indexL][i] * nMasterVolume; |
|
|
|
|
tmp_float[(i*2)+1]=SampleBuffer[indexR][i] * nMasterVolume; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
arm_float_to_q23(tmp_float,tmp_int,nFrames*2); |
|
|
|
|
|
|
|
|
|
// Prevent PCM510x analog mute from kicking in
|
|
|
|
|
if (tmp_int[nFrames * 2 - 1] == 0) |
|
|
|
|
{ |
|
|
|
|