Added T.40 kluge to AudioDelay class

pull/10/head
Steve Lascos 4 years ago
parent 235dacf5a1
commit 8c2515ee44
  1. 2
      src/LibBasicFunctions.h
  2. 16
      src/common/AudioDelay.cpp

@ -201,7 +201,7 @@ public:
/// @returns true if suceess, false if an error occurs
bool setSpiDmaCopyBuffer(void);
/// Ween using INTERNAL memory, thsi function can return a pointer to the underlying RingBuffer that contains
/// When using INTERNAL memory, this function can return a pointer to the underlying RingBuffer that contains
/// audio_block_t * pointers.
/// @returns pointer to the underlying RingBuffer
RingBuffer<audio_block_t*> *getRingBuffer() const { return m_ringBuffer; }

@ -79,6 +79,14 @@ audio_block_t* AudioDelay::addBlock(audio_block_t *block)
if (!m_slot) { Serial.println("addBlock(): m_slot is not valid"); }
if (block) {
// KLUGE! The Teensy Audio Library doesn't support DMA buffers correctly on the T4.0. We need to
// use an intermediate copy buffer kluge here.
#if defined(__IMXRT1062__)
// This is a T4.0 build
setSpiDmaCopyBuffer();
#endif
// this causes pops
m_slot->writeAdvance16(block->data, AUDIO_BLOCK_SAMPLES);
}
@ -164,6 +172,7 @@ bool AudioDelay::m_getSamples(int16_t *dest, size_t offsetSamples, size_t numSam
} else {
// EXTERNAL Memory
if (numSamples*sizeof(int16_t) <= m_slot->size() ) { // check for overflow
// current position is considered the write position subtracted by the number of samples we're going
// to read since this is the smallest delay we can get without reading past the write position into
// the "future".
@ -216,8 +225,11 @@ bool AudioDelay::setSpiDmaCopyBuffer(void)
// For DMA use on T4.0 we need this kluge
BASpiMemoryDMA * spiDma = static_cast<BASpiMemoryDMA*>(m_slot->getSpiMemoryHandle());
if (spiDma) {
spiDma->setDmaCopyBufferSize(sizeof(int16_t) * AUDIO_BLOCK_SAMPLES);
returnValue = true;
// Check if the size is already set
if (spiDma->getDmaCopyBufferSize() == 0) {
spiDma->setDmaCopyBufferSize(sizeof(int16_t) * AUDIO_BLOCK_SAMPLES);
returnValue = true;
}
}
}
return returnValue;

Loading…
Cancel
Save