diff --git a/examples/Delay/AnalogDelayDemo/AnalogDelayDemo.ino b/examples/Delay/AnalogDelayDemo/AnalogDelayDemo.ino index 72b9dbc..f339351 100644 --- a/examples/Delay/AnalogDelayDemo/AnalogDelayDemo.ino +++ b/examples/Delay/AnalogDelayDemo/AnalogDelayDemo.ino @@ -15,11 +15,14 @@ * Even if you don't control the guitar effect with USB MIDI, you must set * the Arduino IDE USB-Type under Tools to "Serial + MIDI" */ - #include +#include +#include #include "BALibrary.h" #include "BAEffects.h" using namespace midi; +MIDI_CREATE_DEFAULT_INSTANCE(); + using namespace BAEffects; using namespace BALibrary; @@ -31,7 +34,7 @@ BAAudioControlWM8731 codec; // YOU MUST USE TEENSYDUINO 1.41 or greater // YOU MUST COMPILE THIS DEMO USING Serial + Midi -#define USE_CAB_FILTER // uncomment this line to add a simple low-pass filter to simulate a cabinet if you are going straight to headphones +//#define USE_CAB_FILTER // uncomment this line to add a simple low-pass filter to simulate a cabinet if you are going straight to headphones //#define USE_EXT // uncomment this line to use External MEM0 #define MIDI_DEBUG // uncomment to see raw MIDI info in terminal @@ -70,6 +73,19 @@ AudioConnection rightOut(analogDelay,0, i2sOut, 1); elapsedMillis timer; +void OnControlChange(byte channel, byte control, byte value) { + analogDelay.processMidi(channel-1, control, value); + #ifdef MIDI_DEBUG + Serial.print("Control Change, ch="); + Serial.print(channel, DEC); + Serial.print(", control="); + Serial.print(control, DEC); + Serial.print(", value="); + Serial.print(value, DEC); + Serial.println(); + #endif +} + void setup() { TGA_PRO_MKII_REV1(); // Declare the version of the TGA Pro you are using. //TGA_PRO_REVB(x); @@ -104,6 +120,12 @@ void setup() { Serial.println("Using INTERNAL memory"); #endif + // Setup MIDI + MIDI.begin(MIDI_CHANNEL_OMNI); + MIDI.setHandleControlChange(OnControlChange); + + usbMIDI.setHandleControlChange(OnControlChange); + // Configure which MIDI CC's will control the effect parameters analogDelay.mapMidiControl(AudioEffectAnalogDelay::BYPASS,16); analogDelay.mapMidiControl(AudioEffectAnalogDelay::DELAY,20); @@ -137,23 +159,8 @@ void setup() { #endif } -void OnControlChange(byte channel, byte control, byte value) { - analogDelay.processMidi(channel, control, value); - #ifdef MIDI_DEBUG - Serial.print("Control Change, ch="); - Serial.print(channel, DEC); - Serial.print(", control="); - Serial.print(control, DEC); - Serial.print(", value="); - Serial.print(value, DEC); - Serial.println(); - #endif -} - void loop() { - // usbMIDI.read() needs to be called rapidly from loop(). When - // each MIDI messages arrives, it return true. The message must - // be fully processed before usbMIDI.read() is called again. + // usbMIDI.read() needs to be called rapidly from loop(). if (timer > 1000) { timer = 0; @@ -163,23 +170,7 @@ void loop() { Serial.println("%"); } - - // check for new MIDI from USB - if (usbMIDI.read()) { - // this code entered only if new MIDI received - byte type, channel, data1, data2, cable; - type = usbMIDI.getType(); // which MIDI message, 128-255 - channel = usbMIDI.getChannel(); // which MIDI channel, 1-16 - data1 = usbMIDI.getData1(); // first data byte of message, 0-127 - data2 = usbMIDI.getData2(); // second data byte of message, 0-127 - Serial.println(String("Received a MIDI message on channel ") + channel); - - if (type == MidiType::ControlChange) { - // if type is 3, it's a CC MIDI Message - // Note: the Arduino MIDI library encodes channels as 1-16 instead - // of 0 to 15 as it should, so we must subtract one. - OnControlChange(channel-1, data1, data2); - } - } + MIDI.read(); + usbMIDI.read(); } diff --git a/examples/Delay/ExternalDelayDemo/ExternalDelayDemo.ino b/examples/Delay/ExternalDelayDemo/ExternalDelayDemo.ino index 1d4ef97..093fb78 100644 --- a/examples/Delay/ExternalDelayDemo/ExternalDelayDemo.ino +++ b/examples/Delay/ExternalDelayDemo/ExternalDelayDemo.ino @@ -49,17 +49,21 @@ AudioConnection outputRight(delayMixer, 0, i2sOut, 1); void setup() { + TGA_PRO_MKII_REV1(); // Declare the version of the TGA Pro you are using. + //TGA_PRO_REVB(x); + //TGA_PRO_REVA(x); + + SPI_MEM0_4M(); + //SPI_MEM0_1M(); // use this line instead of you have the older 1Mbit memory + Serial.begin(57600); - while(!Serial) { yield(); } + delay(200); AudioMemory(64); delay(500); Serial.println(String("Starting...\n")); delay(100); - SPI_MEM0_1M(); // set the SPI MEM0 memory size - // SPI_MEM1_1M(); // set the MEM1 memory aize - Serial.println("Enabling codec...\n"); codecControl.enable(); delay(100); diff --git a/examples/Delay/SoundOnSoundDemo/SoundOnSoundDemo.ino b/examples/Delay/SoundOnSoundDemo/SoundOnSoundDemo.ino index 820642d..851a116 100644 --- a/examples/Delay/SoundOnSoundDemo/SoundOnSoundDemo.ino +++ b/examples/Delay/SoundOnSoundDemo/SoundOnSoundDemo.ino @@ -11,32 +11,29 @@ * the BAMidiTester to control the effect but it's best to use external MIDI footswitch * or the Blackaddr Audio Expansion Control Board. * - * Use must set the Arduino IDE USB-Type to "Serial + MIDI" in the Tools menu. + * User must set the Arduino IDE USB-Type to "Serial + MIDI" in the Tools menu. + * + * Afters startup, the effect will spend about 5 seconds clearing the audio delay buffer to prevent + * any startup pops or clicks from propagating. * */ -#include #include #include -#include + #include "BALibrary.h" #include "BAEffects.h" -#include -static const unsigned sUsbTransportBufferSize = 16; -typedef midi::UsbTransport UsbTransport; - -UsbTransport sUsbTransport; - -MIDI_CREATE_INSTANCE(UsbTransport, sUsbTransport, uMIDI); +/// IMPORTANT ///// +// YOU MUST USE TEENSYDUINO 1.41 or greater +// YOU MUST COMPILE THIS DEMO USING Serial + Midi +//#define USE_CAB_FILTER // uncomment this line to add a simple low-pass filter to simulate a cabinet if you are going straight to headphones +#define MIDI_DEBUG -MIDI_CREATE_DEFAULT_INSTANCE(); using namespace midi; +MIDI_CREATE_DEFAULT_INSTANCE(); using namespace BAEffects; - -#define MIDI_DEBUG - using namespace BALibrary; AudioInputI2S i2sIn; @@ -54,9 +51,12 @@ AudioEffectSOS sos(&delaySlot); AudioEffectDelay delayModule; // we'll add a little slapback echo AudioMixer4 gainModule; // This will be used simply to reduce the gain before the reverb AudioEffectReverb reverb; // Add a bit of 'verb to our tone -AudioFilterBiquad cabFilter; // We'll want something to cut out the highs and smooth the tone, just like a guitar cab. AudioMixer4 mixer; +#if defined(USE_CAB_FILTER) +AudioFilterBiquad cabFilter; // We'll want something to cut out the highs and smooth the tone, just like a guitar cab. +#endif + // Connect the input AudioConnection inputToSos(i2sIn, 0, sos, 0); AudioConnection inputToSolo(i2sIn, 0, delayModule, 0); @@ -69,13 +69,17 @@ AudioConnection inputToReverb(gainModule, 0, reverb, 0); AudioConnection mixer0input(i2sIn, 0, mixer, 0); // SOLO Dry Channel AudioConnection mixer1input(reverb, 0, mixer, 1); // SOLO Wet Channel AudioConnection mixer2input(sos, 0, mixer, 2); // SOS Channel -AudioConnection inputToCab(mixer, 0, cabFilter, 0); -// CODEC Outputs +#if defined(USE_CAB_FILTER) +AudioConnection inputToCab(mixer, 0, cabFilter, 0); AudioConnection outputLeft(cabFilter, 0, i2sOut, 0); AudioConnection outputRight(cabFilter, 0, i2sOut, 1); +#else +AudioConnection outputLeft(mixer, 0, i2sOut, 0); +AudioConnection outputRight(mixer, 0, i2sOut, 1); +#endif -int loopCount = 0; +elapsedMillis timer; void OnControlChange(byte channel, byte control, byte value) { sos.processMidi(channel-1, control, value); @@ -92,7 +96,14 @@ void OnControlChange(byte channel, byte control, byte value) { void setup() { -delay(100); + TGA_PRO_MKII_REV1(); // Declare the version of the TGA Pro you are using. + //TGA_PRO_REVB(x); + //TGA_PRO_REVA(x); + + SPI_MEM0_4M(); + //SPI_MEM0_1M(); // use this line instead of you have the older 1Mbit memory + + delay(100); Serial.begin(57600); // Start the serial port // Disable the codec first @@ -115,20 +126,20 @@ delay(100); // Setup MIDI MIDI.begin(MIDI_CHANNEL_OMNI); MIDI.setHandleControlChange(OnControlChange); - uMIDI.begin(MIDI_CHANNEL_OMNI); - uMIDI.setHandleControlChange(OnControlChange); + + usbMIDI.setHandleControlChange(OnControlChange); // Configure the LED to indicate the gate status sos.setGateLedGpio(USR_LED_ID); // Configure which MIDI CC's will control the effect parameters - sos.mapMidiControl(AudioEffectSOS::BYPASS,16); - sos.mapMidiControl(AudioEffectSOS::CLEAR_FEEDBACK_TRIGGER,22); - sos.mapMidiControl(AudioEffectSOS::GATE_TRIGGER,23); + //sos.mapMidiControl(AudioEffectSOS::BYPASS,16); + sos.mapMidiControl(AudioEffectSOS::GATE_TRIGGER,16); + sos.mapMidiControl(AudioEffectSOS::CLEAR_FEEDBACK_TRIGGER,17); sos.mapMidiControl(AudioEffectSOS::GATE_OPEN_TIME,20); sos.mapMidiControl(AudioEffectSOS::GATE_CLOSE_TIME,21); - sos.mapMidiControl(AudioEffectSOS::FEEDBACK,24); - sos.mapMidiControl(AudioEffectSOS::VOLUME,17); + sos.mapMidiControl(AudioEffectSOS::VOLUME,22); + //sos.mapMidiControl(AudioEffectSOS::FEEDBACK,24); // Besure to enable the delay. When disabled, audio is is completely blocked // to minimize resources to nearly zero. @@ -146,51 +157,34 @@ delay(100); gainModule.gain(0, 0.25); // the reverb unit clips easily if the input is too high delayModule.delay(0, 50.0f); // 50 ms slapback delay +#if defined(USE_CAB_FILTER) // Setup 2-stages of LPF, cutoff 4500 Hz, Q-factor 0.7071 (a 'normal' Q-factor) cabFilter.setLowpass(0, 4500, .7071); cabFilter.setLowpass(1, 4500, .7071); +#endif // Setup the Mixer mixer.gain(0, 0.5f); // SOLO Dry gain mixer.gain(1, 0.5f); // SOLO Wet gain mixer.gain(1, 1.0f); // SOS gain + + delay(1000); + sos.clear(); } - - void loop() { - // usbMIDI.read() needs to be called rapidly from loop(). When - // each MIDI messages arrives, it return true. The message must - // be fully processed before usbMIDI.read() is called again. + // usbMIDI.read() needs to be called rapidly from loop(). - if (loopCount % 524288 == 0) { + if (timer > 1000) { + timer = 0; Serial.print("Processor Usage, Total: "); Serial.print(AudioProcessorUsage()); Serial.print("% "); - Serial.print(" sos: "); Serial.print(sos.processorUsage()); + Serial.print(" SOS: "); Serial.print(sos.processorUsage()); Serial.println("%"); } - loopCount++; MIDI.read(); - uMIDI.read(); - -// // check for new MIDI from USB -// if (usbMIDI.read()) { -// // this code entered only if new MIDI received -// byte type, channel, data1, data2, cable; -// type = usbMIDI.getType(); // which MIDI message, 128-255 -// channel = usbMIDI.getChannel(); // which MIDI channel, 1-16 -// data1 = usbMIDI.getData1(); // first data byte of message, 0-127 -// data2 = usbMIDI.getData2(); // second data byte of message, 0-127 -// Serial.println(String("Received a MIDI message on channel ") + channel); -// -// if (type == MidiType::ControlChange) { -// // if type is 3, it's a CC MIDI Message -// // Note: the Arduino MIDI library encodes channels as 1-16 instead -// // of 0 to 15 as it should, so we must subtract one. -// OnControlChange(channel-1, data1, data2); -// } -// } + usbMIDI.read(); } diff --git a/examples/Delay/SoundOnSoundExpansionDemo/SoundOnSoundExpansionDemo.ino b/examples/Delay/SoundOnSoundExpansionDemo/SoundOnSoundExpansionDemo.ino index 85c26e6..3ae018f 100644 --- a/examples/Delay/SoundOnSoundExpansionDemo/SoundOnSoundExpansionDemo.ino +++ b/examples/Delay/SoundOnSoundExpansionDemo/SoundOnSoundExpansionDemo.ino @@ -13,6 +13,9 @@ * * The pots control the feedback, as well as the gate opening and close times. * + * Afters startup, the effect will spend about 5 seconds clearing the audio delay buffer to prevent + * any startup pops or clicks from propagating. + * * POT1 - Gate open time. Middle position (detent) is about 2100 ms. * POT2 - gate close time. Middle position (detent) is about 2100 ms. * POT3 - Effect volume. Controls the volume of the SOS effect separate from the normal volume @@ -20,12 +23,15 @@ * SW2 - Push this button to clear out the sound circulating in the delay. * */ +#include #include "BALibrary.h" #include "BAEffects.h" using namespace BAEffects; using namespace BALibrary; +//#define USE_CAB_FILTER // uncomment this line to add a simple low-pass filter to simulate a cabinet if you are going straight to headphones + AudioInputI2S i2sIn; AudioOutputI2S i2sOut; BAAudioControlWM8731 codec; @@ -41,9 +47,12 @@ AudioEffectSOS sos(&delaySlot); AudioEffectDelay delayModule; // we'll add a little slapback echo AudioMixer4 gainModule; // This will be used simply to reduce the gain before the reverb AudioEffectReverb reverb; // Add a bit of 'verb to our tone -AudioFilterBiquad cabFilter; // We'll want something to cut out the highs and smooth the tone, just like a guitar cab. AudioMixer4 mixer; +#if defined(USE_CAB_FILTER) +AudioFilterBiquad cabFilter; // We'll want something to cut out the highs and smooth the tone, just like a guitar cab. +#endif + // Connect the input AudioConnection inputToSos(i2sIn, 0, sos, 0); AudioConnection inputToSolo(i2sIn, 0, delayModule, 0); @@ -56,11 +65,15 @@ AudioConnection inputToReverb(gainModule, 0, reverb, 0); AudioConnection mixer0input(i2sIn, 0, mixer, 0); // SOLO Dry Channel AudioConnection mixer1input(reverb, 0, mixer, 1); // SOLO Wet Channel AudioConnection mixer2input(sos, 0, mixer, 2); // SOS Channel -AudioConnection inputToCab(mixer, 0, cabFilter, 0); -// CODEC Outputs +#if defined(USE_CAB_FILTER) +AudioConnection inputToCab(mixer, 0, cabFilter, 0); AudioConnection outputLeft(cabFilter, 0, i2sOut, 0); AudioConnection outputRight(cabFilter, 0, i2sOut, 1); +#else +AudioConnection outputLeft(mixer, 0, i2sOut, 0); +AudioConnection outputRight(mixer, 0, i2sOut, 1); +#endif ////////////////////////////////////////// // SETUP PHYSICAL CONTROLS @@ -82,7 +95,7 @@ constexpr bool potSwapDirection = true; // Blackaddr Audio Expansion Board. BAPhysicalControls controls(BA_EXPAND_NUM_SW, BA_EXPAND_NUM_POT, BA_EXPAND_NUM_ENC, BA_EXPAND_NUM_LED); -int loopCount = 0; +elapsedMillis timer; constexpr unsigned MAX_HEADPHONE_VOL = 10; unsigned headphoneVolume = MAX_HEADPHONE_VOL; // control headphone volume from 0 to 10. constexpr float MAX_GATE_TIME_MS = 4000.0f; // set maximum gate time of 4 seconds. @@ -93,11 +106,17 @@ int gateHandle, clearHandle, openHandle, closeHandle, volumeHandle, led1Handle, void setup() { -delay(100); + TGA_PRO_MKII_REV1(); // Declare the version of the TGA Pro you are using. + //TGA_PRO_REVB(x); + //TGA_PRO_REVA(x); + + SPI_MEM0_4M(); + //SPI_MEM0_1M(); // use this line instead of you have the older 1Mbit memory + + 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 - BAHardwareConfig.set(MemSelect::MEM0, SPI_MEMORY_1M); // Setup the controls. The return value is the handle to use when checking for control changes, etc. // pushbuttons @@ -115,9 +134,6 @@ delay(100); codec.disable(); AudioMemory(128); - TGA_PRO_EXPAND_REV2(); // Set the expansion board revision - SPI_MEM0_1M(); // set the Spi memory size - // Enable the codec Serial.println("Enabling codec...\n"); codec.enable(); @@ -130,7 +146,7 @@ delay(100); // by BAPhysicalControls sos.setGateLedGpio(BA_EXPAND_LED1_PIN); - // Besure to enable the delay. When disabled, audio is is completely blocked + // Besure to enable the SOS. When disabled, audio is is completely blocked // to minimize resources to nearly zero. sos.enable(); @@ -146,19 +162,22 @@ delay(100); gainModule.gain(0, 0.25); // the reverb unit clips easily if the input is too high delayModule.delay(0, 50.0f); // 50 ms slapback delay +#if defined(USE_CAB_FILTER) // Setup 2-stages of LPF, cutoff 4500 Hz, Q-factor 0.7071 (a 'normal' Q-factor) cabFilter.setLowpass(0, 4500, .7071); cabFilter.setLowpass(1, 4500, .7071); +#endif // Setup the Mixer mixer.gain(0, 0.5f); // SOLO Dry gain mixer.gain(1, 0.5f); // SOLO Wet gain mixer.gain(1, 1.0f); // SOS gain + + delay(1000); + sos.clear(); } - - void loop() { float potValue; @@ -215,12 +234,14 @@ void loop() { } } } - if (loopCount % 524288 == 0) { + + delay(20); // Without some minimal delay here it will be difficult for the pots/switch changes to be detected. + + if (timer > 1000) { + timer = 0; Serial.print("Processor Usage, Total: "); Serial.print(AudioProcessorUsage()); Serial.print("% "); - Serial.print(" sos: "); Serial.print(sos.processorUsage()); + Serial.print(" SOS: "); Serial.print(sos.processorUsage()); Serial.println("%"); } - loopCount++; - } diff --git a/examples/Modulation/TemoloDemo/TemoloDemo.ino b/examples/Modulation/TemoloDemo/TemoloDemo.ino index 0188002..a9f4097 100644 --- a/examples/Modulation/TemoloDemo/TemoloDemo.ino +++ b/examples/Modulation/TemoloDemo/TemoloDemo.ino @@ -20,6 +20,8 @@ #include "BAEffects.h" using namespace midi; +MIDI_CREATE_DEFAULT_INSTANCE(); + using namespace BAEffects; using namespace BALibrary; @@ -52,6 +54,19 @@ AudioConnection rightOut(tremolo,0, i2sOut, 1); elapsedMillis timer; +void OnControlChange(byte channel, byte control, byte value) { + tremolo.processMidi(channel-1, control, value); + #ifdef MIDI_DEBUG + Serial.print("Control Change, ch="); + Serial.print(channel, DEC); + Serial.print(", control="); + Serial.print(control, DEC); + Serial.print(", value="); + Serial.print(value, DEC); + Serial.println(); + #endif +} + void setup() { TGA_PRO_MKII_REV1(); // Declare the version of the TGA Pro you are using. @@ -72,6 +87,11 @@ void setup() { codec.enable(); delay(100); + // Setup MIDI + MIDI.begin(MIDI_CHANNEL_OMNI); + MIDI.setHandleControlChange(OnControlChange); + usbMIDI.setHandleControlChange(OnControlChange); + // Configure which MIDI CC's will control the effect parameters tremolo.mapMidiControl(AudioEffectTremolo::BYPASS,16); tremolo.mapMidiControl(AudioEffectTremolo::RATE,20); @@ -96,23 +116,8 @@ void setup() { #endif } -void OnControlChange(byte channel, byte control, byte value) { - tremolo.processMidi(channel, control, value); - #ifdef MIDI_DEBUG - Serial.print("Control Change, ch="); - Serial.print(channel, DEC); - Serial.print(", control="); - Serial.print(control, DEC); - Serial.print(", value="); - Serial.print(value, DEC); - Serial.println(); - #endif -} - void loop() { - // usbMIDI.read() needs to be called rapidly from loop(). When - // each MIDI messages arrives, it return true. The message must - // be fully processed before usbMIDI.read() is called again. + // usbMIDI.read() needs to be called rapidly from loop(). if (timer > 1000) { timer = 0; @@ -122,22 +127,7 @@ void loop() { Serial.println("%"); } - // check for new MIDI from USB - if (usbMIDI.read()) { - // this code entered only if new MIDI received - byte type, channel, data1, data2, cable; - type = usbMIDI.getType(); // which MIDI message, 128-255 - channel = usbMIDI.getChannel(); // which MIDI channel, 1-16 - data1 = usbMIDI.getData1(); // first data byte of message, 0-127 - data2 = usbMIDI.getData2(); // second data byte of message, 0-127 - Serial.println(String("Received a MIDI message on channel ") + channel); - - if (type == MidiType::ControlChange) { - // if type is 3, it's a CC MIDI Message - // Note: the Arduino MIDI library encodes channels as 1-16 instead - // of 0 to 15 as it should, so we must subtract one. - OnControlChange(channel-1, data1, data2); - } - } + MIDI.read(); + usbMIDI.read(); } diff --git a/src/BAHardware.h b/src/BAHardware.h index babdf9a..befe8da 100644 --- a/src/BAHardware.h +++ b/src/BAHardware.h @@ -20,8 +20,8 @@ * along with this program. If not, see . *****************************************************************************/ -#ifndef __BALIBRARY_BAHARDWARE_H -#define __BALIBRARY_BAHARDWARE_H +#ifndef BALIBRARY_BAHARDWARE_H_ +#define BALIBRARY_BAHARDWARE_H_ #include #include @@ -32,20 +32,6 @@ *****************************************************************************/ namespace BALibrary { -// In your Arudino .ino file, use #defines for your TGA Pro revision and options -// to correctly configure your hardware -#define TGA_PRO_REVA(x) BALibrary::BAHardwareConfig.m_tgaBoard = TgaBoard::REV_A ///< Macro for specifying REV A of the TGA Pro -#define TGA_PRO_REVB(x) BALibrary::BAHardwareConfig.m_tgaBoard = TgaBoard::REV_B ///< Macro for specifying REV B of the TGA Pro -#define TGA_PRO_MKII_REV1(x) BALibrary::BAHardwareConfig.m_tgaBoard = TgaBoard::MKII_REV1 ///< Macro for specifying REV B of the TGA Pro - -#define TGA_PRO_EXPAND_REV2(x) BALibrary::BAHardwareConfig.m_expansionBoard = ExpansionBoard::REV_2 ///< Macro for specifying REV 2 of the Expansion Board -#define TGA_PRO_EXPAND_REV3(x) BALibrary::BAHardwareConfig.m_expansionBoard = ExpansionBoard::REV_3 ///< Macro for specifying REV 2 of the Expansion Board - -#define SPI_MEM0_1M(x) BALibrary::BAHardwareConfig.m_spiMem0 = SPI_MEMORY_1M ///< Macro for specifying MEM0 is 1Mbit -#define SPI_MEM0_4M(x) BALibrary::BAHardwareConfig.m_spiMem0 = SPI_MEMORY_4M ///< Macro for specifying MEM1 is 4Mbit -#define SPI_MEM1_1M(x) BALibrary::BAHardwareConfig.m_spiMem1 = SPI_MEMORY_1M ///< Macro for specifying MEM0 is 1Mbit -#define SPI_MEM1_4M(x) BALibrary::BAHardwareConfig.m_spiMem1 = SPI_MEMORY_4M ///< Macro for specifying MEM1 is 1Mbit - /****************************************************************************** * Hardware Configuration *****************************************************************************/ @@ -53,7 +39,14 @@ namespace BALibrary { enum class TgaBoard : unsigned { REV_A = 0, ///< indicates using REV A of the TGA Pro REV_B, ///< indicates using REV B of the TGA Pro - MKII_REV1 ///< indicates using MKII, Rev 1 of the TGA Pro + MKII_REV1, ///< indicates using MKII, Rev 1 of the TGA Pro + AVALON +}; + +/// enum to specify the TGA Board revision +enum class TeensyProcessor : unsigned { + TEENSY3 = 0, ///< indicates using REV A of the TGA Pro + TEENSY4, ///< indicates using REV B of the TGA Pro }; /// enum to specify the TGA Pro Expansion Board revision @@ -72,6 +65,7 @@ enum class SpiMemorySize : unsigned { }; constexpr unsigned NUM_MEM_SLOTS = 2; ///< The TGA Pro has two SPI ports for memory + /// enum to specify MEM0 or MEM1 enum MemSelect : unsigned { MEM0 = 0, ///< SPI RAM MEM0 @@ -114,6 +108,22 @@ enum class SpiDeviceId : unsigned { SPI_DEVICE1 = 1 ///< Arduino SPI1 device }; +// GPIOs and Testpoints are accessed via enumerated class constants. +enum class GPIO { + GPIO0 = 0, + GPIO1 = 1, + GPIO2 = 2, + GPIO3 = 3, + + GPIO4 = 4, + GPIO5 = 5, + GPIO6 = 6, + GPIO7 = 7, + + TP1 = 8, + TP2 = 9 +}; + /**************************************************************************//** * BAHardware is a global object that holds hardware configuration options for * board revisions and ordering options. It is created automatically, and only @@ -122,7 +132,7 @@ enum class SpiDeviceId : unsigned { *****************************************************************************/ class BAHardware { public: - BAHardware() = default; ///< default constructor + BAHardware(); ///< default constructor /// sets the TGA Pro board revision /// @param tgaBoard enum to specify board revision @@ -132,6 +142,10 @@ public: /// @returns enum for the board revision TgaBoard getTgaBoard(void); + /// get the configured Teensy Processor + /// @returns enum for the processor + TeensyProcessor getTeensyProcessor(); + /// sets the Expansion board revision /// @param expansionBoard enum to specify the expansion board revision void set(ExpansionBoard expansionBoard); @@ -169,80 +183,75 @@ public: /// @returns the last valid address location in the memory size_t getSpiMemMaxAddr (unsigned memIndex); - TgaBoard m_tgaBoard = TgaBoard::REV_B; ///< stores the configured TGA Pro revision - ExpansionBoard m_expansionBoard = ExpansionBoard::NO_EXPANSION; ///< stores the configured Expansion Board revision - SpiMemoryDefinition m_spiMem0 = SPI_MEMORY_NONE; ///< stores the definition for MEM0 - SpiMemoryDefinition m_spiMem1 = SPI_MEMORY_NONE; ///< stores the definition for MEM1 + TgaBoard m_tgaBoard = TgaBoard::MKII_REV1; ///< stores the configured TGA Pro revision + TeensyProcessor m_teensyProcessor = TeensyProcessor::TEENSY4; ///< store the processor in use + ExpansionBoard m_expansionBoard = ExpansionBoard::NO_EXPANSION; ///< stores the configured Expansion Board revision + SpiMemoryDefinition m_spiMem0 = SPI_MEMORY_NONE; ///< stores the definition for MEM0 + SpiMemoryDefinition m_spiMem1 = SPI_MEMORY_NONE; ///< stores the definition for MEM1 }; extern BAHardware BAHardwareConfig; ///< external definition of global configuration class object -/**************************************************************************//** - * Teensy 3.6/3.5 Hardware Pinout - *****************************************************************************/ -#if defined(__MK66FX1M0__) || defined(__MK64FX512__) // T3.6 or T3.5 -constexpr uint8_t USR_LED_ID = 16; ///< Teensy IO number for the user LED. +// In your Arudino .ino file, use #defines for your TGA Pro revision and options +// to correctly configure your hardware +#define TGA_PRO_REVA(x) BALibrary::BAHardwareConfig.set(TgaBoard::REV_A) ///< Macro for specifying REV A of the TGA Pro +#define TGA_PRO_REVB(x) BALibrary::BAHardwareConfig.set(TgaBoard::REV_B) ///< Macro for specifying REV B of the TGA Pro +#define TGA_PRO_MKII_REV1(x) BALibrary::BAHardwareConfig.set(TgaBoard::MKII_REV1) ///< Macro for specifying REV B of the TGA Pro + +#define TGA_PRO_EXPAND_REV2(x) BALibrary::BAHardwareConfig.setExpansionBoard(ExpansionBoard::REV_2) ///< Macro for specifying REV 2 of the Expansion Board +#define TGA_PRO_EXPAND_REV3(x) BALibrary::BAHardwareConfig.setExpansionBoard(ExpansionBoard::REV_3) ///< Macro for specifying REV 2 of the Expansion Board + +#define SPI_MEM0_1M(x) BALibrary::BAHardwareConfig.set(MEM0, SPI_MEMORY_1M) ///< Macro for specifying MEM0 is 1Mbit +#define SPI_MEM0_4M(x) BALibrary::BAHardwareConfig.set(MEM0, SPI_MEMORY_4M) ///< Macro for specifying MEM1 is 4Mbit +#define SPI_MEM1_1M(x) BALibrary::BAHardwareConfig.set(MEM1, SPI_MEMORY_1M) ///< Macro for specifying MEM0 is 1Mbit +#define SPI_MEM1_4M(x) BALibrary::BAHardwareConfig.set(MEM1, SPI_MEMORY_4M) ///< Macro for specifying MEM1 is 1Mbit + +extern uint8_t USR_LED_ID; ///< Teensy IO number for the user LED. + +extern unsigned BA_EXPAND_NUM_POT; +extern unsigned BA_EXPAND_NUM_SW; +extern unsigned BA_EXPAND_NUM_LED; +extern unsigned BA_EXPAND_NUM_ENC; + +extern uint8_t BA_EXPAND_POT1_PIN; // 14_A0_TX3_SPDIFOUT +extern uint8_t BA_EXPAND_POT2_PIN; // 15_A1_RX3_SPDIFIN +extern uint8_t BA_EXPAND_POT3_PIN; // 16_A2_RX4_SCL1 + +extern uint8_t BA_EXPAND_SW1_PIN; // 2_OUT2 +extern uint8_t BA_EXPAND_SW2_PIN; // 3_LRCLK2 +extern uint8_t BA_EXPAND_LED1_PIN; // 4_BLCK2 +extern uint8_t BA_EXPAND_LED2_PIN; // 5_IN2 + +extern uint8_t GPIO0; +extern uint8_t GPIO1; +extern uint8_t GPIO2; +extern uint8_t GPIO3; +extern uint8_t GPIO4; +extern uint8_t GPIO5; +extern uint8_t GPIO6; +extern uint8_t GPIO7; +extern uint8_t TP1; +extern uint8_t TP2; // SPI0 and SPI1 pinouts -constexpr uint8_t SPI0_SCK_PIN = 14; -constexpr uint8_t SPI0_CS_PIN = 15; -constexpr uint8_t SPI0_MISO_PIN = 8; -constexpr uint8_t SPI0_MOSI_PIN = 7; +extern uint8_t SPI0_SCK_PIN; +extern uint8_t SPI0_CS_PIN; +extern uint8_t SPI0_MISO_PIN; +extern uint8_t SPI0_MOSI_PIN; -#define SPI1_AVAILABLE -constexpr uint8_t SPI1_SCK_PIN = 20; -constexpr uint8_t SPI1_CS_PIN = 31; -constexpr uint8_t SPI1_MISO_PIN = 5; -constexpr uint8_t SPI1_MOSI_PIN = 21; +extern uint8_t SPI1_SCK_PIN; +extern uint8_t SPI1_CS_PIN; +extern uint8_t SPI1_MISO_PIN; +extern uint8_t SPI1_MOSI_PIN; -// GPIOs and Testpoints are accessed via enumerated class constants. -enum class GPIO : uint8_t { - GPIO0 = 2, - GPIO1 = 3, - GPIO2 = 4, - GPIO3 = 6, - - GPIO4 = 12, - GPIO5 = 32, - GPIO6 = 27, - GPIO7 = 28, - - TP1 = 34, - TP2 = 33 -}; +#if defined(ARDUINO_TEENSY41) || defined(__MK66FX1M0__) || defined(__MK64FX512__) +#define SPI1_AVAILABLE +#endif /**************************************************************************//** * Teensy 4.0 Hardware Settings *****************************************************************************/ -#elif defined(__IMXRT1062__) // T4.0 - -// TGA PRO MKI -//constexpr uint8_t USR_LED_ID = 2; ///< Teensy IO number for the user LED. - -// TGA PRO MKI -constexpr uint8_t USR_LED_ID = 6; ///< Teensy IO number for the user LED. - -// SPI0 pinouts -constexpr uint8_t SPI0_SCK_PIN = 13; -constexpr uint8_t SPI0_CS_PIN = 10; -constexpr uint8_t SPI0_MISO_PIN = 12; -constexpr uint8_t SPI0_MOSI_PIN = 11; - -// GPIOs and Testpoints are accessed via enumerated class constants. -enum class GPIO : uint8_t { - GPIO0 = 3, - GPIO1 = 4, - GPIO2 = 5, - GPIO3 = 6, - - GPIO4 = 17, - GPIO5 = 16, - GPIO6 = 15, - GPIO7 = 14, - - TP1 = 9, - TP2 = 22 -}; +#if defined(__IMXRT1062__) // T4.0 #define SCL_PAD_CTRL IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B1_00 #define SDA_PAD_CTRL IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B1_01 @@ -253,83 +262,10 @@ constexpr uint32_t SCL_SDA_PAD_CFG = 0xF808; #define LRCLK_PAD_CTRL IOMUXC_SW_PAD_CTL_PAD_GPIO_AD_B1_11 #define DAC_PAD_CTRL IOMUXC_SW_PAD_CTL_PAD_GPIO_B1_01 constexpr uint32_t I2S_PAD_CFG = 0x0008; - -/**************************************************************************//** - * DEFAULT Teensy 3.2 Hardware Settings - *****************************************************************************/ -#else -constexpr uint8_t USR_LED_ID = 16; ///< Teensy IO number for the user LED. - -// SPI0 and SPI1 pinouts -constexpr uint8_t SPI0_SCK_PIN = 14; -constexpr uint8_t SPI0_CS_PIN = 15; -constexpr uint8_t SPI0_MISO_PIN = 8; -constexpr uint8_t SPI0_MOSI_PIN = 7; - -// GPIOs and Testpoints are accessed via enumerated class constants. -enum class GPIO : uint8_t { - GPIO0 = 2, - GPIO1 = 3, - GPIO2 = 4, - GPIO3 = 6, - - GPIO4 = 12, - GPIO5 = 32, - GPIO6 = 27, - GPIO7 = 28, - - TP1 = 34, - TP2 = 33 -}; #endif -/**************************************************************************//** - * Blackaddr Audio Expansion Board Pin Configuration - *****************************************************************************/ -#if defined(__MK66FX1M0__) || defined(__MK64FX512__) // T3.6 or T3.5 -// Teensy 3.6 Pinout -constexpr unsigned BA_EXPAND_NUM_POT = 3; -constexpr unsigned BA_EXPAND_NUM_SW = 2; -constexpr unsigned BA_EXPAND_NUM_LED = 2; -constexpr unsigned BA_EXPAND_NUM_ENC = 0; - -constexpr uint8_t BA_EXPAND_POT1_PIN = A16; // 35_A16_PWM -constexpr uint8_t BA_EXPAND_POT2_PIN = A17; // 36_A17_PWM -constexpr uint8_t BA_EXPAND_POT3_PIN = A18; // 37_SCL1_A18_PWM -constexpr uint8_t BA_EXPAND_SW1_PIN = 2; // 2)PWM -constexpr uint8_t BA_EXPAND_SW2_PIN = 3; // 3_SCL2_PWM -constexpr uint8_t BA_EXPAND_LED1_PIN = 4; // 4_SDA2_PWM -constexpr uint8_t BA_EXPAND_LED2_PIN = 6; // 6_PWM - -#elif defined(__IMXRT1062__) -// Teensy 4.0 pinout -constexpr unsigned BA_EXPAND_NUM_POT = 3; -constexpr unsigned BA_EXPAND_NUM_SW = 2; -constexpr unsigned BA_EXPAND_NUM_LED = 2; -constexpr unsigned BA_EXPAND_NUM_ENC = 0; - -constexpr uint8_t BA_EXPAND_POT1_PIN = A0; // 14_A0_TX3_SPDIFOUT -constexpr uint8_t BA_EXPAND_POT2_PIN = A1; // 15_A1_RX3_SPDIFIN -constexpr uint8_t BA_EXPAND_POT3_PIN = A2; // 16_A2_RX4_SCL1 - -//// REV B -//constexpr uint8_t BA_EXPAND_SW1_PIN = 3; // 3_LRCLK2 -//constexpr uint8_t BA_EXPAND_SW2_PIN = 4; // 4_BCLK2 -//constexpr uint8_t BA_EXPAND_LED1_PIN = 5; // 5_IN2 -//constexpr uint8_t BA_EXPAND_LED2_PIN = 6; // 6_OUT1D - -// MKII REV1 -constexpr uint8_t BA_EXPAND_SW1_PIN = 2; // 2_OUT2 -constexpr uint8_t BA_EXPAND_SW2_PIN = 3; // 3_LRCLK2 -constexpr uint8_t BA_EXPAND_LED1_PIN = 4; // 4_BLCK2 -constexpr uint8_t BA_EXPAND_LED2_PIN = 5; // 5_IN2 - -#else - -#warning Your processor is not yet supported in BALibrary -#endif } // namespace BALibrary -#endif /* __BALIBRARY_BAHARDWARE_H */ +#endif /* BALIBRARY_BAHARDWARE_H_ */ diff --git a/src/BALibrary.h b/src/BALibrary.h index 9a0a3d3..d56fd30 100644 --- a/src/BALibrary.h +++ b/src/BALibrary.h @@ -17,8 +17,8 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -#ifndef __BALIBRARY_H -#define __BALIBRARY_H +#ifndef BALIBRARY_H_ +#define BALIBRARY_H_ #include "BAHardware.h" // contains the Blackaddr hardware board definitions @@ -31,4 +31,4 @@ #include "BAGpio.h" #include "BAPhysicalControls.h" -#endif /* __BALIBRARY_H */ +#endif /* BALIBRARY_H_ */ diff --git a/src/common/BAHardware.cpp b/src/common/BAHardware.cpp index 2ce9eb1..ca01c08 100644 --- a/src/common/BAHardware.cpp +++ b/src/common/BAHardware.cpp @@ -23,15 +23,277 @@ namespace BALibrary { BAHardware BAHardwareConfig; // create the global configuration struct +//////////////////////////////////////////////////////////////////////////////// +// DEFAULT SETTINGS - modified appropriate when user calls BAHardware:set() +// Default settings are currently for TGA PRO MKII & Teensy 4 +//////////////////////////////////////////////////////////////////////////////// +uint8_t USR_LED_ID = 6; ///< Teensy IO number for the user LED. + +unsigned BA_EXPAND_NUM_POT = 3; +unsigned BA_EXPAND_NUM_SW = 2; +unsigned BA_EXPAND_NUM_LED = 2; +unsigned BA_EXPAND_NUM_ENC = 0; + +uint8_t BA_EXPAND_POT1_PIN = A0; // 14_A0_TX3_SPDIFOUT +uint8_t BA_EXPAND_POT2_PIN = A1; // 15_A1_RX3_SPDIFIN +uint8_t BA_EXPAND_POT3_PIN = A2; // 16_A2_RX4_SCL1 + +uint8_t BA_EXPAND_SW1_PIN = 2; // 2_OUT2 +uint8_t BA_EXPAND_SW2_PIN = 3; // 3_LRCLK2 +uint8_t BA_EXPAND_LED1_PIN = 4; // 4_BLCK2 +uint8_t BA_EXPAND_LED2_PIN = 5; // 5_IN2 + +uint8_t GPIO0 = 2; +uint8_t GPIO1 = 3; +uint8_t GPIO2 = 4; +uint8_t GPIO3 = 5; +uint8_t GPIO4 = 255; // Not available on MKII +uint8_t GPIO5 = 16; +uint8_t GPIO6 = 15; +uint8_t GPIO7 = 14; +uint8_t TP1 = 9; +uint8_t TP2 = 22; + +// SPI0 +uint8_t SPI0_SCK_PIN = 13; +uint8_t SPI0_CS_PIN = 10; +uint8_t SPI0_MISO_PIN = 12; +uint8_t SPI0_MOSI_PIN = 11; + +// SPI1 is only available on user breakout board for MKII/T4 +uint8_t SPI1_SCK_PIN = 27; +uint8_t SPI1_CS_PIN = 38; +uint8_t SPI1_MISO_PIN = 39; +uint8_t SPI1_MOSI_PIN = 26; + +BAHardware::BAHardware() +{ +#if defined(ARDUINO_TEENSY41) || defined(ARDUINO_TEENSY40) // T4.X + m_teensyProcessor = TeensyProcessor::TEENSY4; +#elif defined(__MK66FX1M0__) || defined(__MK64FX512__) || defined(__MK20DX256__) + m_teensyProcessor = TeensyProcessor::TEENSY3; +#else +#error "Only Teensy 4.1, 4.0, 3.6, 3.5, 3.2 are supported" +#endif +} + void BAHardware::set(TgaBoard tgaBoard) { - m_tgaBoard = tgaBoard; + m_tgaBoard = tgaBoard; + + //////////////////////////////////////////////////////////////////////////// + // MKII // + //////////////////////////////////////////////////////////////////////////// +#if defined(ARDUINO_TEENSY41) || defined(ARDUINO_TEENSY40) // T4.X + if (tgaBoard == TgaBoard::MKII_REV1) { + // No change from defaults + } +#endif + +#if defined(__MK66FX1M0__) || defined(__MK64FX512__) || defined(__MK20DX256__) // T3.6 or T3.5 or T3.2 + if (tgaBoard == TgaBoard::MKII_REV1) { + // Uses TEENSY_ADAPTER_T3 + + USR_LED_ID = 16; + + BA_EXPAND_POT1_PIN = A16; // 14_A0_TX3_SPDIFOUT + BA_EXPAND_POT2_PIN = A17; // 15_A1_RX3_SPDIFIN + BA_EXPAND_POT3_PIN = A18; // 16_A2_RX4_SCL1 + + BA_EXPAND_SW1_PIN = 2; // 2_OUT2 + BA_EXPAND_SW2_PIN = 3; // 3_LRCLK2 + BA_EXPAND_LED1_PIN = 4; // 4_BLCK2 + BA_EXPAND_LED2_PIN = 6; // 5_IN2 + + GPIO0 = 2; + GPIO1 = 3; + GPIO2 = 4; + GPIO3 = 6; + GPIO4 = 255; // Not available on MKII + GPIO5 = 37; + GPIO6 = 36; + GPIO7 = 35; + TP1 = 34; + TP2 = 33; + + SPI0_SCK_PIN = 14; + SPI0_CS_PIN = 15; + SPI0_MISO_PIN = 8; + SPI0_MOSI_PIN = 7; + + SPI1_SCK_PIN = 20; + SPI1_CS_PIN = 31; + SPI1_MISO_PIN = 5; + SPI1_MOSI_PIN = 21; + } +#endif + + //////////////////////////////////////////////////////////////////////////// + // REVB (Original TGA Pro) // + //////////////////////////////////////////////////////////////////////////// +#if defined(ARDUINO_TEENSY41) || defined(ARDUINO_TEENSY40) // T4.X + if (tgaBoard == TgaBoard::REV_B) { + // Uses TGA_T4_ADAPTER board + + USR_LED_ID = 2; + + BA_EXPAND_POT1_PIN = A0; // 14_A0_TX3_SPDIFOUT + BA_EXPAND_POT2_PIN = A1; // 15_A1_RX3_SPDIFIN + BA_EXPAND_POT3_PIN = A2; // 16_A2_RX4_SCL1 + + BA_EXPAND_SW1_PIN = 3; // 2_OUT2 + BA_EXPAND_SW2_PIN = 4; // 3_LRCLK2 + BA_EXPAND_LED1_PIN = 5; // 4_BLCK2 + BA_EXPAND_LED2_PIN = 6; // 5_IN2 + + GPIO0 = 3; + GPIO1 = 4; + GPIO2 = 5; + GPIO3 = 6; + GPIO4 = 17; + GPIO5 = 16; + GPIO6 = 15; + GPIO7 = 14; + TP1 = 9; + TP2 = 255; // Not available + + SPI0_SCK_PIN = 13; + SPI0_CS_PIN = 10; + SPI0_MISO_PIN = 12; + SPI0_MOSI_PIN = 11; + } +#endif + +#if defined(__MK66FX1M0__) || defined(__MK64FX512__) || defined(__MK20DX256__) // T3.6 or T3.5 or T3.2 + if (tgaBoard == TgaBoard::REV_B) { + + USR_LED_ID = 16; + + BA_EXPAND_POT1_PIN = A16; // 14_A0_TX3_SPDIFOUT + BA_EXPAND_POT2_PIN = A17; // 15_A1_RX3_SPDIFIN + BA_EXPAND_POT3_PIN = A18; // 16_A2_RX4_SCL1 + + BA_EXPAND_SW1_PIN = 2; // 2_OUT2 + BA_EXPAND_SW2_PIN = 3; // 3_LRCLK2 + BA_EXPAND_LED1_PIN = 4; // 4_BLCK2 + BA_EXPAND_LED2_PIN = 6; // 5_IN2 + + GPIO0 = 2; + GPIO1 = 3; + GPIO2 = 4; + GPIO3 = 6; + GPIO4 = 38; + GPIO5 = 37; + GPIO6 = 36; + GPIO7 = 35; + TP1 = 34; + TP2 = 33; + + SPI0_SCK_PIN = 14; + SPI0_CS_PIN = 15; + SPI0_MISO_PIN = 8; + SPI0_MOSI_PIN = 7; + + SPI1_SCK_PIN = 20; + SPI1_CS_PIN = 31; + SPI1_MISO_PIN = 5; + SPI1_MOSI_PIN = 21; + } +#endif + + //////////////////////////////////////////////////////////////////////////// + // REVA (Original TGA Pro) // + //////////////////////////////////////////////////////////////////////////// +#if defined(ARDUINO_TEENSY41) || defined(ARDUINO_TEENSY40) // T4.X + if (tgaBoard == TgaBoard::REV_A) { + // Uses TGA_T4_ADAPTER board + + USR_LED_ID = 2; + + GPIO0 = 3; + GPIO1 = 4; + GPIO2 = 5; + GPIO3 = 6; + GPIO4 = 17; + GPIO5 = 16; + GPIO6 = 15; + GPIO7 = 14; + TP1 = 9; + TP2 = 255; // Not available + + SPI0_SCK_PIN = 13; + SPI0_CS_PIN = 10; + SPI0_MISO_PIN = 12; + SPI0_MOSI_PIN = 11; + } +#endif + +#if defined(__MK66FX1M0__) || defined(__MK64FX512__) || defined(__MK20DX256__) // T3.6 or T3.5 or T3.2 + if (tgaBoard == TgaBoard::REV_A) { + // REVA did not support Expansion board + + USR_LED_ID = 16; + + GPIO0 = 2; + GPIO1 = 3; + GPIO2 = 4; + GPIO3 = 6; + GPIO4 = 12; + GPIO5 = 32; + GPIO6 = 27; + GPIO7 = 29; + TP1 = 34; + TP2 = 33; + + SPI0_SCK_PIN = 14; + SPI0_CS_PIN = 15; + SPI0_MISO_PIN = 8; + SPI0_MOSI_PIN = 7; + + SPI1_SCK_PIN = 20; + SPI1_CS_PIN = 31; + SPI1_MISO_PIN = 5; + SPI1_MOSI_PIN = 21; + } +#endif + + //////////////////////////////////////////////////////////////////////////// + // Avalon // + //////////////////////////////////////////////////////////////////////////// +#if defined(ARDUINO_TEENSY41) // T4.X + if (tgaBoard == TgaBoard::AVALON) { + BA_EXPAND_NUM_POT = 2; + BA_EXPAND_NUM_SW = 6; + BA_EXPAND_NUM_LED = 2; + BA_EXPAND_NUM_ENC = 4; + + BA_EXPAND_POT1_PIN = A0; + BA_EXPAND_POT2_PIN = A1; + BA_EXPAND_POT3_PIN = A13; + + BA_EXPAND_SW1_PIN = 17; + BA_EXPAND_SW2_PIN = 16; + BA_EXPAND_LED1_PIN = 22; + BA_EXPAND_LED2_PIN = 32; + + SPI0_SCK_PIN = 13; + SPI0_CS_PIN = 10; + SPI0_MISO_PIN = 12; + SPI0_MOSI_PIN = 11; + } +#endif } + TgaBoard BAHardware::getTgaBoard(void) { return m_tgaBoard; } +TeensyProcessor BAHardware::getTeensyProcessor(void) +{ + return m_teensyProcessor; +} + void BAHardware::set(ExpansionBoard expansionBoard) { m_expansionBoard = expansionBoard; diff --git a/src/effects/AudioEffectSOS.cpp b/src/effects/AudioEffectSOS.cpp index 7999ac6..61552b5 100644 --- a/src/effects/AudioEffectSOS.cpp +++ b/src/effects/AudioEffectSOS.cpp @@ -67,23 +67,20 @@ void AudioEffectSOS::enable(void) } m_delaySamples = m_maxDelaySamples; m_inputGateAuto.setupParameter(GATE_OPEN_STAGE, 0.0f, 1.0f, 1000.0f, ParameterAutomation::Function::EXPONENTIAL); - m_inputGateAuto.setupParameter(GATE_HOLD_STAGE, 1.0f, 1.0f, m_maxDelaySamples, ParameterAutomation::Function::HOLD); + m_inputGateAuto.setupParameter(GATE_HOLD_STAGE, 1.0f, 1.0f, m_delaySamples, ParameterAutomation::Function::HOLD); m_inputGateAuto.setupParameter(GATE_CLOSE_STAGE, 1.0f, 0.0f, 1000.0f, ParameterAutomation::Function::EXPONENTIAL); m_clearFeedbackAuto.setupParameter(GATE_OPEN_STAGE, 1.0f, 0.0f, 1000.0f, ParameterAutomation::Function::EXPONENTIAL); - m_clearFeedbackAuto.setupParameter(GATE_HOLD_STAGE, 0.0f, 0.0f, m_maxDelaySamples, ParameterAutomation::Function::HOLD); + m_clearFeedbackAuto.setupParameter(GATE_HOLD_STAGE, 0.0f, 0.0f, m_delaySamples, ParameterAutomation::Function::HOLD); m_clearFeedbackAuto.setupParameter(GATE_CLOSE_STAGE, 0.0f, 1.0f, 1000.0f, ParameterAutomation::Function::EXPONENTIAL); } void AudioEffectSOS::update(void) { - audio_block_t *inputAudioBlock = receiveReadOnly(); // get the next block of input samples // Check is block is disabled if (m_enable == false) { // do not transmit or process any audio, return as quickly as possible. - if (inputAudioBlock) release(inputAudioBlock); - // release all held memory resources if (m_previousBlock) { release(m_previousBlock); m_previousBlock = nullptr; @@ -99,6 +96,8 @@ void AudioEffectSOS::update(void) return; } + audio_block_t *inputAudioBlock = receiveReadOnly(); // get the next block of input samples + // Check is block is bypassed, if so either transmit input directly or create silence if ( (m_bypass == true) || (!inputAudioBlock) ) { // transmit the input directly @@ -138,11 +137,7 @@ void AudioEffectSOS::update(void) // mix the input with the feedback path in the pre-processing stage m_preProcessing(preProcessed, inputAudioBlock, m_previousBlock); - // consider doing the BBD post processing here to use up more time while waiting - // for the read data to come back audio_block_t *blockToRelease = m_memory->addBlock(preProcessed); - //audio_block_t *blockToRelease = m_memory->addBlock(inputAudioBlock); - //Serial.println("Done adding new block"); // BACK TO OUTPUT PROCESSING @@ -158,15 +153,14 @@ void AudioEffectSOS::update(void) release(inputAudioBlock); - if (m_previousBlock) - release(m_previousBlock); + if (m_previousBlock) { release(m_previousBlock); } m_previousBlock = blockToOutput; if (m_blockToRelease == m_previousBlock) { Serial.println("ERROR: POINTER COLLISION"); } - if (m_blockToRelease) release(m_blockToRelease); + if (m_blockToRelease) { release(m_blockToRelease); } m_blockToRelease = blockToRelease; } @@ -176,14 +170,12 @@ void AudioEffectSOS::gateOpenTime(float milliseconds) // TODO - change the paramter automation to an automation sequence m_openTimeMs = milliseconds; m_inputGateAuto.setupParameter(GATE_OPEN_STAGE, 0.0f, 1.0f, m_openTimeMs, ParameterAutomation::Function::EXPONENTIAL); - //m_clearFeedbackAuto.setupParameter(GATE_OPEN_STAGE, 1.0f, 0.0f, m_openTimeMs, ParameterAutomation::Function::EXPONENTIAL); } void AudioEffectSOS::gateCloseTime(float milliseconds) { m_closeTimeMs = milliseconds; m_inputGateAuto.setupParameter(GATE_CLOSE_STAGE, 1.0f, 0.0f, m_closeTimeMs, ParameterAutomation::Function::EXPONENTIAL); - //m_clearFeedbackAuto.setupParameter(GATE_CLOSE_STAGE, 0.0f, 1.0f, m_closeTimeMs, ParameterAutomation::Function::EXPONENTIAL); } ////////////////////////////////////////////////////////////////////////