Finished version of We Wish You a Merry Christmas
parent
56fae7e54d
commit
88fda8a5f2
|
@ -8,42 +8,26 @@ Adafruit_MCP4728 mcp;
|
|||
float tuning[16];
|
||||
// 0 = A, 8 = F (tonic)
|
||||
|
||||
/*
|
||||
int m1[] = { 3, 8, 8, 10, 8, 7, 5, 5, 5, 10, 10, 12, 10, 8, 7, 3, 7, 12, 12, 13, 12, 10, 8, 5, 3, 3, 5, 10, 7, 8, 3, 8, 8, 8, 7, 7, 8, 7, 5, 3, 10, 12, 10, 10, 8, 8, 15, 3, 3, 3, 5, 10, 7, 8 };
|
||||
int s1[] = { 0, 2, 4, 5, 6, 7, 8, 10, 12, 14, 16, 17, 18, 19, 20, 22, 24, 26, 28, 29, 30, 31, 32, 34, 36, 37, 38, 40, 42, 44, 48, 50, 52, 54, 56, 60, 62, 64, 66, 68, 72, 74, 76, 77, 78, 79, 80, 82, 84, 85, 86, 88, 90, 92 };
|
||||
float d1[] = { 2, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, 2, 2, 1, 1, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 4 };
|
||||
|
||||
For each note: pitch, absolute start time (in beats) and duration - either preset these or compute it
|
||||
|
||||
For a sequencer: is time-elapsed > start time of next note?
|
||||
|
||||
if yes - set the play time to now, increment the note
|
||||
- if a note happens to be playing now, doesn't matter, just change the pitch and reset the timer
|
||||
|
||||
if no - is there still a note playing?
|
||||
|
||||
if still playing, is now - play start > the note's duration? if so, stop playing
|
||||
|
||||
the absolute start time should include a count-in
|
||||
|
||||
*/
|
||||
|
||||
// int m1[] = { 3, 8, 8, 10, 8, 7, 5, 5, 5, 10, 10, 12, 10, 8, 7, 3, 7, 12, 12, 13, 12, 10, 8, 5, 3, 3, 5, 10, 7, 8, 3, 8, 8, 8, 7, 7, 8, 7, 5, 3, 10, 12, 10, 10, 8, 8, 15, 3, 3, 3, 5, 10, 7, 8 };
|
||||
// int s1[] = { 2, 4, 5, 6, 7, 8, 10, 12, 14, 16, 17, 18, 19, 20, 22, 24, 26, 28, 29, 30, 31, 32, 34, 36, 37, 38, 40, 42, 44, 48, 50, 52, 54, 56, 60, 62, 64, 66, 68, 72, 74, 76, 77, 78, 79, 80, 82, 84, 85, 86, 88, 90, 92, 96 };
|
||||
// int d1[] = { 2, 2, 1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 1, 1, 2, 2, 1, 1, 2, 2, 2, 4, 2, 2, 2, 2, 4, 2, 2, 2, 2, 4, 2, 2, 1, 1, 1, 1, 2, 2, 1, 1, 2, 2, 2, 4 };
|
||||
|
||||
//int m2[] = { -1, 8, 1, 2, 3, 4, 5, 0, 1, 3, 8, 8, 3, 5, 7, 8, 7, 0, 1, 3, 8 };
|
||||
//int d2[] = { 2, 6, 6, 6, 6, 6, 4, 2, 4, 2, 6, 6, 6, 6, 6, 6, 4, 2, 4, 2, 4 };
|
||||
int m2[] = { 8, 1, 2, 3, 4, 5, 0, 1, 3, 8, 8, 3, 5, 7, 8, 7, 0, 1, 3, 8 };
|
||||
int s2[] = { 2, 8, 14, 20, 26, 32, 36, 38, 42, 44, 50, 56, 62, 68, 74, 80, 84, 86, 90, 92 };
|
||||
float d2[] = { 6, 6, 6, 6, 6, 4, 2, 4, 2, 6, 6, 6, 6, 6, 6, 4, 2, 4, 2, 4 };
|
||||
|
||||
|
||||
|
||||
int m1[] = { 0, 2, 4, 5, 7, 9, 11, 12 };
|
||||
int s1[] = { 0, 2, 4, 6, 8, 10, 12, 14 };
|
||||
float d1[] = { 1.0, 0.5, 1.0, 0.5, 1.0, 0.5, 1.0, 0.5 };
|
||||
int m2[] = { 0, 4, 7, 12, 0, 4, 7, 12, 0, 4, 7, 12, 0, 4, 7, 12 };
|
||||
int s2[] = { 0, 1 , 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
|
||||
float d2[] = { 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5 };
|
||||
// int m1[] = { 0, 2, 4, 5, 7, 9, 11, 12 };
|
||||
// int s1[] = { 0, 2, 4, 6, 8, 10, 12, 14 };
|
||||
// float d1[] = { 1.0, 0.5, 1.0, 0.5, 1.0, 0.5, 1.0, 0.5 };
|
||||
// int m2[] = { 0, 4, 7, 12, 0, 4, 7, 12, 0, 4, 7, 12, 0, 4, 7, 12 };
|
||||
// int s2[] = { 0, 1 , 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
|
||||
// float d2[] = { 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5 };
|
||||
|
||||
|
||||
float gate = 0.5;
|
||||
int bpm = 180;
|
||||
int bpm = 320;
|
||||
float beat_s = 60.0 / (float)bpm;
|
||||
int beat = round(1000.0 * beat_s);
|
||||
|
||||
|
@ -53,7 +37,7 @@ int beat = round(1000.0 * beat_s);
|
|||
// From here on, all times are in milliseconds to head off floating point errors
|
||||
|
||||
long count_in = 4 * beat;
|
||||
int repeat = 16;
|
||||
int repeat = 96;
|
||||
|
||||
|
||||
float voltrange = 5.0;
|
||||
|
@ -107,6 +91,8 @@ void setup(void) {
|
|||
seq1.duration = d1;
|
||||
seq1.len = sizeof(m1) / sizeof(m1[0]);
|
||||
|
||||
times_to_ms(seq1);
|
||||
|
||||
seq2.last = now;
|
||||
seq2.pitch = MCP4728_CHANNEL_C;
|
||||
seq2.gate = MCP4728_CHANNEL_D;
|
||||
|
@ -115,7 +101,6 @@ void setup(void) {
|
|||
seq2.start = s2;
|
||||
seq2.len = sizeof(m2) / sizeof(m2[0]);
|
||||
|
||||
times_to_ms(seq1);
|
||||
times_to_ms(seq2);
|
||||
|
||||
}
|
||||
|
@ -123,7 +108,7 @@ void setup(void) {
|
|||
void times_to_ms(sequencer& seq) {
|
||||
for( int i = 0; i < seq.len; i++ ) {
|
||||
seq.start[i] *= beat;
|
||||
seq.duration[i] = (float)beat * seq.duration[i];
|
||||
seq.duration[i] = (float)beat * seq.duration[i] * 0.8;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue