fixed sequence lengthe (was playing one step more than set)
This commit is contained in:
@ -85,22 +85,7 @@ sequence sequences[] {
|
|||||||
{0b000000000000000000000000000000000, 15},
|
{0b000000000000000000000000000000000, 15},
|
||||||
{0b000000000000000000000000000000000, 15}
|
{0b000000000000000000000000000000000, 15}
|
||||||
};
|
};
|
||||||
/*bool seqA1[16] = {1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1};
|
|
||||||
bool seqA2[16] = {0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0};
|
|
||||||
bool seqA3[16] = {1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0};
|
|
||||||
bool seqA4[16] = {0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1};
|
|
||||||
bool seqA5[16] = {0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1};
|
|
||||||
bool seqA6[16] = {0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0};
|
|
||||||
bool seqA7[16] = {1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0};
|
|
||||||
bool seqA8[16] = {1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 1};
|
|
||||||
bool seqB1[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
|
||||||
bool seqB2[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
|
||||||
bool seqB3[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
|
||||||
bool seqB4[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
|
||||||
bool seqB5[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
|
||||||
bool seqB6[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
|
||||||
bool seqB7[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
|
||||||
bool seqB8[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};*/
|
|
||||||
byte currentStep[7] = {0};
|
byte currentStep[7] = {0};
|
||||||
int8_t stepNumSelected = 0;
|
int8_t stepNumSelected = 0;
|
||||||
byte patternToEdit;
|
byte patternToEdit;
|
||||||
@ -216,7 +201,7 @@ void sendMIDIStop() {
|
|||||||
|
|
||||||
void receiveMIDI( uint8_t msg, uint8_t status ) {
|
void receiveMIDI( uint8_t msg, uint8_t status ) {
|
||||||
if (masterClockMode == 2) {
|
if (masterClockMode == 2) {
|
||||||
if (msg == 0xF8) { //Clock
|
if (msg == 0xF8) { //Clock tick
|
||||||
MIDIClockReceived = true;
|
MIDIClockReceived = true;
|
||||||
} else if (msg == 0xFC) { //stop
|
} else if (msg == 0xFC) { //stop
|
||||||
isPlaying = false;
|
isPlaying = false;
|
||||||
@ -279,19 +264,14 @@ void clock() {
|
|||||||
|
|
||||||
// pull low all outputs after set pulse length
|
// pull low all outputs after set pulse length
|
||||||
for (byte i = 0; i < 7; i++) {
|
for (byte i = 0; i < 7; i++) {
|
||||||
if (channels[i].mode != 4 && tickCount >= PULSE_LENGTH) { //everything but gate mode
|
if (channels[i].mode != 4 && tickCount >= PULSE_LENGTH) { //everything but gate mode
|
||||||
digitalWrite(outsPins[i], LOW);
|
digitalWrite(outsPins[i], LOW);
|
||||||
}
|
} else if (channels[i].mode == 4 && tickCount >= gateCountDown[i]) { //gate mode gateLengthTime[i] < pulsePeriod
|
||||||
|
|
||||||
if (channels[i].mode == 4 && gateCountDown[i] > pulsePeriod && tickCount >= pulsePeriod) { //tickCount == 0?
|
|
||||||
gateCountDown[i] = gateCountDown[i] - pulsePeriod; // !!! Most likely something is wrong here that causing the drift
|
|
||||||
}
|
|
||||||
|
|
||||||
if (channels[i].mode == 4 && tickCount >= gateCountDown[i]) { //gate mode
|
|
||||||
digitalWrite(outsPins[i], LOW);
|
digitalWrite(outsPins[i], LOW);
|
||||||
gateCountDown[i] = gateLengthTime[i];
|
gateCountDown[i] = gateLengthTime[i];
|
||||||
|
} else if (channels[i].mode == 4 && gateCountDown[i] > pulsePeriod && tickCount == 0) {
|
||||||
|
gateCountDown[i] = gateCountDown[i] - pulsePeriod;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -393,7 +373,7 @@ void sendTriggers() { //rename to onPulse or something
|
|||||||
} else {
|
} else {
|
||||||
sixteenthPulseCount = 0;
|
sixteenthPulseCount = 0;
|
||||||
for (byte i; i < 7; i++) {
|
for (byte i; i < 7; i++) {
|
||||||
if (channels[i].mode == 2 && currentStep[i] <= sequences[channels[i].seqPattern].length) {
|
if (channels[i].mode == 2 && currentStep[i] < sequences[channels[i].seqPattern].length) {
|
||||||
currentStep[i] ++;
|
currentStep[i] ++;
|
||||||
} else {
|
} else {
|
||||||
currentStep[i] = 0;
|
currentStep[i] = 0;
|
||||||
@ -482,15 +462,12 @@ void calculateCycles() {
|
|||||||
|
|
||||||
void calculateGate(uint8_t channel) {
|
void calculateGate(uint8_t channel) {
|
||||||
//if (subDivs[channels[channel].subDiv] > 0) {
|
//if (subDivs[channels[channel].subDiv] > 0) {
|
||||||
uint16_t gateLengthOld = gateLengthTime[channel];
|
gateLengthTime[channel] = ((channelPulsesPerCycle[channel] + 1) * (pulsePeriod + 1) / 100) * channels[channel].gate;
|
||||||
//gateLengthTime[channel] = ((channelPulsesPerCycle[channel] + 1) * (pulsePeriod + 1) / 100) * channels[channel].gate; // this seemed to work, but at some point started drifting
|
gateCountDown[channel] = gateLengthTime[channel];
|
||||||
gateLengthTime[channel] = ((channelPulsesPerCycle[channel] + 1) * (pulsePeriod - 1) / 100) * channels[channel].gate;
|
|
||||||
if (gateLengthOld != gateLengthTime[channel]) {
|
|
||||||
gateCountDown[channel] = gateLengthTime[channel];
|
|
||||||
}
|
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void calculateBPMTiming() {
|
void calculateBPMTiming() {
|
||||||
int mod = 0;
|
int mod = 0;
|
||||||
if (masterClockMode == 0) { //Internal clock
|
if (masterClockMode == 0) { //Internal clock
|
||||||
@ -506,12 +483,6 @@ void calculateBPMTiming() {
|
|||||||
} else if (masterClockMode == 1 && extClockPPQN == 1) { //for ext 1/16 clock
|
} else if (masterClockMode == 1 && extClockPPQN == 1) { //for ext 1/16 clock
|
||||||
pulsePeriod = (newExtPulseTime - lastExtPulseTime) * 10 / 6;
|
pulsePeriod = (newExtPulseTime - lastExtPulseTime) * 10 / 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (byte i = 0; i < (extraChannel ? 7 : 6); i++) {
|
|
||||||
if (channels[i].mode == 4) {
|
|
||||||
calculateGate(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void resetClocks() {
|
void resetClocks() {
|
||||||
|
|||||||
@ -20,7 +20,6 @@ const byte clockOutPin = 3;
|
|||||||
const byte outsPins[] = { 7, 8, 10, 6, 9, 11, clockOutPin };
|
const byte outsPins[] = { 7, 8, 10, 6, 9, 11, clockOutPin };
|
||||||
bool rotateScreen = false;
|
bool rotateScreen = false;
|
||||||
bool reverseEnc = false;
|
bool reverseEnc = false;
|
||||||
//
|
|
||||||
|
|
||||||
/* Rev 1 Config
|
/* Rev 1 Config
|
||||||
#define ENC_BTN_PIN 14
|
#define ENC_BTN_PIN 14
|
||||||
@ -34,7 +33,7 @@ bool reverseEnc = false;
|
|||||||
#define ANALOGUE_INPUT_2_PIN A1
|
#define ANALOGUE_INPUT_2_PIN A1
|
||||||
|
|
||||||
const byte clockOutPin = 13;
|
const byte clockOutPin = 13;
|
||||||
const byte outsPins[6] = {6, 11, 7, 10, 8, 9};
|
const byte outsPins[6] = {6, 11, 7, 10, 8, 9, clockOutPin};
|
||||||
bool rotateScreen = true;
|
bool rotateScreen = true;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user