Skip to content
Snippets Groups Projects
Commit 8768cfd9 authored by David Huss's avatar David Huss :speech_balloon:
Browse files

Make waveform modes wrap around

parent 90ba64ae
No related branches found
No related tags found
No related merge requests found
......@@ -6,6 +6,7 @@
#define FREQ_POT_PIN 27
#define INVERSION_PIN 28
#define CHORD_POT_PIN 29
#define DEBUG_MODE false
// 0-4=chord osc , 5=bass osc , 6=arpeggio osc
float osc_progress[6];
......@@ -102,7 +103,7 @@ void setup() {
pinMode(PUSHBUTTON_PIN, INPUT_PULLUP);//push sw
// Create the waveform and put it into the wavetable
wavetable_populate();
wavetable_populate(waveform_selection);
quantizer_select();
//-------------------octave select-------------------------------
for (int i = 0; i < 1230; i++) {//Covers 6(=1230) octaves. If it is 1230 or more, the operation becomes unstable.
......@@ -178,10 +179,12 @@ void loop() {
osc_freq = freq_table[qnt[thr] + freq_pot]; // V/oct apply
osc_freq = 256 * osc_freq / 122070 * 8;//7 is base octave
if (DEBUG_MODE) {
Serial.print(analogRead(VOCT_PIN));
Serial.print(",");
Serial.print(adc);
Serial.println("");
}
// -------------------chord mode select-------------------------------
chord_mode = analogRead(CHORD_POT_PIN)/171; //171=1023/6 , 6 is amount of chord mode
......@@ -368,9 +371,11 @@ void loop() {
push_sw = digitalRead(PUSHBUTTON_PIN);
// TODO: Add propper debouncing for the button here
if (push_sw == 0 && old_push_sw == 1) {//when push sw ON
// Change the selected waveform and ensure the selection is within bounds
waveform_selection = min(waveform_selection + 1, 6);
wavetable_populate();
// Change the selected waveform and ensure the selection is within bounds+1
waveform_selection = min(waveform_selection + 1, 8);
// Wrap around if we are around the last element
if (waveform_selection == 8) { waveform_selection = 0; }
wavetable_populate(waveform_selection);
}
}
......@@ -419,7 +424,7 @@ void quantizer_select(){
}
// Populate the wavetable with values
void wavetable_populate() {
void wavetable_populate(int waveform_selection) {
switch (waveform_selection) {
// Sawtooth wave
case 0:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment