Added T.40 kluge to AudioDelay class

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

@ -201,7 +201,7 @@ public:
/// @returns true if suceess, false if an error occurs /// @returns true if suceess, false if an error occurs
bool setSpiDmaCopyBuffer(void); 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. /// audio_block_t * pointers.
/// @returns pointer to the underlying RingBuffer /// @returns pointer to the underlying RingBuffer
RingBuffer<audio_block_t*> *getRingBuffer() const { return m_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 (!m_slot) { Serial.println("addBlock(): m_slot is not valid"); }
if (block) { 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 // this causes pops
m_slot->writeAdvance16(block->data, AUDIO_BLOCK_SAMPLES); 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 { } else {
// EXTERNAL Memory // EXTERNAL Memory
if (numSamples*sizeof(int16_t) <= m_slot->size() ) { // check for overflow 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 // 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 // to read since this is the smallest delay we can get without reading past the write position into
// the "future". // the "future".
@ -216,10 +225,13 @@ bool AudioDelay::setSpiDmaCopyBuffer(void)
// For DMA use on T4.0 we need this kluge // For DMA use on T4.0 we need this kluge
BASpiMemoryDMA * spiDma = static_cast<BASpiMemoryDMA*>(m_slot->getSpiMemoryHandle()); BASpiMemoryDMA * spiDma = static_cast<BASpiMemoryDMA*>(m_slot->getSpiMemoryHandle());
if (spiDma) { if (spiDma) {
// Check if the size is already set
if (spiDma->getDmaCopyBufferSize() == 0) {
spiDma->setDmaCopyBufferSize(sizeof(int16_t) * AUDIO_BLOCK_SAMPLES); spiDma->setDmaCopyBufferSize(sizeof(int16_t) * AUDIO_BLOCK_SAMPLES);
returnValue = true; returnValue = true;
} }
} }
}
return returnValue; return returnValue;
} }

Loading…
Cancel
Save