|
|
|
@ -34,15 +34,12 @@ void AudioEffectSimpleChorus::update(void) |
|
|
|
|
{ |
|
|
|
|
audio_block_t *inputAudioBlock = receiveReadOnly(); // get the next block of input samples
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
// Check is block is disabled
|
|
|
|
|
if (m_enable == false) { |
|
|
|
|
// do not transmit or process any audio, return as quickly as possible.
|
|
|
|
|
if (inputAudioBlock) release(inputAudioBlock); |
|
|
|
|
|
|
|
|
|
// release all held memory resources
|
|
|
|
|
if (m_previousBlock) { |
|
|
|
|
release(m_previousBlock); m_previousBlock = nullptr; |
|
|
|
|
} |
|
|
|
|
// when using internal memory we have to release all references in the ring buffer
|
|
|
|
|
while (m_memory->getRingBuffer()->size() > 0) { |
|
|
|
|
audio_block_t *releaseBlock = m_memory->getRingBuffer()->front(); |
|
|
|
@ -67,45 +64,47 @@ void AudioEffectSimpleChorus::update(void) |
|
|
|
|
release(inputAudioBlock); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
*/ |
|
|
|
|
// Otherwise perform normal processing
|
|
|
|
|
// In order to make use of the SPI DMA, we need to request the read from memory first,
|
|
|
|
|
// then do other processing while it fills in the back.
|
|
|
|
|
audio_block_t *blockToOutput = nullptr; // this will hold the output audio
|
|
|
|
|
blockToOutput = allocate(); |
|
|
|
|
if (!blockToOutput) return; // skip this update cycle due to failure
|
|
|
|
|
|
|
|
|
|
// get the data. If using external memory with DMA, this won't be filled until
|
|
|
|
|
// later.
|
|
|
|
|
m_memory->getSamples(blockToOutput, m_delaySamples); |
|
|
|
|
|
|
|
|
|
//audio_block_t *blockToRelease = m_memory->addBlock(blockToOutput);
|
|
|
|
|
|
|
|
|
|
// If using DMA, we need something else to do while that read executes, so
|
|
|
|
|
// move on to input preprocessing
|
|
|
|
|
|
|
|
|
|
// Chorus
|
|
|
|
|
float *mod = lfo.getNextVector(); |
|
|
|
|
for(uint8_t i=0;i<AUDIO_BLOCK_SAMPLES;i++) |
|
|
|
|
{ |
|
|
|
|
/// HIER
|
|
|
|
|
//float sample=std::roundf((m_delaySamples/2)*mod[i]*(float)inputAudioBlock->data[i])+(m_delaySamples/2);
|
|
|
|
|
//inputAudioBlock->data[i] = (int16_t)sample/2+inputAudioBlock->data[i]/2;
|
|
|
|
|
blockToOutput->data[i]=(float(inputAudioBlock->data[i])*mod[i]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// BACK TO OUTPUT PROCESSING
|
|
|
|
|
blockToOutput = allocate(); |
|
|
|
|
if (!blockToOutput) return; // skip this update cycle due to failure
|
|
|
|
|
memset(blockToOutput->data,0,AUDIO_BLOCK_SAMPLES * sizeof(int16_t)); |
|
|
|
|
|
|
|
|
|
audio_block_t *blockToRelease = m_memory->addBlock(inputAudioBlock); |
|
|
|
|
|
|
|
|
|
// Chorus
|
|
|
|
|
float *mod = lfo.getNextVector(); |
|
|
|
|
audio_block_t *lfoData = nullptr; |
|
|
|
|
lfoData = allocate(); |
|
|
|
|
if (!lfoData) return; |
|
|
|
|
for(uint8_t i=0;i<AUDIO_BLOCK_SAMPLES;i++) |
|
|
|
|
{ |
|
|
|
|
//m_memory->getSamples(blockToOutput,m_delaySamples);
|
|
|
|
|
m_memory->getSamples(lfoData,float(m_delaySamples)/2+(m_intensity*mod[i]*float(m_delaySamples)/2),3); |
|
|
|
|
if(mod[i]==0.0) |
|
|
|
|
blockToOutput->data[i]=lfoData->data[1]; |
|
|
|
|
else if(mod[i]<0.0) |
|
|
|
|
blockToOutput->data[i]=int16_t(((float(lfoData->data[0])-lfoData->data[1])*(1+mod[i]))+lfoData->data[0]+0.5); |
|
|
|
|
else |
|
|
|
|
blockToOutput->data[i]=int16_t(((float(lfoData->data[2])-lfoData->data[1])*mod[i])+lfoData->data[2]+0.5); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// perform the wet/dry mix mix
|
|
|
|
|
//m_postProcessing(blockToOutput, inputAudioBlock, blockToOutput);
|
|
|
|
|
transmit(blockToOutput); |
|
|
|
|
|
|
|
|
|
release(inputAudioBlock); |
|
|
|
|
release(m_previousBlock); |
|
|
|
|
release(lfoData); |
|
|
|
|
if(m_previousBlock) |
|
|
|
|
release(m_previousBlock); |
|
|
|
|
m_previousBlock = blockToOutput; |
|
|
|
|
release(blockToOutput); |
|
|
|
|
|
|
|
|
|
//if (m_blockToRelease) release(m_blockToRelease);
|
|
|
|
|
//m_blockToRelease = blockToRelease;
|
|
|
|
|
if (m_blockToRelease) |
|
|
|
|
release(m_blockToRelease); |
|
|
|
|
m_blockToRelease = blockToRelease; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void AudioEffectSimpleChorus::delay(float milliseconds) |
|
|
|
|