From 4425550f5bbb71d22f35e35311dd2160071d1492 Mon Sep 17 00:00:00 2001 From: --global <--global> Date: Tue, 9 May 2023 20:17:45 +0300 Subject: [PATCH] added subdiv modulation, but it still needs some work --- software/GToE/GToE.ino | 49 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 40 insertions(+), 9 deletions(-) diff --git a/software/GToE/GToE.ino b/software/GToE/GToE.ino index e80bf54..c83a20c 100644 --- a/software/GToE/GToE.ino +++ b/software/GToE/GToE.ino @@ -36,17 +36,17 @@ struct channel { }; channel channels[6] = { //array of channel settings - { 8, 0, 0, 0, 0 }, - { 8, 0, 0, 0, 0 }, - { 8, 0, 0, 0, 0 }, - { 8, 0, 0, 0, 0 }, - { 8, 0, 0, 0, 0 }, - { 8, 0, 0, 0, 0 } + { 7, 0, 0, 0, 0 }, + { 7, 0, 0, 0, 0 }, + { 7, 0, 0, 0, 0 }, + { 7, 0, 0, 0, 0 }, + { 7, 0, 0, 0, 0 }, + { 7, 0, 0, 0, 0 } }; int channelPulseCount[6]; int channelPulsesPerCycle[6]; -int playingModes[6]; //actual channel modes array updated from channels each beat +int playingModes[6]; //actual channel modes array updated from channels object on each beat unsigned int pulsePeriod; bool isPlaying = false; @@ -192,14 +192,17 @@ void externalClock() { } void sendTriggers() { + calculateCycles(); + //switching modes on the beat and resetting channel clock if (pulseCount == 0) { for (int i = 0; i<6; i++) { if (playingModes[i] != clockModes[channels[i].mode]) { - calculateCycles(); + // calculateCycles(); this shouldn't be inside the loop. but it was here and it worked channelPulseCount[i] = 0; } } + // calculateCycles(); } //multiplier @@ -218,13 +221,41 @@ void sendTriggers() { } void calculateCycles() { + /*modulation for (int i = 0; i<6; i++) { - playingModes[i] = clockModes[channels[i].mode]; + if (channels[i].modulationRange != 0) { + int mod; + if (!channels[i].modulationChannel) { + mod = a1Input; + } else { + mod = a2Input; + } + mod = map (mod, 0, 1023, 0, channels[i].modulationRange); + playingModes[i] = clockModes[channels[i].mode - mod]; //subtracting because the innitiall array is backwards + } + }*/ + + + for (int i = 0; i<6; i++) { + if (channels[i].modulationRange == 0) { + playingModes[i] = clockModes[channels[i].mode]; + } else { //modulation happens here + int mod; + if (!channels[i].modulationChannel) { + mod = a1Input; + } else { + mod = a2Input; + } + mod = map (mod, 0, 1023, 0, channels[i].modulationRange); + playingModes[i] = clockModes[channels[i].mode - mod]; //subtracting because the innitiall array is backwards + } + if (playingModes[i] > 0) { channelPulsesPerCycle[i] = (playingModes[i] * PPQN) - 1; } else { channelPulsesPerCycle[i] = (PPQN / abs(playingModes[i])) - 1; } + } }