diff --git a/MicroDexed.ino b/MicroDexed.ino index ceef66b..bc9a8a1 100644 --- a/MicroDexed.ino +++ b/MicroDexed.ino @@ -51,25 +51,43 @@ uint8_t ui_main_state = UI_MAIN_VOICE; #endif // GUItool: begin automatically generated code -AudioPlayQueue queue1; //xy=494,404 -AudioAnalyzePeak peak1; //xy=695,491 +AudioPlayQueue queue1; //xy=694.0277709960938,601.9166259765625 +AudioFilterStateVariable filter1; //xy=434.44439697265625,456.6666564941406 +AudioEffectDelay delay1; //xy=895.5554809570312,542.2223510742188 +AudioAnalyzePeak peak1; //xy=987.25,722.25 +AudioMixer4 mixer1; //xy=1054.6109619140625,591.2499389648438 +AudioEffectFreeverb freeverb1; //xy=1120,352.22222900390625 +AudioAmplifier amp1; //xy=1086.666748046875,537.7777709960938 +AudioAmplifier amp2; //xy=1206.6666666666667,416.66666666666663 #ifdef TEENSY_AUDIO_BOARD -AudioOutputI2S i2s1; //xy=1072,364 +AudioOutputI2S i2s1; //xy=1364.25,595.25 +AudioControlSGTL5000 sgtl5000_1; //xy=371.33319091796875,513.8888549804688 AudioConnection patchCord1(queue1, peak1); -AudioConnection patchCord2(queue1, 0, i2s1, 0); -AudioConnection patchCord3(queue1, 0, i2s1, 1); -AudioControlSGTL5000 sgtl5000_1; //xy=700,536 +AudioConnection patchCord2(queue1, delay1); +AudioConnection patchCord3(queue1, 0, filter1, 0); +AudioConnection patchCord4(filter1, 0, mixer1, 0); +AudioConnection patchCord5(delay1, 0, mixer1, 1); +AudioConnection patchCord6(mixer1, amp1); +AudioConnection patchCord7(mixer1, freeverb1); +AudioConnection patchCord8(freeverb1, amp2); +AudioConnection patchCord9(amp1, delay1); +AudioConnection patchCord10(amp2, 0, i2s1, 0); +AudioConnection patchCord11(amp2, 0, i2s1, 1); #else AudioOutputPT8211 pt8211_1; //xy=1079,320 AudioAmplifier volume_master; //xy=678,393 AudioAmplifier volume_r; //xy=818,370 AudioAmplifier volume_l; //xy=818,411 AudioConnection patchCord1(queue1, peak1); -AudioConnection patchCord2(queue1, volume_master); -AudioConnection patchCord3(volume_master, volume_r); -AudioConnection patchCord4(volume_master, volume_l); -AudioConnection patchCord5(volume_r, 0, pt8211_1, 0); -AudioConnection patchCord6(volume_l, 0, pt8211_1, 1); +AudioConnection patchCord2(queue1, delay1); +AudioConnection patchCord3(queue1, 0, mixer1, 0); +AudioConnection patchCord4(delay1, 0, mixer1, 1); +AudioConnection patchCord5(mixer1, 0, volume_master, 0); +AudioConnection patchCord6(amp1, delay1); // feedback-loop +AudioConnection patchCord7(volume_master, volume_r); +AudioConnection patchCord8(volume_master, volume_l); +AudioConnection patchCord9(volume_r, 0, pt8211_1, 0); +AudioConnection patchCord10(volume_l, 0, pt8211_1, 1); #endif // GUItool: end automatically generated code @@ -205,6 +223,18 @@ void setup() Serial.println(F("]")); } #endif + + // fixed delay options + delay1.delay(0, 110); + mixer1.gain(0, 1.0); // original sigmal + mixer1.gain(1, 0.5); // delay tap sigmal + amp1.gain(0.1); // feedback level + // fixed reverb options + freeverb1.roomsize(0.5); + freeverb1.damping(0.5); + filter1.frequency(1000); + filter1.resonance(2); + filter1.octaveControl(1); // load default SYSEX data load_sysex(bank, voice); } diff --git a/addon/FeedbackDelay.cpp b/addon/FeedbackDelay.cpp new file mode 100644 index 0000000..24841dd --- /dev/null +++ b/addon/FeedbackDelay.cpp @@ -0,0 +1,97 @@ +// http://digitalmedia.risd.edu/pbadger/PhysComp/index.php?n=Devices.CombinedFilterAndFeedbackDelayCodeFromTheTutorials +/* Filter combined with Feedback (Echo) Delay from the + Teensy Audio Library examples. Check the pins you use + on pots. Inputs to the mixer are on inputs 0 (signal) and 1 (delay line) +*/ + +#include +#include +#include +#include +#include + +// GUItool: begin automatically generated code +AudioPlaySdWav playSdWav1; //xy=192,121 +AudioFilterStateVariable filter1; //xy=396,132 +AudioMixer4 mixer1; //xy=584,134 +AudioEffectDelay delay1; //xy=598,313 +AudioOutputI2S i2s1; //xy=799,289 +AudioConnection patchCord1(playSdWav1, 0, filter1, 0); +AudioConnection patchCord2(filter1, 1, mixer1, 0); // filter 1, 1 is bandbass - +// try filter 1, 0 for high pass +// try filter 1, 2 for high pass +AudioConnection patchCord3(mixer1, delay1); +AudioConnection patchCord4(delay1, 0, mixer1, 1); +AudioConnection patchCord5(delay1, 0, i2s1, 0); +AudioConnection patchCord6(delay1, 0, i2s1, 1); +AudioControlSGTL5000 sgtl5000_1; //xy=597,539 +// GUItool: end automatically generated code + + + +#include + +Bounce button0 = Bounce(17, 5); +float freq ; +int knob2; + +void setup() { + Serial.begin(57600); // you may have to set serial monitor to higher speed + pinMode(0, INPUT_PULLUP); + AudioMemory(200); + sgtl5000_1.enable(); + sgtl5000_1.volume(0.55); + sgtl5000_1.enable(); + sgtl5000_1.volume(0.5); + SPI.setMOSI(7); + SPI.setSCK(14); + if (!(SD.begin(10))) { + while (1) { + Serial.println("Unable to access the SD card"); + delay(500); + } + } + mixer1.gain(0, 0.7); + mixer1.gain(1, 0.7); + delay1.delay(0, 400); + filter1.resonance(2.5); // values between 0.7 and 5.0 useful + delay(1000); +} + +void loop() { + // uncomment for A3 knob to control the feedback level + + if (playSdWav1.isPlaying() == false) { + Serial.println("Start playing"); + playSdWav1.play("SDTEST1.WAV"); + delay(20); // wait for library to parse WAV info + } + + int knob = analogRead(16); + float feedback = (float)knob / 1050.0; + mixer1.gain(1, feedback); + Serial.println(feedback); + + // uncomment for pin 0 button to double the feedback (allowing unstable) + /* + button0.update(); + if (button0.read() == LOW) { + mixer1.gain(1, feedback * 2.0); + } + + */ + + + // read the knob and adjust the filter frequency + knob2 = analogRead(A1) + 20; + // quick and dirty equation for exp scale frequency adjust + freq = expf((float)knob2 / 150.0) * 20.0 + 80.0; + filter1.frequency(freq); +/* //uncomment for freq debug + Serial.print(knob2); + Serial.print("\t"); + Serial.print("freq = "); + Serial.println(freq); + + delay(5); */ +} diff --git a/config.h b/config.h index 90fbf37..06c672d 100644 --- a/config.h +++ b/config.h @@ -44,7 +44,7 @@ #ifndef TEENSY_AUDIO_BOARD #define AUDIO_MEM 80 #else -#define AUDIO_MEM 80 +#define AUDIO_MEM 128 #endif #define SAMPLE_RATE 44100 #define MAX_BANKS 100 diff --git a/dexed.h b/dexed.h index b2b7f65..df18b9d 100644 --- a/dexed.h +++ b/dexed.h @@ -35,6 +35,7 @@ #include "EngineMkI.h" #include "EngineOpl.h" #include +#include "config.h" extern uint8_t bank; extern uint32_t overload; @@ -182,7 +183,7 @@ class Dexed void keyup(uint8_t pitch); void keydown(uint8_t pitch, uint8_t velo); - static const uint8_t MAX_ACTIVE_NOTES = 16; + static const uint8_t MAX_ACTIVE_NOTES = MAX_NOTES; uint8_t max_notes = MAX_ACTIVE_NOTES; ProcessorVoice voices[MAX_ACTIVE_NOTES]; uint8_t currentNote;