pull/19/head
Blackaddr 2 years ago
parent be5469d4d1
commit 7f450ececb
  1. 10
      examples/Delay/AnalogDelayDemo/AnalogDelayDemo.ino
  2. 18
      examples/Delay/AnalogDelayDemoExpansion/AnalogDelayDemoExpansion.ino
  3. 4
      examples/Delay/ExternalDelayDemo/ExternalDelayDemo.ino
  4. 9
      examples/Delay/SoundOnSoundDemo/SoundOnSoundDemo.ino
  5. 15
      examples/Delay/SoundOnSoundExpansionDemo/SoundOnSoundExpansionDemo.ino
  6. 8
      examples/Modulation/TemoloDemo/TemoloDemo.ino
  7. 14
      examples/Modulation/TremoloDemoExpansion/TremoloDemoExpansion.ino
  8. 2
      examples/Tests/DMA_MEM0_test/DMA_MEM0_test.ino
  9. 15
      examples/Tests/DMA_MEM1_test/DMA_MEM1_test.ino
  10. 4
      examples/Tests/TGA_PRO_Basic_Test/PhysicalControls.cpp
  11. 7
      examples/Tests/TGA_PRO_Basic_Test/TGA_PRO_Basic_Test.ino
  12. 3
      examples/Tests/TGA_PRO_Basic_Test/UartTest.cpp
  13. 12
      examples/Tests/TGA_PRO_Basic_Test/spiTest.cpp
  14. 10
      src/BATypes.h
  15. 10
      src/DmaSpi.h
  16. 10
      src/common/AudioDelay.cpp
  17. 7
      src/common/ExtMemSlot.cpp
  18. 20
      src/common/ParameterAutomation.cpp
  19. 51
      src/effects/AudioEffectAnalogDelay.cpp
  20. 2
      src/effects/AudioEffectDelayExternal.cpp
  21. 18
      src/effects/AudioEffectRmsMeasure.cpp
  22. 37
      src/effects/AudioEffectSOS.cpp
  23. 36
      src/effects/AudioEffectTremolo.cpp
  24. 9
      src/peripherals/BAAudioControlWM8731.cpp
  25. 6
      src/peripherals/BAPhysicalControls.cpp
  26. 14
      src/peripherals/BASpiMemory.cpp
  27. 19
      src/peripherals/DmaSpi.cpp

@ -76,6 +76,7 @@ elapsedMillis timer;
void OnControlChange(byte channel, byte control, byte value) {
analogDelay.processMidi(channel-1, control, value);
#ifdef MIDI_DEBUG
if (Serial) {
Serial.print("Control Change, ch=");
Serial.print(channel, DEC);
Serial.print(", control=");
@ -83,6 +84,7 @@ void OnControlChange(byte channel, byte control, byte value) {
Serial.print(", value=");
Serial.print(value, DEC);
Serial.println();
}
#endif
}
@ -107,19 +109,19 @@ void setup() {
delay(5);
// Enable the codec
Serial.println("Enabling codec...\n");
if (Serial) { Serial.println("Enabling codec...\n"); }
codec.enable();
delay(100);
// If using external memory request request memory from the manager
// for the slot
#ifdef USE_EXT
Serial.println("Using EXTERNAL memory");
if (Serial) { Serial.println("Using EXTERNAL memory"); }
// We have to request memory be allocated to our slot.
externalSram.requestMemory(&delaySlot, 500.0f, MemSelect::MEM0, true);
delaySlot.clear();
#else
Serial.println("Using INTERNAL memory");
if (Serial) { Serial.println("Using INTERNAL memory"); }
#endif
// Setup MIDI
@ -166,11 +168,13 @@ void loop() {
if (timer > 1000) {
timer = 0;
if (Serial) {
Serial.print("Processor Usage, Total: "); Serial.print(AudioProcessorUsage());
Serial.print("% ");
Serial.print(" analogDelay: "); Serial.print(analogDelay.processorUsage());
Serial.println("%");
}
}
MIDI.read();
usbMIDI.read();

@ -130,19 +130,19 @@ void setup() {
AudioMemory(128);
// Enable and configure the codec
Serial.println("Enabling codec...\n");
if (Serial) { Serial.println("Enabling codec...\n"); }
codec.enable();
codec.setHeadphoneVolume(1.0f); // Max headphone volume
// If using external memory request request memory from the manager
// for the slot
#ifdef USE_EXT
Serial.println("Using EXTERNAL memory");
if (Serial) { Serial.println("Using EXTERNAL memory"); }
// We have to request memory be allocated to our slot.
externalSram.requestMemory(&delaySlot, 500.0f, MemSelect::MEM0, true);
delaySlot.clear();
#else
Serial.println("Using INTERNAL memory");
if (Serial) { Serial.println("Using INTERNAL memory"); }
#endif
// Besure to enable the delay. When disabled, audio is is completely blocked by the effect
@ -180,7 +180,7 @@ void loop() {
bypass = !bypass; // change it
analogDelay.bypass(bypass); // set the new state
controls.setOutput(led1Handle, !bypass); // Set the LED when NOT bypassed
Serial.println(String("BYPASS is ") + bypass);
if (Serial) { Serial.println(String("BYPASS is ") + bypass); }
}
// Use SW2 to cycle through the filters
@ -189,27 +189,27 @@ void loop() {
filterIndex = (filterIndex + 1) % 3; // update and potentionall roll the counter 0, 1, 2, 0, 1, 2, ...
// cast the index between 0 to 2 to the enum class AudioEffectAnalogDelay::Filter
analogDelay.setFilter(static_cast<AudioEffectAnalogDelay::Filter>(filterIndex)); // will cycle through 0 to 2
Serial.println(String("Filter set to ") + filterIndex);
if (Serial) { Serial.println(String("Filter set to ") + filterIndex); }
}
// Use POT1 (left) to control the delay setting
if (controls.checkPotValue(delayHandle, potValue)) {
// Pot has changed
Serial.println(String("New DELAY setting: ") + potValue);
if (Serial) { Serial.println(String("New DELAY setting: ") + potValue); }
analogDelay.delayFractionMax(potValue);
}
// Use POT2 (right) to control the feedback setting
if (controls.checkPotValue(feedbackHandle, potValue)) {
// Pot has changed
Serial.println(String("New FEEDBACK setting: ") + potValue);
if (Serial) { Serial.println(String("New FEEDBACK setting: ") + potValue); }
analogDelay.feedback(potValue);
}
// Use POT3 (centre) to control the mix setting
if (controls.checkPotValue(mixHandle, potValue)) {
// Pot has changed
Serial.println(String("New MIX setting: ") + potValue);
if (Serial) { Serial.println(String("New MIX setting: ") + potValue); }
analogDelay.mix(potValue);
}
@ -235,10 +235,12 @@ void loop() {
if (timer > 1000) {
timer = 0;
if (Serial) {
Serial.print("Processor Usage, Total: "); Serial.print(AudioProcessorUsage());
Serial.print("% ");
Serial.print(" analogDelay: "); Serial.print(analogDelay.processorUsage());
Serial.println("%");
}
}
}

@ -62,10 +62,10 @@ void setup() {
AudioMemory(64);
delay(500);
Serial.println(String("Starting...\n"));
if (Serial) { Serial.println(String("Starting...\n")); }
delay(100);
Serial.println("Enabling codec...\n");
if (Serial) { Serial.println("Enabling codec...\n"); }
codecControl.enable();
delay(100);

@ -84,6 +84,7 @@ elapsedMillis timer;
void OnControlChange(byte channel, byte control, byte value) {
sos.processMidi(channel-1, control, value);
#ifdef MIDI_DEBUG
if (Serial) {
Serial.print("Control Change, ch=");
Serial.print(channel, DEC);
Serial.print(", control=");
@ -91,6 +92,7 @@ void OnControlChange(byte channel, byte control, byte value) {
Serial.print(", value=");
Serial.print(value, DEC);
Serial.println();
}
#endif
}
@ -109,16 +111,13 @@ void setup() {
// Disable the codec first
codec.disable();
delay(100);
AudioMemory(128);
delay(5);
SPI_MEM0_1M(); // Configure the SPI memory size
// Enable the codec
Serial.println("Enabling codec...\n");
if (Serial) { Serial.println("Enabling codec...\n"); }
codec.enable();
delay(100);
// We have to request memory be allocated to our slot.
externalSram.requestMemory(&delaySlot, BAHardwareConfig.getSpiMemSizeBytes(MemSelect::MEM0), MemSelect::MEM0, true);
@ -178,11 +177,13 @@ void loop() {
if (timer > 1000) {
timer = 0;
if (Serial) {
Serial.print("Processor Usage, Total: "); Serial.print(AudioProcessorUsage());
Serial.print("% ");
Serial.print(" SOS: "); Serial.print(sos.processorUsage());
Serial.println("%");
}
}
MIDI.read();
usbMIDI.read();

@ -114,7 +114,6 @@ void setup() {
//SPI_MEM0_4M(); // Older REVB / REVA boards offered 1M or 4M
//SPI_MEM0_1M();
delay(100);
delay(100); // wait a bit for serial to be available
Serial.begin(57600); // Start the serial port
delay(100); // wait a bit for serial to be available
@ -136,7 +135,7 @@ void setup() {
AudioMemory(128);
// Enable the codec
Serial.println("Enabling codec...\n");
if (Serial) { Serial.println("Enabling codec...\n"); }
codec.enable();
codec.setHeadphoneVolume(1.0f); // Max headphone volume
@ -188,34 +187,34 @@ void loop() {
// LED1 will be directly control by the SOS effect, not by BAPhysicalControls
if (controls.isSwitchToggled(gateHandle)) {
sos.trigger();
Serial.println("GATE OPEN is triggered");
if (Serial) { Serial.println("GATE OPEN is triggered"); }
}
// Use SW2 to clear out the SOS delayline
controls.setOutput(led2Handle, controls.getSwitchValue(led2Handle));
if (controls.isSwitchToggled(clearHandle)) {
sos.clear();
Serial.println("GATE CLEAR is triggered");
if (Serial) { Serial.println("GATE CLEAR is triggered"); }
}
// Use POT1 (left) to control the OPEN GATE time
if (controls.checkPotValue(openHandle, potValue)) {
// Pot has changed
sos.gateOpenTime(potValue * MAX_GATE_TIME_MS);
Serial.println(String("New OPEN GATE setting (ms): ") + (potValue * MAX_GATE_TIME_MS));
if (Serial) { Serial.println(String("New OPEN GATE setting (ms): ") + (potValue * MAX_GATE_TIME_MS)); }
}
// Use POT2 (right) to control the CLOSE GATE time
if (controls.checkPotValue(closeHandle, potValue)) {
// Pot has changed
sos.gateCloseTime(potValue * MAX_GATE_TIME_MS);
Serial.println(String("New CLOSE GATE setting (ms): ") + (potValue * MAX_GATE_TIME_MS));
if (Serial) { Serial.println(String("New CLOSE GATE setting (ms): ") + (potValue * MAX_GATE_TIME_MS)); }
}
// Use POT3 (centre) to control the sos effect volume
if (controls.checkPotValue(volumeHandle, potValue)) {
// Pot has changed
Serial.println(String("New SOS VOLUME setting: ") + potValue);
if (Serial) { Serial.println(String("New SOS VOLUME setting: ") + potValue); }
sos.volume(potValue);
}
@ -241,9 +240,11 @@ void loop() {
if (timer > 1000) {
timer = 0;
if (Serial) {
Serial.print("Processor Usage, Total: "); Serial.print(AudioProcessorUsage());
Serial.print("% ");
Serial.print(" SOS: "); Serial.print(sos.processorUsage());
Serial.println("%");
}
}
}

@ -57,6 +57,7 @@ elapsedMillis timer;
void OnControlChange(byte channel, byte control, byte value) {
tremolo.processMidi(channel-1, control, value);
#ifdef MIDI_DEBUG
if (Serial) {
Serial.print("Control Change, ch=");
Serial.print(channel, DEC);
Serial.print(", control=");
@ -64,6 +65,7 @@ void OnControlChange(byte channel, byte control, byte value) {
Serial.print(", value=");
Serial.print(value, DEC);
Serial.println();
}
#endif
}
@ -78,14 +80,12 @@ void setup() {
// Disable the codec first
codec.disable();
delay(100);
AudioMemory(128);
delay(5);
// Enable the codec
Serial.println("Enabling codec...\n");
if (Serial) { Serial.println("Enabling codec...\n"); }
codec.enable();
delay(100);
// Setup MIDI
MIDI.begin(MIDI_CHANNEL_OMNI);
@ -121,11 +121,13 @@ void loop() {
if (timer > 1000) {
timer = 0;
if (Serial) {
Serial.print("Processor Usage, Total: "); Serial.print(AudioProcessorUsage());
Serial.print("% ");
Serial.print(" tremolo: "); Serial.print(tremolo.processorUsage());
Serial.println("%");
}
}
MIDI.read();
usbMIDI.read();

@ -104,7 +104,7 @@ void setup() {
AudioMemory(128);
// Enable and configure the codec
Serial.println("Enabling codec...\n");
if (Serial) { Serial.println("Enabling codec...\n"); }
codec.enable();
codec.setHeadphoneVolume(1.0f); // Max headphone volume
@ -141,7 +141,7 @@ void loop() {
bypass = !bypass; // change it
tremolo.bypass(bypass); // set the new state
controls.setOutput(led1Handle, !bypass); // Set the LED when NOT bypassed
Serial.println(String("BYPASS is ") + bypass);
if (Serial) { Serial.println(String("BYPASS is ") + bypass); }
}
// Use SW2 to cycle through the waveforms
@ -150,27 +150,27 @@ void loop() {
waveformIndex = (waveformIndex + 1) % static_cast<unsigned>(Waveform::NUM_WAVEFORMS);
// cast the index
tremolo.setWaveform(static_cast<Waveform>(waveformIndex));
Serial.println(String("Waveform set to ") + waveformIndex);
if (Serial) { Serial.println(String("Waveform set to ") + waveformIndex); }
}
// Use POT1 (left) to control the rate setting
if (controls.checkPotValue(rateHandle, potValue)) {
// Pot has changed
Serial.println(String("New RATE setting: ") + potValue);
if (Serial) { Serial.println(String("New RATE setting: ") + potValue); }
tremolo.rate(potValue);
}
// Use POT2 (right) to control the depth setting
if (controls.checkPotValue(depthHandle, potValue)) {
// Pot has changed
Serial.println(String("New DEPTH setting: ") + potValue);
if (Serial) { Serial.println(String("New DEPTH setting: ") + potValue); }
tremolo.depth(potValue);
}
// Use POT3 (centre) to control the volume setting
if (controls.checkPotValue(volumeHandle, potValue)) {
// Pot has changed
Serial.println(String("New VOLUME setting: ") + potValue);
if (Serial) { Serial.println(String("New VOLUME setting: ") + potValue); }
tremolo.volume(potValue);
}
@ -196,10 +196,12 @@ void loop() {
if (timer > 1000) {
timer = 0;
if (Serial) {
Serial.print("Processor Usage, Total: "); Serial.print(AudioProcessorUsage());
Serial.print("% ");
Serial.print(" tremolo: "); Serial.print(tremolo.processorUsage());
Serial.println("%");
}
}
}

@ -72,7 +72,7 @@ void setup() {
SPI_MEM0_1M();
SPI_MAX_ADDR = BAHardwareConfig.getSpiMemMaxAddr(MemSelect::MEM0);
Serial.println("Enabling SPI, testing MEM0");
Serial.printf("Enabling SPI, testing MEM0 up to addres %08X\n\r", SPI_MAX_ADDR);
spiMem0.begin();
}

@ -30,7 +30,6 @@ using namespace BALibrary;
SPISettings memSettings(20000000, MSBFIRST, SPI_MODE0);
const int cs0pin = SPI1_CS_PIN;
BAGpio gpio; // access to User LED
BASpiMemoryDMA spiMem1(SpiDeviceId::SPI_DEVICE1);
bool compareBuffers(uint8_t *a, uint8_t *b, size_t numBytes)
@ -62,16 +61,14 @@ void setup() {
//TGA_PRO_REVB(x);
//TGA_PRO_REVA(x);
gpio.begin();
Serial.begin(57600);
while (!Serial) { yield(); }
delay(5);
SPI_MEM1_1M();
SPI_MEM1_64M();
SPI_MAX_ADDR = BAHardwareConfig.getSpiMemMaxAddr(MemSelect::MEM1);
Serial.println("Enabling SPI, testing MEM1");
Serial.printf("Enabling SPI, testing MEM1, max address %08X\n\r", SPI_MAX_ADDR); Serial.flush();
spiMem1.begin();
}
@ -87,7 +84,7 @@ bool spi8BitTest(void) {
uint8_t dest8[DMA_SIZE];
// Write to the memory using 8-bit transfers
Serial.println("\nStarting 8-bit test Write/Read");
Serial.println("\nStarting 8-bit test Write/Read"); Serial.flush();
while (spiPhase < 4) {
spiAddress = 0;
while (spiAddress <= SPI_MAX_ADDR) {
@ -169,7 +166,7 @@ bool spi8BitTest(void) {
}
#endif
Serial.println("\nStarting 8-bit test Zero/Read");
Serial.println("\nStarting 8-bit test Zero/Read"); Serial.flush();
// Clear the memory
spiAddress = 0;
memset(src8, 0, DMA_SIZE);
@ -206,7 +203,7 @@ bool spi16BitTest(void) {
uint16_t dest16[NUM_DATA];
// Write to the memory using 16-bit transfers
Serial.println("\nStarting 16-bit test");
Serial.println("\nStarting 16-bit test"); Serial.flush();
while (spiPhase < 4) {
spiAddress = 0;
while (spiAddress <= SPI_MAX_ADDR) {
@ -287,7 +284,7 @@ bool spi16BitTest(void) {
}
#endif
Serial.println("\nStarting 16-bit test Zero/Read");
Serial.println("\nStarting 16-bit test Zero/Read"); Serial.flush();
// Clear the memory
spiAddress = 0;
memset(src16, 0, DMA_SIZE);

@ -49,7 +49,7 @@ void checkPot(unsigned id)
if (controlPtr->checkPotValue(handle, potValue)) {
// Pot has changed
codecPtr->setHeadphoneVolume(potValue);
Serial.println(String("POT") + id + String(" value: ") + potValue);
if (Serial) { Serial.println(String("POT") + id + String(" value: ") + potValue); }
}
}
@ -72,7 +72,7 @@ void checkSwitch(unsigned id)
}
if (controlPtr->isSwitchToggled(swHandle)) {
Serial.println(String("Button ") + id + String(" pressed"));
if (Serial) { Serial.println(String("Button ") + id + String(" pressed")); }
}
bool pressed = controlPtr->isSwitchHeld(swHandle);

@ -93,7 +93,6 @@ void setup() {
gpio.begin();
Serial.begin(57600);
//while (!Serial) { yield(); }
delay(500);
// Disable the audio codec first
@ -104,12 +103,12 @@ void setup() {
codec.setHeadphoneVolume(0.8f); // Set headphone volume
#if defined(RUN_EXP_TEST)
configPhysicalControls(controls, codec);
Serial.println("Now monitoring for input from Expansion Control Board");
if (Serial) { Serial.println("Now monitoring for input from Expansion Control Board"); }
#endif
// Run the initial Midi connectivity and SPI memory tests.
#if defined(RUN_MIDI_TEST)
if (uartTest()) { Serial.println("MIDI Ports testing PASSED!"); }
if (uartTest()) { if (Serial) Serial.println("MIDI Ports testing PASSED!"); }
#endif
#if defined(RUN_MEMO_TEST)
@ -117,7 +116,7 @@ void setup() {
//SPI_MEM0_4M(); // REVB and REVA came with 4M or 1M
// SPI_MEM0_1M();
spiMem0.begin(); delay(10);
if (spiTest(&spiMem0, 0)) { Serial.println("SPI0 testing PASSED!");}
if (spiTest(&spiMem0, 0)) { if (Serial) Serial.println("SPI0 testing PASSED!");}
#endif
}

@ -19,7 +19,8 @@ bool uartTest(void)
{
Serial1.begin(baudRate, SERIAL_8N1);
delay(100);
while(!Serial) {}
if (!Serial) { return false; } // skip uart test if Serial not connected
Serial.println(String("\nRunning MIDI Port speed test at ") + baudRate);
// write the first data

@ -39,6 +39,7 @@ int calcData(int spiAddress, int loopPhase, int maskPhase)
bool spiTest(BASpiMemory *mem, int id)
{
if (!Serial) { return false; } // Skip test if Serial not connected
int spiAddress = 0;
int spiErrorCount = 0;
@ -47,7 +48,7 @@ bool spiTest(BASpiMemory *mem, int id)
uint16_t memBlock[NUM_BLOCK_WORDS];
uint16_t goldData[NUM_BLOCK_WORDS];
SPI_MAX_ADDR = BAHardwareConfig.getSpiMemMaxAddr(0); // assume for this test both memories are the same size so use MEM0
SPI_MAX_ADDR = BAHardwareConfig.getSpiMemMaxAddr(MemSelect::MEM0); // assume for this test both memories are the same size so use MEM0
const size_t SPI_MEM_SIZE_BYTES = BAHardwareConfig.getSpiMemSizeBytes(id);
Serial.println(String("Starting SPI MEM Test of ") + SPI_MEM_SIZE_BYTES + String(" bytes"));
@ -70,9 +71,14 @@ bool spiTest(BASpiMemory *mem, int id)
if (spiErrorCount >= 10) break;
}
//if (spiErrorCount == 0) { Serial.println(String("SPI MEMORY(") + cnt + String("): Zero test PASSED!")); }
if (spiErrorCount == 0) { Serial.println(String("SPI MEMORY(") + cnt + String("): Zero test PASSED!")); }
if (spiErrorCount == 0) { Serial.print("."); Serial.flush(); }
if (spiErrorCount > 0) { Serial.println(String("SPI MEMORY(") + cnt + String("): Zero test FAILED, error count = ") + spiErrorCount); return false;}
if (spiErrorCount > 0) {
//Serial.println(String("SPI MEMORY(") + cnt + String("): Zero test FAILED, error count = ") + spiErrorCount); return false;
Serial.printf("SPI MEMORY: test %d Zero test FAILED, error count:%d, final address:0x%08X\n\r",
cnt, spiErrorCount, spiAddress);
return false;
}
// Write all test data to the memory

@ -49,10 +49,10 @@ public:
/// returns 0 if success, otherwise error
int push_back(T element) {
//Serial.println(String("RingBuffer::push_back...") + m_head + String(":") + m_tail + String(":") + m_size);
//if (Serial) { Serial.println(String("RingBuffer::push_back...") + m_head + String(":") + m_tail + String(":") + m_size); }
if ( (m_head == m_tail) && (m_size > 0) ) {
// overflow
Serial.println("RingBuffer::push_back: overflow");
if (Serial) { Serial.println("RingBuffer::push_back: overflow"); }
return -1;
}
@ -73,7 +73,7 @@ public:
if (m_size == 0) {
// buffer is empty
//Serial.println("RingBuffer::pop_front: buffer is empty\n");
// if (Serial) { Serial.println("RingBuffer::pop_front: buffer is empty\n"); }
return -1;
}
if (m_tail < m_maxSize-1) {
@ -82,7 +82,7 @@ public:
m_tail = 0;
}
m_size--;
//Serial.println(String("RingBuffer::pop_front: ") + m_head + String(":") + m_tail + String(":") + m_size);
// if (Serial) { Serial.println(String("RingBuffer::pop_front: ") + m_head + String(":") + m_tail + String(":") + m_size); }
return 0;
}
@ -141,10 +141,12 @@ public:
/// DEBUG: Prints the status of the Ringbuffer. NOte using this much printing will usually cause audio glitches
void print() const {
for (int idx=0; idx<m_maxSize; idx++) {
if (Serial) {
Serial.print(idx + String(" address: ")); Serial.print((uint32_t)m_buffer[idx], HEX);
Serial.print(" data: "); Serial.println((uint32_t)m_buffer[idx]->data, HEX);
}
}
}
private:
size_t m_head=0; ///< back of the queue
size_t m_tail=0; ///< front of the queue

@ -58,8 +58,8 @@ class DummyChipSelect : public AbstractChipSelect
**/
class DebugChipSelect : public AbstractChipSelect
{
void select(TransferType transferType = TransferType::NORMAL) override {Serial.println("Debug CS: select()");}
void deselect(TransferType transferType = TransferType::NORMAL) override {Serial.println("Debug CS: deselect()");}
void select(TransferType transferType = TransferType::NORMAL) override { if (Serial) Serial.println("Debug CS: select()");}
void deselect(TransferType transferType = TransferType::NORMAL) override { if (Serial) Serial.println("Debug CS: deselect()");}
};
/** \brief An active low chip select class. This also configures the given pin.
@ -159,7 +159,7 @@ class ActiveLowChipSelect1 : public AbstractChipSelect
#if defined(DEBUG_DMASPI)
#define DMASPI_PRINT(x) do {Serial.printf x ; Serial.flush();} while (0);
#define DMASPI_PRINT(x) do { if (Serial) { Serial.printf x ; Serial.flush();} } while (0);
#else
#define DMASPI_PRINT(x) do {} while (0);
#endif
@ -714,13 +714,15 @@ volatile uint8_t AbstractDmaSpi<DMASPI_INSTANCE, SPICLASS, m_Spi>::m_devNull = 0
// void dump_dma(DMAChannel *dmabc)
// {
// if (Serial) {
// Serial.printf("%x %x:", (uint32_t)dmabc, (uint32_t)dmabc->TCD);
//
// Serial.printf("SA:%x SO:%d AT:%x NB:%x SL:%d DA:%x DO: %d CI:%x DL:%x CS:%x BI:%x\n", (uint32_t)dmabc->TCD->SADDR,
// dmabc->TCD->SOFF, dmabc->TCD->ATTR, dmabc->TCD->NBYTES, dmabc->TCD->SLAST, (uint32_t)dmabc->TCD->DADDR,
// dmabc->TCD->DOFF, dmabc->TCD->CITER, dmabc->TCD->DLASTSGA, dmabc->TCD->CSR, dmabc->TCD->BITER);
// Serial.flush();
// }
// }
#if defined(__IMXRT1062__) // T4.0

@ -76,7 +76,9 @@ audio_block_t* AudioDelay::addBlock(audio_block_t *block)
} else {
// EXTERNAL memory
if (!m_slot) { Serial.println("addBlock(): m_slot is not valid"); }
if (!m_slot) {
if (Serial) { Serial.println("addBlock(): m_slot is not valid"); }
}
if (block) {
@ -128,7 +130,7 @@ bool AudioDelay::getSamples(int16_t *dest, size_t offsetSamples, size_t numSampl
bool AudioDelay::m_getSamples(int16_t *dest, size_t offsetSamples, size_t numSamples)
{
if (!dest) {
Serial.println("getSamples(): dest is invalid");
if (Serial) { Serial.println("getSamples(): dest is invalid"); }
return false;
}
@ -196,8 +198,8 @@ bool AudioDelay::m_getSamples(int16_t *dest, size_t offsetSamples, size_t numSam
return true;
} else {
// numSamples is > than total slot size
Serial.println("getSamples(): ERROR numSamples > total slot size");
Serial.println(numSamples + String(" > ") + m_slot->size());
if (Serial) { Serial.println("getSamples(): ERROR numSamples > total slot size"); }
if (Serial) { Serial.println(numSamples + String(" > ") + m_slot->size()); }
return false;
}
}

@ -332,12 +332,12 @@ bool ExtMemSlot::writeAdvance16(int16_t data)
bool ExtMemSlot::enable() const
{
if (m_spi) {
Serial.println("ExtMemSlot::enable()");
if (Serial) { Serial.println("ExtMemSlot::enable()"); }
m_spi->begin();
return true;
}
else {
Serial.println("ExtMemSlot m_spi is nullptr");
if (Serial) { Serial.println("ExtMemSlot m_spi is nullptr"); }
return false;
}
}
@ -365,11 +365,12 @@ bool ExtMemSlot::isReadBusy() const
void ExtMemSlot::printStatus(void) const
{
Serial.println(String("valid:") + m_valid + String(" m_start:") + m_start + \
if (Serial) { Serial.println(String("valid:") + m_valid + String(" m_start:") + m_start + \
String(" m_end:") + m_end + String(" m_currentWrPosition: ") + m_currentWrPosition + \
String(" m_currentRdPosition: ") + m_currentRdPosition + \
String(" m_size:") + m_size);
}
}
}

@ -134,9 +134,9 @@ T ParameterAutomation<T>::getNextValue()
} else {
returnValue = m_startValue - (m_scaleY*value);
}
// Serial.println(String("Start/End values: ") + m_startValue + String(":") + m_endValue);
//Serial.print("Parameter m_currentValueX is "); Serial.println(m_currentValueX, 6);
//Serial.print("Parameter returnValue is "); Serial.println(returnValue, 6);
// if (Serial) { Serial.println(String("Start/End values: ") + m_startValue + String(":") + m_endValue); }
// if (Serial) { Serial.print("Parameter m_currentValueX is "); Serial.println(m_currentValueX, 6); }
// if (Serial) { Serial.print("Parameter returnValue is "); Serial.println(returnValue, 6); }
return returnValue;
}
@ -175,7 +175,7 @@ ParameterAutomationSequence<T>::~ParameterAutomationSequence()
template <class T>
void ParameterAutomationSequence<T>::setupParameter(int index, T startValue, T endValue, size_t durationSamples, typename ParameterAutomation<T>::Function function)
{
Serial.println(String("setupParameter() called with samples: ") + durationSamples);
if (Serial) { Serial.println(String("setupParameter() called with samples: ") + durationSamples); }
m_paramArray[index]->reconfigure(startValue, endValue, durationSamples, function);
m_currentIndex = 0;
}
@ -183,7 +183,7 @@ void ParameterAutomationSequence<T>::setupParameter(int index, T startValue, T e
template <class T>
void ParameterAutomationSequence<T>::setupParameter(int index, T startValue, T endValue, float durationMilliseconds, typename ParameterAutomation<T>::Function function)
{
Serial.print(String("setupParameter() called with time: ")); Serial.println(durationMilliseconds, 6);
if (Serial) { Serial.print(String("setupParameter() called with time: ")); Serial.println(durationMilliseconds, 6); }
m_paramArray[index]->reconfigure(startValue, endValue, durationMilliseconds, function);
m_currentIndex = 0;
}
@ -194,7 +194,7 @@ void ParameterAutomationSequence<T>::trigger(void)
m_currentIndex = 0;
m_paramArray[0]->trigger();
m_running = true;
//Serial.println("ParameterAutomationSequence<T>::trigger() called");
// if (Serial) { Serial.println("ParameterAutomationSequence<T>::trigger() called"); }
}
template <class T>
@ -204,17 +204,17 @@ T ParameterAutomationSequence<T>::getNextValue()
T nextValue = m_paramArray[m_currentIndex]->getNextValue();
if (m_running) {
//Serial.println(String("ParameterAutomationSequence<T>::getNextValue() is ") + nextValue
// + String(" from stage ") + m_currentIndex);
// if (Serial) { Serial.println(String("ParameterAutomationSequence<T>::getNextValue() is ") + nextValue
// + String(" from stage ") + m_currentIndex); }
// If current stage is done, trigger the next
if (m_paramArray[m_currentIndex]->isFinished()) {
Serial.println(String("Finished stage ") + m_currentIndex);
if (Serial) { Serial.println(String("Finished stage ") + m_currentIndex); }
m_currentIndex++;
if (m_currentIndex >= m_numStages) {
// Last stage already finished
Serial.println("Last stage finished");
if (Serial) { Serial.println("Last stage finished"); }
m_running = false;
m_currentIndex = 0;
} else {

@ -3,6 +3,19 @@
*
* Created on: Jan 7, 2018
* Author: slascos
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <new>
#include "AudioEffectAnalogDelayFilters.h"
@ -166,22 +179,26 @@ void AudioEffectAnalogDelay::delay(float milliseconds)
{
size_t delaySamples = calcAudioSamples(milliseconds);
if (!m_memory) { Serial.println("delay(): m_memory is not valid"); return; }
if (!m_memory) {
if (Serial) { Serial.println("delay(): m_memory is not valid"); return; }
}
if (!m_externalMemory) {
// internal memory
m_maxDelaySamples = m_memory->getMaxDelaySamples();
//QueuePosition queuePosition = calcQueuePosition(milliseconds);
//Serial.println(String("CONFIG: delay:") + delaySamples + String(" queue position ") + queuePosition.index + String(":") + queuePosition.offset);
// if (Serial) { Serial.println(String("CONFIG: delay:") + delaySamples + String(" queue position ") + queuePosition.index + String(":") + queuePosition.offset); }
} else {
// external memory
ExtMemSlot *slot = m_memory->getSlot();
m_maxDelaySamples = (slot->size() / sizeof(int16_t))-AUDIO_BLOCK_SAMPLES;
if (!slot) { Serial.println("ERROR: slot ptr is not valid"); }
if (!slot) {
if (Serial) { Serial.println("ERROR: slot ptr is not valid"); }
}
if (!slot->isEnabled()) {
slot->enable();
Serial.println("WEIRD: slot was not enabled");
if (Serial) { Serial.println("WEIRD: slot was not enabled"); }
}
}
@ -194,16 +211,16 @@ void AudioEffectAnalogDelay::delay(float milliseconds)
void AudioEffectAnalogDelay::delay(size_t delaySamples)
{
if (!m_memory) { Serial.println("delay(): m_memory is not valid"); }
if (!m_memory) { if (Serial) Serial.println("delay(): m_memory is not valid"); }
if (!m_externalMemory) {
// internal memory
m_maxDelaySamples = m_memory->getMaxDelaySamples();
//QueuePosition queuePosition = calcQueuePosition(delaySamples);
//Serial.println(String("CONFIG: delay:") + delaySamples + String(" queue position ") + queuePosition.index + String(":") + queuePosition.offset);
// if (Serial) { Serial.println(String("CONFIG: delay:") + delaySamples + String(" queue position ") + queuePosition.index + String(":") + queuePosition.offset); }
} else {
// external memory
//Serial.println(String("CONFIG: delay:") + delaySamples);
// if (Serial) { Serial.println(String("CONFIG: delay:") + delaySamples); }
ExtMemSlot *slot = m_memory->getSlot();
m_maxDelaySamples = (slot->size() / sizeof(int16_t))-AUDIO_BLOCK_SAMPLES;
if (!slot->isEnabled()) {
@ -222,16 +239,16 @@ void AudioEffectAnalogDelay::delayFractionMax(float delayFraction)
{
size_t delaySamples = static_cast<size_t>(static_cast<float>(m_memory->getMaxDelaySamples()) * delayFraction);
if (!m_memory) { Serial.println("delay(): m_memory is not valid"); }
if (!m_memory) { if (Serial) Serial.println("delay(): m_memory is not valid"); }
if (!m_externalMemory) {
// internal memory
m_maxDelaySamples = m_memory->getMaxDelaySamples();
//QueuePosition queuePosition = calcQueuePosition(delaySamples);
//Serial.println(String("CONFIG: delay:") + delaySamples + String(" queue position ") + queuePosition.index + String(":") + queuePosition.offset);
// if (Serial) { Serial.println(String("CONFIG: delay:") + delaySamples + String(" queue position ") + queuePosition.index + String(":") + queuePosition.offset); }
} else {
// external memory
//Serial.println(String("CONFIG: delay:") + delaySamples);
// if (Serial) { Serial.println(String("CONFIG: delay:") + delaySamples); }
ExtMemSlot *slot = m_memory->getSlot();
m_maxDelaySamples = (slot->size() / sizeof(int16_t))-AUDIO_BLOCK_SAMPLES;
if (!slot->isEnabled()) {
@ -284,23 +301,23 @@ void AudioEffectAnalogDelay::processMidi(int channel, int control, int value)
if (m_externalMemory) { m_maxDelaySamples = (m_memory->getSlot()->size() / sizeof(int16_t))-AUDIO_BLOCK_SAMPLES; }
size_t delayVal = (size_t)(val * (float)(m_maxDelaySamples));
delay(delayVal);
Serial.println(String("AudioEffectAnalogDelay::delay (ms): ") + calcAudioTimeMs(delayVal)
+ String(" (samples): ") + delayVal + String(" out of ") + m_maxDelaySamples);
if (Serial) { Serial.println(String("AudioEffectAnalogDelay::delay (ms): ") + calcAudioTimeMs(delayVal)
+ String(" (samples): ") + delayVal + String(" out of ") + m_maxDelaySamples); }
return;
}
if ((m_midiConfig[BYPASS][MIDI_CHANNEL] == channel) &&
(m_midiConfig[BYPASS][MIDI_CONTROL] == control)) {
// Bypass
if (value >= 65) { bypass(false); Serial.println(String("AudioEffectAnalogDelay::not bypassed -> ON") + value); }
else { bypass(true); Serial.println(String("AudioEffectAnalogDelay::bypassed -> OFF") + value); }
if (value >= 65) { bypass(false); if (Serial) Serial.println(String("AudioEffectAnalogDelay::not bypassed -> ON") + value); }
else { bypass(true); if (Serial) Serial.println(String("AudioEffectAnalogDelay::bypassed -> OFF") + value); }
return;
}
if ((m_midiConfig[FEEDBACK][MIDI_CHANNEL] == channel) &&
(m_midiConfig[FEEDBACK][MIDI_CONTROL] == control)) {
// Feedback
Serial.println(String("AudioEffectAnalogDelay::feedback: ") + 100*val + String("%"));
if (Serial) { Serial.println(String("AudioEffectAnalogDelay::feedback: ") + 100*val + String("%")); }
feedback(val);
return;
}
@ -308,7 +325,7 @@ void AudioEffectAnalogDelay::processMidi(int channel, int control, int value)
if ((m_midiConfig[MIX][MIDI_CHANNEL] == channel) &&
(m_midiConfig[MIX][MIDI_CONTROL] == control)) {
// Mix
Serial.println(String("AudioEffectAnalogDelay::mix: Dry: ") + 100*(1-val) + String("% Wet: ") + 100*val );
if (Serial) { Serial.println(String("AudioEffectAnalogDelay::mix: Dry: ") + 100*(1-val) + String("% Wet: ") + 100*val ); }
mix(val);
return;
}
@ -316,7 +333,7 @@ void AudioEffectAnalogDelay::processMidi(int channel, int control, int value)
if ((m_midiConfig[VOLUME][MIDI_CHANNEL] == channel) &&
(m_midiConfig[VOLUME][MIDI_CONTROL] == control)) {
// Volume
Serial.println(String("AudioEffectAnalogDelay::volume: ") + 100*val + String("%"));
if (Serial) { Serial.println(String("AudioEffectAnalogDelay::volume: ") + 100*val + String("%")); }
volume(val);
return;
}

@ -67,7 +67,7 @@ void BAAudioEffectDelayExternal::delay(uint8_t channel, float milliseconds) {
unsigned mask = m_activeMask;
if (m_activeMask == 0) m_startUsingSPI(m_spiChannel);
m_activeMask = mask | (1<<channel);
Serial.print("DelayLengthInt: "); Serial.println(m_requestedDelayLength);
if (Serial) { Serial.print("DelayLengthInt: "); Serial.println(m_requestedDelayLength); }
}
void BAAudioEffectDelayExternal::disable(uint8_t channel) {

@ -3,6 +3,19 @@
*
* Created on: March 7, 2020
* Author: slascos
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <arm_math.h>
#include "BALibrary.h"
@ -64,8 +77,7 @@ void AudioEffectRmsMeasure::update(void)
for (int i=0; i<AUDIO_BLOCK_SAMPLES; i++) {
dotProduct += ((int64_t)inputAudioBlock->data[i] * (int64_t)inputAudioBlock->data[i]);
if (dotProduct < 0) {
Serial.println("DOT ERROR!");
Serial.println(inputAudioBlock->data[i], HEX);
if (Serial) { Serial.println("DOT ERROR!"); Serial.println(inputAudioBlock->data[i], HEX); }
}
}
m_sum += (int64_t)(dotProduct);
@ -80,11 +92,13 @@ void AudioEffectRmsMeasure::update(void)
// dbfs = 20*log10(abs(rmsFigure)/32768.0f);
m_dbfs = 20.0f * log10(m_rms/32768.0f);
if (Serial) {
Serial.print("Accumulator: "); Serial.println((int)(m_sum >> 32), HEX);
Serial.print("RAW RMS: "); Serial.println(m_rms);
Serial.print("AudioEffectRmsMeasure: the RMS figure is "); Serial.print(m_dbfs);
Serial.print(" dBFS over "); Serial.print(m_accumulatorCount); Serial.println(" audio blocks");
}
m_sum = 0;
m_accumulatorCount = 0;

@ -3,6 +3,19 @@
*
* Created on: Apr 14, 2018
* Author: blackaddr
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "AudioEffectSOS.h"
@ -63,7 +76,7 @@ void AudioEffectSOS::enable(void)
// Because we hold the previous output buffer for an update cycle, the maximum delay is actually
// 1 audio block mess then the max delay returnable from the memory.
m_maxDelaySamples = m_memory->getMaxDelaySamples() - AUDIO_BLOCK_SAMPLES;
Serial.println(String("SOS Enabled with delay length ") + m_maxDelaySamples + String(" samples"));
if (Serial) { Serial.println(String("SOS Enabled with delay length ") + m_maxDelaySamples + String(" samples")); }
}
m_delaySamples = m_maxDelaySamples;
m_inputGateAuto.setupParameter(GATE_OPEN_STAGE, 0.0f, 1.0f, 1000.0f, ParameterAutomation<float>::Function::EXPONENTIAL);
@ -126,8 +139,8 @@ void AudioEffectSOS::update(void)
// get the data. If using external memory with DMA, this won't be filled until
// later.
m_memory->getSamples(blockToOutput, m_delaySamples);
//Serial.println(String("Delay samples:") + m_delaySamples);
//Serial.println(String("Use dma: ") + m_memory->getSlot()->isUseDma());
// if (Serial) { Serial.println(String("Delay samples:") + m_delaySamples); }
// if (Serial) { Serial.println(String("Use dma: ") + m_memory->getSlot()->isUseDma()); }
// If using DMA, we need something else to do while that read executes, so
// move on to input preprocessing
@ -157,7 +170,7 @@ void AudioEffectSOS::update(void)
m_previousBlock = blockToOutput;
if (m_blockToRelease == m_previousBlock) {
Serial.println("ERROR: POINTER COLLISION");
if (Serial) { Serial.println("ERROR: POINTER COLLISION"); }
}
if (m_blockToRelease) { release(m_blockToRelease); }
@ -190,7 +203,7 @@ void AudioEffectSOS::processMidi(int channel, int control, int value)
(m_midiConfig[GATE_OPEN_TIME][MIDI_CONTROL] == control)) {
// Gate Open Time
gateOpenTime(val * MAX_GATE_OPEN_TIME_MS);
Serial.println(String("AudioEffectSOS::gate open time (ms): ") + m_openTimeMs);
if (Serial) { Serial.println(String("AudioEffectSOS::gate open time (ms): ") + m_openTimeMs); }
return;
}
@ -198,14 +211,14 @@ void AudioEffectSOS::processMidi(int channel, int control, int value)
(m_midiConfig[GATE_CLOSE_TIME][MIDI_CONTROL] == control)) {
// Gate Close Time
gateCloseTime(val * MAX_GATE_CLOSE_TIME_MS);
Serial.println(String("AudioEffectSOS::gate close time (ms): ") + m_closeTimeMs);
if (Serial) { Serial.println(String("AudioEffectSOS::gate close time (ms): ") + m_closeTimeMs); }
return;
}
if ((m_midiConfig[FEEDBACK][MIDI_CHANNEL] == channel) &&
(m_midiConfig[FEEDBACK][MIDI_CONTROL] == control)) {
// Feedback
Serial.println(String("AudioEffectSOS::feedback: ") + 100*val + String("%"));
if (Serial) { Serial.println(String("AudioEffectSOS::feedback: ") + 100*val + String("%")); }
feedback(val);
return;
}
@ -213,7 +226,7 @@ void AudioEffectSOS::processMidi(int channel, int control, int value)
if ((m_midiConfig[VOLUME][MIDI_CHANNEL] == channel) &&
(m_midiConfig[VOLUME][MIDI_CONTROL] == control)) {
// Volume
Serial.println(String("AudioEffectSOS::volume: ") + 100*val + String("%"));
if (Serial) { Serial.println(String("AudioEffectSOS::volume: ") + 100*val + String("%")); }
volume(val);
return;
}
@ -221,15 +234,15 @@ void AudioEffectSOS::processMidi(int channel, int control, int value)
if ((m_midiConfig[BYPASS][MIDI_CHANNEL] == channel) &&
(m_midiConfig[BYPASS][MIDI_CONTROL] == control)) {
// Bypass
if (value >= 65) { bypass(false); Serial.println(String("AudioEffectSOS::not bypassed -> ON") + value); }
else { bypass(true); Serial.println(String("AudioEffectSOS::bypassed -> OFF") + value); }
if (value >= 65) { bypass(false); if (Serial) Serial.println(String("AudioEffectSOS::not bypassed -> ON") + value); }
else { bypass(true); if (Serial) Serial.println(String("AudioEffectSOS::bypassed -> OFF") + value); }
return;
}
if ((m_midiConfig[GATE_TRIGGER][MIDI_CHANNEL] == channel) &&
(m_midiConfig[GATE_TRIGGER][MIDI_CONTROL] == control)) {
// The gate is triggered by any value
Serial.println(String("AudioEffectSOS::Gate Triggered!"));
if (Serial) { Serial.println(String("AudioEffectSOS::Gate Triggered!")); }
m_inputGateAuto.trigger();
return;
}
@ -237,7 +250,7 @@ void AudioEffectSOS::processMidi(int channel, int control, int value)
if ((m_midiConfig[CLEAR_FEEDBACK_TRIGGER][MIDI_CHANNEL] == channel) &&
(m_midiConfig[CLEAR_FEEDBACK_TRIGGER][MIDI_CONTROL] == control)) {
// The gate is triggered by any value
Serial.println(String("AudioEffectSOS::Clear feedback Triggered!"));
if (Serial) { Serial.println(String("AudioEffectSOS::Clear feedback Triggered!")); }
m_clearFeedbackAuto.trigger();
return;
}

@ -3,7 +3,21 @@
*
* Created on: Jan 7, 2018
* Author: slascos
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <cmath> // std::roundf
#include "AudioEffectTremolo.h"
@ -62,16 +76,6 @@ void AudioEffectTremolo::update(void)
float sample = std::roundf(mod[i] * (float)inputAudioBlock->data[i]);
inputAudioBlock->data[i] = (int16_t)sample;
}
//Serial.println(String("mod: ") + mod[0]);
//float mod = (m_osc.getNext()+1.0f)/2.0f; // value between -1.0 and +1.0f
//float modVolume = (1.0f - m_depth) + mod*m_depth; // value between 0 to depth
//float finalVolume = m_volume * modVolume;
// Set the output volume
//gainAdjust(inputAudioBlock, inputAudioBlock, finalVolume, 1);
transmit(inputAudioBlock);
release(inputAudioBlock);
@ -97,8 +101,8 @@ void AudioEffectTremolo::processMidi(int channel, int control, int value)
if ((m_midiConfig[BYPASS][MIDI_CHANNEL] == channel) &&
(m_midiConfig[BYPASS][MIDI_CONTROL] == control)) {
// Bypass
if (value >= 65) { bypass(false); Serial.println(String("AudioEffectTremolo::not bypassed -> ON") + value); }
else { bypass(true); Serial.println(String("AudioEffectTremolo::bypassed -> OFF") + value); }
if (value >= 65) { bypass(false); if (Serial) Serial.println(String("AudioEffectTremolo::not bypassed -> ON") + value); }
else { bypass(true); if (Serial) Serial.println(String("AudioEffectTremolo::bypassed -> OFF") + value); }
return;
}
@ -106,7 +110,7 @@ void AudioEffectTremolo::processMidi(int channel, int control, int value)
(m_midiConfig[RATE][MIDI_CONTROL] == control)) {
// Rate
rate(val);
Serial.println(String("AudioEffectTremolo::rate: ") + m_rate);
if (Serial) { Serial.println(String("AudioEffectTremolo::rate: ") + m_rate); }
return;
}
@ -114,7 +118,7 @@ void AudioEffectTremolo::processMidi(int channel, int control, int value)
(m_midiConfig[DEPTH][MIDI_CONTROL] == control)) {
// Depth
depth(val);
Serial.println(String("AudioEffectTremolo::depth: ") + m_depth);
if (Serial) { Serial.println(String("AudioEffectTremolo::depth: ") + m_depth); }
return;
}
@ -133,14 +137,14 @@ void AudioEffectTremolo::processMidi(int channel, int control, int value)
m_waveform = Waveform::RANDOM;
}
Serial.println(String("AudioEffectTremolo::waveform: ") + static_cast<unsigned>(m_waveform));
if (Serial) { Serial.println(String("AudioEffectTremolo::waveform: ") + static_cast<unsigned>(m_waveform)); }
return;
}
if ((m_midiConfig[VOLUME][MIDI_CHANNEL] == channel) &&
(m_midiConfig[VOLUME][MIDI_CONTROL] == control)) {
// Volume
Serial.println(String("AudioEffectTremolo::volume: ") + 100*val + String("%"));
if (Serial) { Serial.println(String("AudioEffectTremolo::volume: ") + 100*val + String("%")); }
volume(val);
return;
}

@ -136,7 +136,7 @@ BAAudioControlWM8731::~BAAudioControlWM8731()
// Powerdown and disable the codec
void BAAudioControlWM8731::disable(void)
{
//Serial.println("Disabling codec");
// if (Serial) { Serial.println("Disabling codec"); }
if (m_wireStarted == false) {
Wire.begin();
m_wireStarted = true;
@ -161,7 +161,7 @@ void BAAudioControlWM8731::enable(void)
disable(); // disable first in case it was already powered up
//Serial.println("Enabling codec");
// if (Serial) { Serial.println("Enabling codec"); }
if (m_wireStarted == false) {
Wire.begin();
m_wireStarted = true;
@ -398,10 +398,9 @@ bool BAAudioControlWM8731::write(unsigned int reg, unsigned int val)
Wire.write(val & 0xFF);
byte error = Wire.endTransmission();
if (error) {
Serial.println(String("Wire::Error: ") + error + String(" retrying..."));
if (Serial) { Serial.println(String("Wire::Error: ") + error + String(" retrying...")); }
} else {
done = true;
//Serial.println("Wire::SUCCESS!");
}
}
@ -427,7 +426,7 @@ void BAAudioControlWM8731master::enable(void)
disable(); // disable first in case it was already powered up
//Serial.println("Enabling codec");
// if (Serial) { Serial.println("Enabling codec"); }
if (m_wireStarted == false) {
Wire.begin();
m_wireStarted = true;

@ -22,11 +22,11 @@
// These calls must be define in order to get vector to work on arduino
namespace std {
void __throw_bad_alloc() {
Serial.println("Unable to allocate memory");
if (Serial) { Serial.println("Unable to allocate memory"); }
abort();
}
void __throw_length_error( char const*e ) {
Serial.print("Length Error :"); Serial.println(e);
if (Serial) { Serial.print("Length Error :"); Serial.println(e); }
abort();
}
}
@ -337,6 +337,8 @@ void Potentiometer::setChangeThreshold(float changeThreshold)
Potentiometer::Calib Potentiometer::calibrate(uint8_t pin) {
Calib calib;
if (!Serial) { return; } // this function REQUIRES Serial port connection
// Flush the serial port input buffer
while (Serial.available() > 0) {}

@ -24,20 +24,6 @@
namespace BALibrary {
//// MEM0 Settings
//int SPI_CS_MEM0 = SPI0_CS_PIN;
//int SPI_MOSI_MEM0 = SPI0_MOSI_PIN;
//int SPI_MISO_MEM0 = SPI0_MISO_PIN;
//int SPI_SCK_MEM0 = SPI0_SCK_PIN;
//
//#if defined(SPI1_AVAILABLE)
//// MEM1 Settings
//int SPI_CS_MEM1 = SPI1_CS_PIN;
//int SPI_MOSI_MEM1 = SPI1_MOSI_PIN;
//int SPI_MISO_MEM1 = SPI1_MISO_PIN;
//int SPI_SCK_MEM1 = SPI1_SCK_PIN;
//#endif
// SPI Constants
constexpr int SPI_WRITE_MODE_REG = 0x1;
constexpr int SPI_WRITE_CMD = 0x2;

@ -1,3 +1,22 @@
/*
* DmaSpi.cpp
*
* Created on: Jan 7, 2018
* Author: slascos
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "DmaSpi.h"
#if defined(__IMXRT1062__) // T4.X

Loading…
Cancel
Save