80 #define N_CS6 1108.73f
82 #define N_DS6 1244.51f
85 #define N_FS6 1479.89f
87 #define N_GS6 1661.22f
89 #define N_AS6 1864.66f
92 #define N_CS7 2217.46f
94 #define N_DS7 2489.02f
97 #define N_FS7 2959.96f
99 #define N_GS7 3322.44f
100 #define N_A7 3520.00f
101 #define N_AS7 3729.31f
102 #define N_B7 3951.07f
103 #define N_C8 4186.01f
104 #define N_CS8 4434.92f
105 #define N_D8 4698.63f
106 #define N_DS8 4978.03f
107 #define N_E8 5274.04f
108 #define N_F8 5587.65f
109 #define N_FS8 5919.91f
110 #define N_G8 6271.93f
111 #define N_GS8 6644.88f
112 #define N_A8 7040.00f
113 #define N_AS8 7458.62f
114 #define N_B8 7902.13f
128 enum MusicalNotesEnum {C, CS, D, DS, E, F,
FS, G, GS, A, AS, B};
132 if (
note>11)
return 0;
133 if (octave>8)
return 0;
134 return notes[octave][
note];
140 uint8_t octave = idx / 12;
144 int frequencyCount()
const {
150 if (mainNoteIdx>6)
return 0;
151 static int mainNotes[] = {0,2,4,5,7,9,11};
158 uint8_t mainNote = idx % 7;
159 uint8_t level = idx /7;
170 float* all_notes = (
float*) notes;
171 const int note_count = 12*9;
176 for (
int j=0; j<note_count; j++){
184 float noteFrequency = all_notes[min_pos];
186 return notes_str[min_pos];
197 return notes_str[idx];
203 return (a / 32) * pow(2, ((x - 9) / 12.0f));
208 return log(freq/440.0f)/log(2) * 12.0f + 69.0f;
211 float stkNoteToFrequency(
int noteNumber)
const {
212 return 220.0f * pow( 2.0f, (noteNumber - 57.0f) / 12.0f );
217 float notes[9][12] = {
218 {N_C0, N_CS0, N_D0, N_DS0, N_E0, N_F0, N_FS0, N_G0, N_GS0, N_A0, N_AS0, N_B0},
219 {N_C1, N_CS1, N_D1, N_DS1, N_E1, N_F1, N_FS1, N_G1, N_GS1, N_A1, N_AS1, N_B1},
220 {N_C2, N_CS2, N_D2, N_DS2, N_E2, N_F2, N_FS2, N_G2, N_GS2, N_A2, N_AS2, N_B2},
221 {N_C3, N_CS3, N_D3, N_DS3, N_E3, N_F3, N_FS3, N_G3, N_GS3, N_A3, N_AS3, N_B3},
222 {N_C4, N_CS4, N_D4, N_DS4, N_E4, N_F4, N_FS4, N_G4, N_GS4, N_A4, N_AS4, N_B4},
223 {N_C5, N_CS5, N_D5, N_DS5, N_E5, N_F5, N_FS5, N_G5, N_GS5, N_A5, N_AS5, N_B5},
224 {N_C6, N_CS6, N_D6, N_DS6, N_E6, N_F6, N_FS6, N_G6, N_GS6, N_A6, N_AS6, N_B6},
225 {N_C7, N_CS7, N_D7, N_DS7, N_E7, N_F7, N_FS7, N_G7, N_GS7, N_A7, N_AS7, N_B7},
226 {N_C8, N_CS8, N_D8, N_DS8, N_E8, N_F8, N_FS8, N_G8, N_GS8, N_A8, N_AS8, N_B8}
229 const char *notes_str[9*12]= {
230 "C0",
"CS0",
"D0",
"DS0",
"E0",
"F0",
"FS0",
"G0",
"GS0",
"A0",
"AS0",
"B0",
231 "C1",
"CS1",
"D1",
"DS1",
"E1",
"F1",
"FS1",
"G1",
"GS1",
"A1",
"AS1",
"B1",
232 "C2",
"CS2",
"D2",
"DS2",
"E2",
"F2",
"FS2",
"G2",
"GS2",
"A2",
"AS2",
"B2",
233 "C3",
"CS3",
"D3",
"DS3",
"E3",
"F3",
"FS3",
"G3",
"GS3",
"A3",
"AS3",
"B3",
234 "C4",
"CS4",
"D4",
"DS4",
"E4",
"F4",
"FS4",
"G4",
"GS4",
"A4",
"AS4",
"B4",
235 "C5",
"CS5",
"D5",
"DS5",
"E5",
"F5",
"FS5",
"G5",
"GS5",
"A5",
"AS5",
"B5",
236 "C6",
"CS6",
"D6",
"DS6",
"E6",
"F6",
"FS6",
"G6",
"GS6",
"A6",
"AS6",
"B6",
237 "C7",
"CS7",
"D7",
"DS7",
"E7",
"F7",
"FS7",
"G7",
"GS7",
"A7",
"AS7",
"B7",
238 "C8",
"CS8",
"D8",
"DS8",
"E8",
"F8",
"FS8",
"G8",
"GS8",
"A8",
"AS8",
"B8"