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. 16
      src/DmaSpi.h
  16. 10
      src/common/AudioDelay.cpp
  17. 7
      src/common/ExtMemSlot.cpp
  18. 20
      src/common/ParameterAutomation.cpp
  19. 53
      src/effects/AudioEffectAnalogDelay.cpp
  20. 2
      src/effects/AudioEffectDelayExternal.cpp
  21. 20
      src/effects/AudioEffectRmsMeasure.cpp
  22. 39
      src/effects/AudioEffectSOS.cpp
  23. 38
      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) { void OnControlChange(byte channel, byte control, byte value) {
analogDelay.processMidi(channel-1, control, value); analogDelay.processMidi(channel-1, control, value);
#ifdef MIDI_DEBUG #ifdef MIDI_DEBUG
if (Serial) {
Serial.print("Control Change, ch="); Serial.print("Control Change, ch=");
Serial.print(channel, DEC); Serial.print(channel, DEC);
Serial.print(", control="); Serial.print(", control=");
@ -83,6 +84,7 @@ void OnControlChange(byte channel, byte control, byte value) {
Serial.print(", value="); Serial.print(", value=");
Serial.print(value, DEC); Serial.print(value, DEC);
Serial.println(); Serial.println();
}
#endif #endif
} }
@ -107,19 +109,19 @@ void setup() {
delay(5); delay(5);
// Enable the codec // Enable the codec
Serial.println("Enabling codec...\n"); if (Serial) { Serial.println("Enabling codec...\n"); }
codec.enable(); codec.enable();
delay(100); delay(100);
// If using external memory request request memory from the manager // If using external memory request request memory from the manager
// for the slot // for the slot
#ifdef USE_EXT #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. // We have to request memory be allocated to our slot.
externalSram.requestMemory(&delaySlot, 500.0f, MemSelect::MEM0, true); externalSram.requestMemory(&delaySlot, 500.0f, MemSelect::MEM0, true);
delaySlot.clear(); delaySlot.clear();
#else #else
Serial.println("Using INTERNAL memory"); if (Serial) { Serial.println("Using INTERNAL memory"); }
#endif #endif
// Setup MIDI // Setup MIDI
@ -166,11 +168,13 @@ void loop() {
if (timer > 1000) { if (timer > 1000) {
timer = 0; timer = 0;
if (Serial) {
Serial.print("Processor Usage, Total: "); Serial.print(AudioProcessorUsage()); Serial.print("Processor Usage, Total: "); Serial.print(AudioProcessorUsage());
Serial.print("% "); Serial.print("% ");
Serial.print(" analogDelay: "); Serial.print(analogDelay.processorUsage()); Serial.print(" analogDelay: "); Serial.print(analogDelay.processorUsage());
Serial.println("%"); Serial.println("%");
} }
}
MIDI.read(); MIDI.read();
usbMIDI.read(); usbMIDI.read();

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

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

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

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

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

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

@ -72,7 +72,7 @@ void setup() {
SPI_MEM0_1M(); SPI_MEM0_1M();
SPI_MAX_ADDR = BAHardwareConfig.getSpiMemMaxAddr(MemSelect::MEM0); 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(); spiMem0.begin();
} }

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

@ -49,7 +49,7 @@ void checkPot(unsigned id)
if (controlPtr->checkPotValue(handle, potValue)) { if (controlPtr->checkPotValue(handle, potValue)) {
// Pot has changed // Pot has changed
codecPtr->setHeadphoneVolume(potValue); 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)) { 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); bool pressed = controlPtr->isSwitchHeld(swHandle);

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

@ -19,7 +19,8 @@ bool uartTest(void)
{ {
Serial1.begin(baudRate, SERIAL_8N1); Serial1.begin(baudRate, SERIAL_8N1);
delay(100); 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); Serial.println(String("\nRunning MIDI Port speed test at ") + baudRate);
// write the first data // write the first data

@ -39,6 +39,7 @@ int calcData(int spiAddress, int loopPhase, int maskPhase)
bool spiTest(BASpiMemory *mem, int id) bool spiTest(BASpiMemory *mem, int id)
{ {
if (!Serial) { return false; } // Skip test if Serial not connected
int spiAddress = 0; int spiAddress = 0;
int spiErrorCount = 0; int spiErrorCount = 0;
@ -47,7 +48,7 @@ bool spiTest(BASpiMemory *mem, int id)
uint16_t memBlock[NUM_BLOCK_WORDS]; uint16_t memBlock[NUM_BLOCK_WORDS];
uint16_t goldData[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); const size_t SPI_MEM_SIZE_BYTES = BAHardwareConfig.getSpiMemSizeBytes(id);
Serial.println(String("Starting SPI MEM Test of ") + SPI_MEM_SIZE_BYTES + String(" bytes")); 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 >= 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.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 // Write all test data to the memory

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

@ -58,8 +58,8 @@ class DummyChipSelect : public AbstractChipSelect
**/ **/
class DebugChipSelect : public AbstractChipSelect class DebugChipSelect : public AbstractChipSelect
{ {
void select(TransferType transferType = TransferType::NORMAL) override {Serial.println("Debug CS: select()");} void select(TransferType transferType = TransferType::NORMAL) override { if (Serial) Serial.println("Debug CS: select()");}
void deselect(TransferType transferType = TransferType::NORMAL) override {Serial.println("Debug CS: deselect()");} 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. /** \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) #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 #else
#define DMASPI_PRINT(x) do {} while (0); #define DMASPI_PRINT(x) do {} while (0);
#endif #endif
@ -712,15 +712,17 @@ typename AbstractDmaSpi<DMASPI_INSTANCE, SPICLASS, m_Spi>::Transfer* volatile Ab
template<typename DMASPI_INSTANCE, typename SPICLASS, SPICLASS& m_Spi> template<typename DMASPI_INSTANCE, typename SPICLASS, SPICLASS& m_Spi>
volatile uint8_t AbstractDmaSpi<DMASPI_INSTANCE, SPICLASS, m_Spi>::m_devNull = 0; volatile uint8_t AbstractDmaSpi<DMASPI_INSTANCE, SPICLASS, m_Spi>::m_devNull = 0;
//void dump_dma(DMAChannel *dmabc) // void dump_dma(DMAChannel *dmabc)
//{ // {
// if (Serial) {
// Serial.printf("%x %x:", (uint32_t)dmabc, (uint32_t)dmabc->TCD); // 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, // 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->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); // dmabc->TCD->DOFF, dmabc->TCD->CITER, dmabc->TCD->DLASTSGA, dmabc->TCD->CSR, dmabc->TCD->BITER);
// Serial.flush(); // Serial.flush();
//} // }
// }
#if defined(__IMXRT1062__) // T4.0 #if defined(__IMXRT1062__) // T4.0

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

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

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

@ -3,7 +3,20 @@
* *
* Created on: Jan 7, 2018 * Created on: Jan 7, 2018
* Author: slascos * 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 <new>
#include "AudioEffectAnalogDelayFilters.h" #include "AudioEffectAnalogDelayFilters.h"
#include "AudioEffectAnalogDelay.h" #include "AudioEffectAnalogDelay.h"
@ -166,22 +179,26 @@ void AudioEffectAnalogDelay::delay(float milliseconds)
{ {
size_t delaySamples = calcAudioSamples(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) { if (!m_externalMemory) {
// internal memory // internal memory
m_maxDelaySamples = m_memory->getMaxDelaySamples(); m_maxDelaySamples = m_memory->getMaxDelaySamples();
//QueuePosition queuePosition = calcQueuePosition(milliseconds); //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 { } else {
// external memory // external memory
ExtMemSlot *slot = m_memory->getSlot(); ExtMemSlot *slot = m_memory->getSlot();
m_maxDelaySamples = (slot->size() / sizeof(int16_t))-AUDIO_BLOCK_SAMPLES; 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()) { if (!slot->isEnabled()) {
slot->enable(); 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) 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) { if (!m_externalMemory) {
// internal memory // internal memory
m_maxDelaySamples = m_memory->getMaxDelaySamples(); m_maxDelaySamples = m_memory->getMaxDelaySamples();
//QueuePosition queuePosition = calcQueuePosition(delaySamples); //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 { } else {
// external memory // external memory
//Serial.println(String("CONFIG: delay:") + delaySamples); // if (Serial) { Serial.println(String("CONFIG: delay:") + delaySamples); }
ExtMemSlot *slot = m_memory->getSlot(); ExtMemSlot *slot = m_memory->getSlot();
m_maxDelaySamples = (slot->size() / sizeof(int16_t))-AUDIO_BLOCK_SAMPLES; m_maxDelaySamples = (slot->size() / sizeof(int16_t))-AUDIO_BLOCK_SAMPLES;
if (!slot->isEnabled()) { 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); 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) { if (!m_externalMemory) {
// internal memory // internal memory
m_maxDelaySamples = m_memory->getMaxDelaySamples(); m_maxDelaySamples = m_memory->getMaxDelaySamples();
//QueuePosition queuePosition = calcQueuePosition(delaySamples); //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 { } else {
// external memory // external memory
//Serial.println(String("CONFIG: delay:") + delaySamples); // if (Serial) { Serial.println(String("CONFIG: delay:") + delaySamples); }
ExtMemSlot *slot = m_memory->getSlot(); ExtMemSlot *slot = m_memory->getSlot();
m_maxDelaySamples = (slot->size() / sizeof(int16_t))-AUDIO_BLOCK_SAMPLES; m_maxDelaySamples = (slot->size() / sizeof(int16_t))-AUDIO_BLOCK_SAMPLES;
if (!slot->isEnabled()) { 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; } if (m_externalMemory) { m_maxDelaySamples = (m_memory->getSlot()->size() / sizeof(int16_t))-AUDIO_BLOCK_SAMPLES; }
size_t delayVal = (size_t)(val * (float)(m_maxDelaySamples)); size_t delayVal = (size_t)(val * (float)(m_maxDelaySamples));
delay(delayVal); delay(delayVal);
Serial.println(String("AudioEffectAnalogDelay::delay (ms): ") + calcAudioTimeMs(delayVal) if (Serial) { Serial.println(String("AudioEffectAnalogDelay::delay (ms): ") + calcAudioTimeMs(delayVal)
+ String(" (samples): ") + delayVal + String(" out of ") + m_maxDelaySamples); + String(" (samples): ") + delayVal + String(" out of ") + m_maxDelaySamples); }
return; return;
} }
if ((m_midiConfig[BYPASS][MIDI_CHANNEL] == channel) && if ((m_midiConfig[BYPASS][MIDI_CHANNEL] == channel) &&
(m_midiConfig[BYPASS][MIDI_CONTROL] == control)) { (m_midiConfig[BYPASS][MIDI_CONTROL] == control)) {
// Bypass // Bypass
if (value >= 65) { bypass(false); Serial.println(String("AudioEffectAnalogDelay::not bypassed -> ON") + value); } if (value >= 65) { bypass(false); if (Serial) Serial.println(String("AudioEffectAnalogDelay::not bypassed -> ON") + value); }
else { bypass(true); Serial.println(String("AudioEffectAnalogDelay::bypassed -> OFF") + value); } else { bypass(true); if (Serial) Serial.println(String("AudioEffectAnalogDelay::bypassed -> OFF") + value); }
return; return;
} }
if ((m_midiConfig[FEEDBACK][MIDI_CHANNEL] == channel) && if ((m_midiConfig[FEEDBACK][MIDI_CHANNEL] == channel) &&
(m_midiConfig[FEEDBACK][MIDI_CONTROL] == control)) { (m_midiConfig[FEEDBACK][MIDI_CONTROL] == control)) {
// Feedback // Feedback
Serial.println(String("AudioEffectAnalogDelay::feedback: ") + 100*val + String("%")); if (Serial) { Serial.println(String("AudioEffectAnalogDelay::feedback: ") + 100*val + String("%")); }
feedback(val); feedback(val);
return; return;
} }
@ -308,7 +325,7 @@ void AudioEffectAnalogDelay::processMidi(int channel, int control, int value)
if ((m_midiConfig[MIX][MIDI_CHANNEL] == channel) && if ((m_midiConfig[MIX][MIDI_CHANNEL] == channel) &&
(m_midiConfig[MIX][MIDI_CONTROL] == control)) { (m_midiConfig[MIX][MIDI_CONTROL] == control)) {
// Mix // 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); mix(val);
return; return;
} }
@ -316,7 +333,7 @@ void AudioEffectAnalogDelay::processMidi(int channel, int control, int value)
if ((m_midiConfig[VOLUME][MIDI_CHANNEL] == channel) && if ((m_midiConfig[VOLUME][MIDI_CHANNEL] == channel) &&
(m_midiConfig[VOLUME][MIDI_CONTROL] == control)) { (m_midiConfig[VOLUME][MIDI_CONTROL] == control)) {
// Volume // Volume
Serial.println(String("AudioEffectAnalogDelay::volume: ") + 100*val + String("%")); if (Serial) { Serial.println(String("AudioEffectAnalogDelay::volume: ") + 100*val + String("%")); }
volume(val); volume(val);
return; return;
} }

@ -67,7 +67,7 @@ void BAAudioEffectDelayExternal::delay(uint8_t channel, float milliseconds) {
unsigned mask = m_activeMask; unsigned mask = m_activeMask;
if (m_activeMask == 0) m_startUsingSPI(m_spiChannel); if (m_activeMask == 0) m_startUsingSPI(m_spiChannel);
m_activeMask = mask | (1<<channel); 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) { void BAAudioEffectDelayExternal::disable(uint8_t channel) {

@ -3,7 +3,20 @@
* *
* Created on: March 7, 2020 * Created on: March 7, 2020
* Author: slascos * 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 <arm_math.h>
#include "BALibrary.h" #include "BALibrary.h"
#include "AudioEffectRmsMeasure.h" #include "AudioEffectRmsMeasure.h"
@ -64,8 +77,7 @@ void AudioEffectRmsMeasure::update(void)
for (int i=0; i<AUDIO_BLOCK_SAMPLES; i++) { for (int i=0; i<AUDIO_BLOCK_SAMPLES; i++) {
dotProduct += ((int64_t)inputAudioBlock->data[i] * (int64_t)inputAudioBlock->data[i]); dotProduct += ((int64_t)inputAudioBlock->data[i] * (int64_t)inputAudioBlock->data[i]);
if (dotProduct < 0) { if (dotProduct < 0) {
Serial.println("DOT ERROR!"); if (Serial) { Serial.println("DOT ERROR!"); Serial.println(inputAudioBlock->data[i], HEX); }
Serial.println(inputAudioBlock->data[i], HEX);
} }
} }
m_sum += (int64_t)(dotProduct); m_sum += (int64_t)(dotProduct);
@ -80,11 +92,13 @@ void AudioEffectRmsMeasure::update(void)
// dbfs = 20*log10(abs(rmsFigure)/32768.0f); // dbfs = 20*log10(abs(rmsFigure)/32768.0f);
m_dbfs = 20.0f * log10(m_rms/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("Accumulator: "); Serial.println((int)(m_sum >> 32), HEX);
Serial.print("RAW RMS: "); Serial.println(m_rms); Serial.print("RAW RMS: "); Serial.println(m_rms);
Serial.print("AudioEffectRmsMeasure: the RMS figure is "); Serial.print(m_dbfs); Serial.print("AudioEffectRmsMeasure: the RMS figure is "); Serial.print(m_dbfs);
Serial.print(" dBFS over "); Serial.print(m_accumulatorCount); Serial.println(" audio blocks"); Serial.print(" dBFS over "); Serial.print(m_accumulatorCount); Serial.println(" audio blocks");
}
m_sum = 0; m_sum = 0;
m_accumulatorCount = 0; m_accumulatorCount = 0;

@ -3,7 +3,20 @@
* *
* Created on: Apr 14, 2018 * Created on: Apr 14, 2018
* Author: blackaddr * 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" #include "AudioEffectSOS.h"
#include "LibBasicFunctions.h" #include "LibBasicFunctions.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 // 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. // 1 audio block mess then the max delay returnable from the memory.
m_maxDelaySamples = m_memory->getMaxDelaySamples() - AUDIO_BLOCK_SAMPLES; 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_delaySamples = m_maxDelaySamples;
m_inputGateAuto.setupParameter(GATE_OPEN_STAGE, 0.0f, 1.0f, 1000.0f, ParameterAutomation<float>::Function::EXPONENTIAL); 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 // get the data. If using external memory with DMA, this won't be filled until
// later. // later.
m_memory->getSamples(blockToOutput, m_delaySamples); m_memory->getSamples(blockToOutput, m_delaySamples);
//Serial.println(String("Delay samples:") + m_delaySamples); // if (Serial) { Serial.println(String("Delay samples:") + m_delaySamples); }
//Serial.println(String("Use dma: ") + m_memory->getSlot()->isUseDma()); // 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 // If using DMA, we need something else to do while that read executes, so
// move on to input preprocessing // move on to input preprocessing
@ -157,7 +170,7 @@ void AudioEffectSOS::update(void)
m_previousBlock = blockToOutput; m_previousBlock = blockToOutput;
if (m_blockToRelease == m_previousBlock) { if (m_blockToRelease == m_previousBlock) {
Serial.println("ERROR: POINTER COLLISION"); if (Serial) { Serial.println("ERROR: POINTER COLLISION"); }
} }
if (m_blockToRelease) { release(m_blockToRelease); } 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)) { (m_midiConfig[GATE_OPEN_TIME][MIDI_CONTROL] == control)) {
// Gate Open Time // Gate Open Time
gateOpenTime(val * MAX_GATE_OPEN_TIME_MS); 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; return;
} }
@ -198,14 +211,14 @@ void AudioEffectSOS::processMidi(int channel, int control, int value)
(m_midiConfig[GATE_CLOSE_TIME][MIDI_CONTROL] == control)) { (m_midiConfig[GATE_CLOSE_TIME][MIDI_CONTROL] == control)) {
// Gate Close Time // Gate Close Time
gateCloseTime(val * MAX_GATE_CLOSE_TIME_MS); 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; return;
} }
if ((m_midiConfig[FEEDBACK][MIDI_CHANNEL] == channel) && if ((m_midiConfig[FEEDBACK][MIDI_CHANNEL] == channel) &&
(m_midiConfig[FEEDBACK][MIDI_CONTROL] == control)) { (m_midiConfig[FEEDBACK][MIDI_CONTROL] == control)) {
// Feedback // Feedback
Serial.println(String("AudioEffectSOS::feedback: ") + 100*val + String("%")); if (Serial) { Serial.println(String("AudioEffectSOS::feedback: ") + 100*val + String("%")); }
feedback(val); feedback(val);
return; return;
} }
@ -213,7 +226,7 @@ void AudioEffectSOS::processMidi(int channel, int control, int value)
if ((m_midiConfig[VOLUME][MIDI_CHANNEL] == channel) && if ((m_midiConfig[VOLUME][MIDI_CHANNEL] == channel) &&
(m_midiConfig[VOLUME][MIDI_CONTROL] == control)) { (m_midiConfig[VOLUME][MIDI_CONTROL] == control)) {
// Volume // Volume
Serial.println(String("AudioEffectSOS::volume: ") + 100*val + String("%")); if (Serial) { Serial.println(String("AudioEffectSOS::volume: ") + 100*val + String("%")); }
volume(val); volume(val);
return; return;
} }
@ -221,15 +234,15 @@ void AudioEffectSOS::processMidi(int channel, int control, int value)
if ((m_midiConfig[BYPASS][MIDI_CHANNEL] == channel) && if ((m_midiConfig[BYPASS][MIDI_CHANNEL] == channel) &&
(m_midiConfig[BYPASS][MIDI_CONTROL] == control)) { (m_midiConfig[BYPASS][MIDI_CONTROL] == control)) {
// Bypass // Bypass
if (value >= 65) { bypass(false); Serial.println(String("AudioEffectSOS::not bypassed -> ON") + value); } if (value >= 65) { bypass(false); if (Serial) Serial.println(String("AudioEffectSOS::not bypassed -> ON") + value); }
else { bypass(true); Serial.println(String("AudioEffectSOS::bypassed -> OFF") + value); } else { bypass(true); if (Serial) Serial.println(String("AudioEffectSOS::bypassed -> OFF") + value); }
return; return;
} }
if ((m_midiConfig[GATE_TRIGGER][MIDI_CHANNEL] == channel) && if ((m_midiConfig[GATE_TRIGGER][MIDI_CHANNEL] == channel) &&
(m_midiConfig[GATE_TRIGGER][MIDI_CONTROL] == control)) { (m_midiConfig[GATE_TRIGGER][MIDI_CONTROL] == control)) {
// The gate is triggered by any value // The gate is triggered by any value
Serial.println(String("AudioEffectSOS::Gate Triggered!")); if (Serial) { Serial.println(String("AudioEffectSOS::Gate Triggered!")); }
m_inputGateAuto.trigger(); m_inputGateAuto.trigger();
return; return;
} }
@ -237,7 +250,7 @@ void AudioEffectSOS::processMidi(int channel, int control, int value)
if ((m_midiConfig[CLEAR_FEEDBACK_TRIGGER][MIDI_CHANNEL] == channel) && if ((m_midiConfig[CLEAR_FEEDBACK_TRIGGER][MIDI_CHANNEL] == channel) &&
(m_midiConfig[CLEAR_FEEDBACK_TRIGGER][MIDI_CONTROL] == control)) { (m_midiConfig[CLEAR_FEEDBACK_TRIGGER][MIDI_CONTROL] == control)) {
// The gate is triggered by any value // 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(); m_clearFeedbackAuto.trigger();
return; return;
} }

@ -3,7 +3,21 @@
* *
* Created on: Jan 7, 2018 * Created on: Jan 7, 2018
* Author: slascos * 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 <cmath> // std::roundf
#include "AudioEffectTremolo.h" #include "AudioEffectTremolo.h"
@ -62,16 +76,6 @@ void AudioEffectTremolo::update(void)
float sample = std::roundf(mod[i] * (float)inputAudioBlock->data[i]); float sample = std::roundf(mod[i] * (float)inputAudioBlock->data[i]);
inputAudioBlock->data[i] = (int16_t)sample; 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); transmit(inputAudioBlock);
release(inputAudioBlock); release(inputAudioBlock);
@ -97,8 +101,8 @@ void AudioEffectTremolo::processMidi(int channel, int control, int value)
if ((m_midiConfig[BYPASS][MIDI_CHANNEL] == channel) && if ((m_midiConfig[BYPASS][MIDI_CHANNEL] == channel) &&
(m_midiConfig[BYPASS][MIDI_CONTROL] == control)) { (m_midiConfig[BYPASS][MIDI_CONTROL] == control)) {
// Bypass // Bypass
if (value >= 65) { bypass(false); Serial.println(String("AudioEffectTremolo::not bypassed -> ON") + value); } if (value >= 65) { bypass(false); if (Serial) Serial.println(String("AudioEffectTremolo::not bypassed -> ON") + value); }
else { bypass(true); Serial.println(String("AudioEffectTremolo::bypassed -> OFF") + value); } else { bypass(true); if (Serial) Serial.println(String("AudioEffectTremolo::bypassed -> OFF") + value); }
return; return;
} }
@ -106,7 +110,7 @@ void AudioEffectTremolo::processMidi(int channel, int control, int value)
(m_midiConfig[RATE][MIDI_CONTROL] == control)) { (m_midiConfig[RATE][MIDI_CONTROL] == control)) {
// Rate // Rate
rate(val); rate(val);
Serial.println(String("AudioEffectTremolo::rate: ") + m_rate); if (Serial) { Serial.println(String("AudioEffectTremolo::rate: ") + m_rate); }
return; return;
} }
@ -114,7 +118,7 @@ void AudioEffectTremolo::processMidi(int channel, int control, int value)
(m_midiConfig[DEPTH][MIDI_CONTROL] == control)) { (m_midiConfig[DEPTH][MIDI_CONTROL] == control)) {
// Depth // Depth
depth(val); depth(val);
Serial.println(String("AudioEffectTremolo::depth: ") + m_depth); if (Serial) { Serial.println(String("AudioEffectTremolo::depth: ") + m_depth); }
return; return;
} }
@ -133,14 +137,14 @@ void AudioEffectTremolo::processMidi(int channel, int control, int value)
m_waveform = Waveform::RANDOM; 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; return;
} }
if ((m_midiConfig[VOLUME][MIDI_CHANNEL] == channel) && if ((m_midiConfig[VOLUME][MIDI_CHANNEL] == channel) &&
(m_midiConfig[VOLUME][MIDI_CONTROL] == control)) { (m_midiConfig[VOLUME][MIDI_CONTROL] == control)) {
// Volume // Volume
Serial.println(String("AudioEffectTremolo::volume: ") + 100*val + String("%")); if (Serial) { Serial.println(String("AudioEffectTremolo::volume: ") + 100*val + String("%")); }
volume(val); volume(val);
return; return;
} }

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

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

@ -24,20 +24,6 @@
namespace BALibrary { 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 // SPI Constants
constexpr int SPI_WRITE_MODE_REG = 0x1; constexpr int SPI_WRITE_MODE_REG = 0x1;
constexpr int SPI_WRITE_CMD = 0x2; 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" #include "DmaSpi.h"
#if defined(__IMXRT1062__) // T4.X #if defined(__IMXRT1062__) // T4.X

Loading…
Cancel
Save