diff --git a/win/main.cpp b/win/main.cpp index 128e4c2..d3b0c6b 100644 --- a/win/main.cpp +++ b/win/main.cpp @@ -11,21 +11,21 @@ static inline uint8_t THREEQUARTERS(uint8_t x) return (x >> 2) + (x >> 1); } -int notes[37] = { 134, 142, 150, 159, 169, 179, 189, 201, 213, 225, 239, 253, 268, 284, 301, 319, 338, 358, 379, 401, 425, 451, 477, 506, 536, 568, 601, 637, 675, 715, 758, 803, 851, 901, 955, 1011, 1072 }; +const int notes[37] = { 134, 142, 150, 159, 169, 179, 189, 201, 213, 225, 239, 253, 268, 284, 301, 319, 338, 358, 379, 401, 425, 451, 477, 506, 536, 568, 601, 637, 675, 715, 758, 803, 851, 901, 955, 1011, 1072 }; -int arpeggio[][4] = { - { 12, 15, 19, 24 }, - { 15, 19, 22, 27 }, - { 10, 14, 17, 22 }, - { 8, 12, 15, 20 }, - { 12, 15, 17, 22 }, - { 12, 15, 17, 21 }, - { 17, 20, 24, 29 }, - { 14, 17, 22, 26 }, -// { 0, 2, 4, 7 }, -// { 0, 2, 4, 6 }, -// { 0, 2, 5, 9 }, -// { 0, 2, 5, 8 }, +const uint8_t arpnotes[] = { + 8, 10, 12, 14, 15, 17, 19, 20, 21, 22, 24, 26, 27, 29, +}; + +const uint16_t arpeggio[][2] = { + { 0x24, 0x6A }, + { 0x46, 0x9C }, + { 0x13, 0x59 }, + { 0x02, 0x47 }, + { 0x24, 0x59 }, + { 0x24, 0x58 }, + { 0x57, 0xAD }, + { 0x35, 0x9B } }; #define ARPSIZE 76 @@ -38,21 +38,21 @@ uint8_t arpseq1[4][8] = { { 3, 3, 2, 2, 0, 0, 4, 5, }, }; #else -uint8_t arpseq1[4][4] = { +const uint8_t arpseq1[4][4] = { { 0x00, 0x12, 0x00, 0x62 }, { 0x00, 0x12, 0x00, 0x17 }, { 0x00, 0x12, 0x00, 0x12 }, { 0x33, 0x22, 0x00, 0x45 }, }; #endif -int arpseq2[] = { 0, 1, 0, 1, 0, 1, 0, 2, 3, 3 }; +const int arpseq2[] = { 0, 1, 0, 1, 0, 1, 0, 2, 3, 3 }; //int arptiming[32] = { 4, 2, 4, 2, 4, 2, 4, 5, 1, 2, 2 } const uint32_t arptiming = B32(00001100,00110000,11111011,00001100); #define BASSSIZE ARPSIZE -int bassbeat[8] = { 0, 0, 1, 0, 0, 1, 0, 1 }; -int bassline[BASSSIZE] = { +const int bassbeat[8] = { 0, 0, 1, 0, 0, 1, 0, 1 }; +const int bassline[BASSSIZE] = { 12, 12, 15, 10, 12, 12, 17, 10, 12, 12, 15, 7, 8, 8, 3, 7, 12, 12, 15, 10, 12, 12, 17, 10, 12, 12, 15, 7, 8, 8, 3, 7, 12, 12, 15, 10, 12, 12, 17, 10, 12, 12, 15, 7, 8, 8, 3, 7, @@ -61,7 +61,7 @@ int bassline[BASSSIZE] = { }; #define LEADSIZE 159 -int leadmelody[LEADSIZE] = { 0, 0, 0, 0, +const int leadmelody[LEADSIZE] = { 0, 0, 0, 0, 12, 7, 0, 12, 0, 14, 15, 0, 14, 0, 12, 0, 14, 15, 0, 14, 0, 12, 0, 14, 10, 0, 7, 5, 7, 3, 1, 0, 12, 7, 0, 12, 0, 14, 15, 0, 14, 0, 12, 0, 14, 15, 0, 14, 0, 15, 0, 17, 19, 0, 22, 24, 26, 27, 24, 0, 12, 7, 0, 12, 0, 14, 15, 0, 14, 0, 12, 0, 14, 15, 0, 14, 0, 12, 0, 14, 10, 0, 7, 5, 7, 3, 1, 0, @@ -69,7 +69,7 @@ int leadmelody[LEADSIZE] = { 0, 0, 0, 0, 8, 3, 0, 8, 10, 12, 14, 15, 19, 17, 0, 12, 7, 0, 12, 14, 15, 14, 15, 19, 17, 0, 8, 3, 0, 8, 10, 12, 14, 15, 19, 17, 15, 0, 14, 15, 17, 19, 0, 15, 14, 15, 12, }; -int leadtiming[LEADSIZE] = { 0, 62, 200, 250, +const int leadtiming[LEADSIZE] = { 0, 62, 200, 250, 4, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 4, 2, 4, 4, 2, 4, 6, 56, 4, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 4, 2, 4, 4, 2, 4, 6, 56, 4, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 2, 4, 2, 4, 4, 2, 4, 6, 56, @@ -123,11 +123,13 @@ static inline unsigned char voice_arp(unsigned long i) static uint16_t arp_osc = 0; uint8_t arpptr = i >> 13; uint8_t arpptr2 = arpseq1[arpseq2[arpptr >> 3]][(arpptr >> 1) & 3]; - if (arpptr & 1) - arpptr2 &= 0xF; - else + if (!(arpptr & 1)) arpptr2 >>= 4; - int note = notes[arpeggio[arpptr2][(i >> 7) & 3]]; + arpptr = arpeggio[arpptr2 & 0xF][(i >> 8) & 1]; + if (!(i & 0x80)) + arpptr >>= 4; + + int note = notes[arpnotes[arpptr & 0xF]]; arp_osc += note; return ((arptiming & (1 << (31 - (i >> 9)))) && (arp_osc & (1 << 12)) && ((i >> 13) > 15)) ? 0 : 140; //return ((arp_osc >> 5) & 128) - 1;