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