neoGFX
Cross-platform C++ app/game engine
Loading...
Searching...
No Matches
audio_primitives.hpp
Go to the documentation of this file.
1// audio_primitives.hpp
2/*
3 neogfx C++ App/Game Engine
4 Copyright (c) 2021 Leigh Johnston. All Rights Reserved.
5
6 This program is free software: you can redistribute it and / or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
18*/
19
20#include <neogfx/neogfx.hpp>
21#include <array>
22#include <bit>
23
24#pragma once
25
26namespace neogfx
27{
28 enum class note : std::uint32_t
29 {
30 MIDI0 = 0,
31 MIDI1 = 1,
32 MIDI2 = 2,
33 MIDI3 = 3,
34 MIDI4 = 4,
35 MIDI5 = 5,
36 MIDI6 = 6,
37 MIDI7 = 7,
38 MIDI8 = 8,
39 MIDI9 = 9,
40 MIDI10 = 10,
41 MIDI11 = 11,
42 MIDI12 = 12,
43 MIDI13 = 13,
44 MIDI14 = 14,
45 MIDI15 = 15,
46 MIDI16 = 16,
47 MIDI17 = 17,
48 MIDI18 = 18,
49 MIDI19 = 19,
50 MIDI20 = 20,
51
52 A0 = 21,
53 Bb0 = 22,
54 B0 = 23,
55 C1 = 24,
56 Db1 = 25,
57 D1 = 26,
58 Eb1 = 27,
59 E1 = 28,
60 F1 = 29,
61 Gb1 = 30,
62 G1 = 31,
63 Ab1 = 32,
64 A1 = 33,
65 Bb1 = 34,
66 B1 = 35,
67 C2 = 36,
68 Db2 = 37,
69 D2 = 38,
70 Eb2 = 39,
71 E2 = 40,
72 F2 = 41,
73 Gb2 = 42,
74 G2 = 43,
75 Ab2 = 44,
76 A2 = 45,
77 Bb2 = 46,
78 B2 = 47,
79 C3 = 48,
80 Db3 = 49,
81 D3 = 50,
82 Eb3 = 51,
83 E3 = 52,
84 F3 = 53,
85 Gb3 = 54,
86 G3 = 55,
87 Ab3 = 56,
88 A3 = 57,
89 Bb3 = 58,
90 B3 = 59,
91 C4 = 60,
92 Db4 = 61,
93 D4 = 62,
94 Eb4 = 63,
95 E4 = 64,
96 F4 = 65,
97 Gb4 = 66,
98 G4 = 67,
99 Ab4 = 68,
100 A4 = 69,
101 Bb4 = 70,
102 B4 = 71,
103 C5 = 72,
104 Db5 = 73,
105 D5 = 74,
106 Eb5 = 75,
107 E5 = 76,
108 F5 = 77,
109 Gb5 = 78,
110 G5 = 79,
111 Ab5 = 80,
112 A5 = 81,
113 Bb5 = 82,
114 B5 = 83,
115 C6 = 84,
116 Db6 = 85,
117 D6 = 86,
118 Eb6 = 87,
119 E6 = 88,
120 F6 = 89,
121 Gb6 = 90,
122 G6 = 91,
123 Ab6 = 92,
124 A6 = 93,
125 Bb6 = 94,
126 B6 = 95,
127 C7 = 96,
128 Db7 = 97,
129 D7 = 98,
130 Eb7 = 99,
131 E7 = 100,
132 F7 = 101,
133 Gb7 = 102,
134 G7 = 103,
135 Ab7 = 104,
136 A7 = 105,
137 Bb7 = 106,
138 B7 = 107,
139 C8 = 108,
140 Db8 = 109,
141 D8 = 110,
142 Eb8 = 111,
143 E8 = 112,
144 F8 = 113,
145 Gb8 = 114,
146 G8 = 115,
147 Ab8 = 116,
148 A8 = 117,
149 Bb8 = 118,
150 B8 = 119,
151 C9 = 120,
152 Db9 = 121,
153 D9 = 122,
154 Eb9 = 123,
155 E9 = 124,
156 F9 = 125,
157 Gb9 = 126,
158 G9 = 127,
159 Ab9 = 128
160 };
161
162 inline std::string to_string(note const& aNote)
163 {
164 static std::unordered_map<note, std::string> const sMap =
165 {
166 { note::MIDI0 , "MIDI0" },
167 { note::MIDI1 , "MIDI1" },
168 { note::MIDI2 , "MIDI2" },
169 { note::MIDI3 , "MIDI3" },
170 { note::MIDI4 , "MIDI4" },
171 { note::MIDI5 , "MIDI5" },
172 { note::MIDI6 , "MIDI6" },
173 { note::MIDI7 , "MIDI7" },
174 { note::MIDI8 , "MIDI8" },
175 { note::MIDI9 , "MIDI9" },
176 { note::MIDI10 , "MIDI10" },
177 { note::MIDI11 , "MIDI11" },
178 { note::MIDI12 , "MIDI12" },
179 { note::MIDI13 , "MIDI13" },
180 { note::MIDI14 , "MIDI14" },
181 { note::MIDI15 , "MIDI15" },
182 { note::MIDI16 , "MIDI16" },
183 { note::MIDI17 , "MIDI17" },
184 { note::MIDI18 , "MIDI18" },
185 { note::MIDI19 , "MIDI19" },
186 { note::MIDI20 , "MIDI20" },
187
188 { note::A0 , "A0" },
189 { note::Bb0 , "Bb0" },
190 { note::B0 , "B0" },
191 { note::C1 , "C1" },
192 { note::Db1 , "Db1" },
193 { note::D1 , "D1" },
194 { note::Eb1 , "Eb1" },
195 { note::E1 , "E1" },
196 { note::F1 , "F1" },
197 { note::Gb1 , "Gb1" },
198 { note::G1 , "G1" },
199 { note::Ab1 , "Ab1" },
200 { note::A1 , "A1" },
201 { note::Bb1 , "Bb1" },
202 { note::B1 , "B1" },
203 { note::C2 , "C2" },
204 { note::Db2 , "Db2" },
205 { note::D2 , "D2" },
206 { note::Eb2 , "Eb2" },
207 { note::E2 , "E2" },
208 { note::F2 , "F2" },
209 { note::Gb2 , "Gb2" },
210 { note::G2 , "G2" },
211 { note::Ab2 , "Ab2" },
212 { note::A2 , "A2" },
213 { note::Bb2 , "Bb2" },
214 { note::B2 , "B2" },
215 { note::C3 , "C3" },
216 { note::Db3 , "Db3" },
217 { note::D3 , "D3" },
218 { note::Eb3 , "Eb3" },
219 { note::E3 , "E3" },
220 { note::F3 , "F3" },
221 { note::Gb3 , "Gb3" },
222 { note::G3 , "G3" },
223 { note::Ab3 , "Ab3" },
224 { note::A3 , "A3" },
225 { note::Bb3 , "Bb3" },
226 { note::B3 , "B3" },
227 { note::C4 , "C4" },
228 { note::Db4 , "Db4" },
229 { note::D4 , "D4" },
230 { note::Eb4 , "Eb4" },
231 { note::E4 , "E4" },
232 { note::F4 , "F4" },
233 { note::Gb4 , "Gb4" },
234 { note::G4 , "G4" },
235 { note::Ab4 , "Ab4" },
236 { note::A4 , "A4" },
237 { note::Bb4 , "Bb4" },
238 { note::B4 , "B4" },
239 { note::C5 , "C5" },
240 { note::Db5 , "Db5" },
241 { note::D5 , "D5" },
242 { note::Eb5 , "Eb5" },
243 { note::E5 , "E5" },
244 { note::F5 , "F5" },
245 { note::Gb5 , "Gb5" },
246 { note::G5 , "G5" },
247 { note::Ab5 , "Ab5" },
248 { note::A5 , "A5" },
249 { note::Bb5 , "Bb5" },
250 { note::B5 , "B5" },
251 { note::C6 , "C6" },
252 { note::Db6 , "Db6" },
253 { note::D6 , "D6" },
254 { note::Eb6 , "Eb6" },
255 { note::E6 , "E6" },
256 { note::F6 , "F6" },
257 { note::Gb6 , "Gb6" },
258 { note::G6 , "G6" },
259 { note::Ab6 , "Ab6" },
260 { note::A6 , "A6" },
261 { note::Bb6 , "Bb6" },
262 { note::B6 , "B6" },
263 { note::C7 , "C7" },
264 { note::Db7 , "Db7" },
265 { note::D7 , "D7" },
266 { note::Eb7 , "Eb7" },
267 { note::E7 , "E7" },
268 { note::F7 , "F7" },
269 { note::Gb7 , "Gb7" },
270 { note::G7 , "G7" },
271 { note::Ab7 , "Ab7" },
272 { note::A7 , "A7" },
273 { note::Bb7 , "Bb7" },
274 { note::B7 , "B7" },
275 { note::C8 , "C8" },
276 { note::Db8 , "Db8" },
277 { note::D8 , "D8" },
278 { note::Eb8 , "Eb8" },
279 { note::E8 , "E8" },
280 { note::F8 , "F8" },
281 { note::Gb8 , "Gb8" },
282 { note::G8 , "G8" },
283 { note::Ab8 , "Ab8" },
284 { note::A8 , "A8" },
285 { note::Bb8 , "Bb8" },
286 { note::B8 , "B8" },
287 { note::C9 , "C9" },
288 { note::Db9 , "Db9" },
289 { note::D9 , "D9" },
290 { note::Eb9 , "Eb9" },
291 { note::E9 , "E9" },
292 { note::F9 , "F9" },
293 { note::Gb9 , "Gb9" },
294 { note::G9 , "G9" },
295 { note::Ab9 , "Ab9" }
296 };
297
298 return sMap.at(aNote);
299 }
300
301 inline note string_to_note(std::string const& aNote)
302 {
303 if (std::isdigit(aNote.at(0)))
304 return static_cast<note>(boost::lexical_cast<std::uint32_t>(aNote));
305
306 static std::unordered_map<std::string, note> const sMap =
307 {
308 { "A0" , note::A0 },
309 { "A#0", note::Bb0 },
310 { "Bb0", note::Bb0 },
311 { "B0" , note::B0 },
312 { "C1" , note::C1 },
313 { "C#1", note::Db1 },
314 { "Db1", note::Db1 },
315 { "D1" , note::D1 },
316 { "D#1", note::Eb1 },
317 { "Eb1", note::Eb1 },
318 { "E1" , note::E1 },
319 { "F1" , note::F1 },
320 { "F#1", note::Gb1 },
321 { "Gb1", note::Gb1 },
322 { "G1" , note::G1 },
323 { "G#1", note::Ab1 },
324 { "Ab1", note::Ab1 },
325 { "A1" , note::A1 },
326 { "A#1", note::Bb1 },
327 { "Bb1", note::Bb1 },
328 { "B1" , note::B1 },
329 { "C2" , note::C2 },
330 { "C#2", note::Db2 },
331 { "Db2", note::Db2 },
332 { "D2" , note::D2 },
333 { "D#2", note::Eb2 },
334 { "Eb2", note::Eb2 },
335 { "E2" , note::E2 },
336 { "F2" , note::F2 },
337 { "F#2", note::Gb2 },
338 { "Gb2", note::Gb2 },
339 { "G2" , note::G2 },
340 { "G#2", note::Ab2 },
341 { "Ab2", note::Ab2 },
342 { "A2" , note::A2 },
343 { "A#2", note::Bb2 },
344 { "Bb2", note::Bb2 },
345 { "B2" , note::B2 },
346 { "C3" , note::C3 },
347 { "C#3", note::Db3 },
348 { "Db3", note::Db3 },
349 { "D3" , note::D3 },
350 { "D#3", note::Eb3 },
351 { "Eb3", note::Eb3 },
352 { "E3" , note::E3 },
353 { "F3" , note::F3 },
354 { "F#3", note::Gb3 },
355 { "Gb3", note::Gb3 },
356 { "G3" , note::G3 },
357 { "G#3", note::Ab3 },
358 { "Ab3", note::Ab3 },
359 { "A3" , note::A3 },
360 { "A#3", note::Bb3 },
361 { "Bb3", note::Bb3 },
362 { "B3" , note::B3 },
363 { "C4" , note::C4 },
364 { "C#4", note::Db4 },
365 { "Db4", note::Db4 },
366 { "D4" , note::D4 },
367 { "D#4", note::Eb4 },
368 { "Eb4", note::Eb4 },
369 { "E4" , note::E4 },
370 { "F4" , note::F4 },
371 { "F#4", note::Gb4 },
372 { "Gb4", note::Gb4 },
373 { "G4" , note::G4 },
374 { "G#4", note::Ab4 },
375 { "Ab4", note::Ab4 },
376 { "A4" , note::A4 },
377 { "A#4", note::Bb4 },
378 { "Bb4", note::Bb4 },
379 { "B4" , note::B4 },
380 { "C5" , note::C5 },
381 { "C#5", note::Db5 },
382 { "Db5", note::Db5 },
383 { "D5" , note::D5 },
384 { "D#5", note::Eb5 },
385 { "Eb5", note::Eb5 },
386 { "E5" , note::E5 },
387 { "F5" , note::F5 },
388 { "F#5", note::Gb5 },
389 { "Gb5", note::Gb5 },
390 { "G5" , note::G5 },
391 { "G#5", note::Ab5 },
392 { "Ab5", note::Ab5 },
393 { "A5" , note::A5 },
394 { "A#5", note::Bb5 },
395 { "Bb5", note::Bb5 },
396 { "B5" , note::B5 },
397 { "C6" , note::C6 },
398 { "C#6", note::Db6 },
399 { "Db6", note::Db6 },
400 { "D6" , note::D6 },
401 { "D#6", note::Eb6 },
402 { "Eb6", note::Eb6 },
403 { "E6" , note::E6 },
404 { "F6" , note::F6 },
405 { "F#6", note::Gb6 },
406 { "Gb6", note::Gb6 },
407 { "G6" , note::G6 },
408 { "G#6", note::Ab6 },
409 { "Ab6", note::Ab6 },
410 { "A6" , note::A6 },
411 { "A#6", note::Bb6 },
412 { "Bb6", note::Bb6 },
413 { "B6" , note::B6 },
414 { "C7" , note::C7 },
415 { "C#7", note::Db7 },
416 { "Db7", note::Db7 },
417 { "D7" , note::D7 },
418 { "D#7", note::Eb7 },
419 { "Eb7", note::Eb7 },
420 { "E7" , note::E7 },
421 { "F7" , note::F7 },
422 { "F#7", note::Gb7 },
423 { "Gb7", note::Gb7 },
424 { "G7" , note::G7 },
425 { "G#7", note::Ab7 },
426 { "Ab7", note::Ab7 },
427 { "A7" , note::A7 },
428 { "A#7", note::Bb7 },
429 { "Bb7", note::Bb7 },
430 { "B7" , note::B7 },
431 { "C8" , note::C8 },
432 { "C#8", note::Db8 },
433 { "Db8", note::Db8 },
434 { "D8" , note::D8 },
435 { "D#8", note::Eb8 },
436 { "Eb8", note::Eb8 },
437 { "E8" , note::E8 },
438 { "F8" , note::F8 },
439 { "F#8", note::Gb8 },
440 { "Gb8", note::Gb8 },
441 { "G8" , note::G8 },
442 { "G#8", note::Ab8 },
443 { "Ab8", note::Ab8 },
444 { "A8" , note::A8 },
445 { "A#8", note::Bb8 },
446 { "Bb8", note::Bb8 },
447 { "B8" , note::B8 },
448 { "C9" , note::C9 },
449 { "C#9", note::Db9 },
450 { "Db9", note::Db9 },
451 { "D9" , note::D9 },
452 { "D#9", note::Eb9 },
453 { "Eb9", note::Eb9 },
454 { "E9" , note::E9 },
455 { "F9" , note::F9 },
456 { "F#9", note::Gb9 },
457 { "Gb9", note::Gb9 },
458 { "G9" , note::G9 },
459 { "G#9", note::Ab9 },
460 { "Ab9", note::Ab9 }
461 };
462
463 return sMap.at(aNote);
464 }
465
467 {
468 return std::pow(2.0f, (static_cast<float>(note) - 69.0f) / 12.0f) * 440.0f;
469 }
470
471 template <neogfx::note Note>
472 inline float frequency()
473 {
474 return frequency(Note);
475 }
476
477 enum class instrument : std::uint32_t
478 {
479 PureTone = 0,
483 HonkytonkPiano = 4,
484 ElectricPiano1 = 5,
485 ElectricPiano2 = 6,
486 Harpsichord = 7,
487 Clavi = 8,
488 Celesta = 9,
489 Glockenspiel = 10,
490 MusicBox = 11,
491 Vibraphone = 12,
492 Marimba = 13,
493 Xylophone = 14,
494 TubularBells = 15,
495 Dulcimer = 16,
496 DrawbarOrgan = 17,
497 PercussiveOrgan = 18,
498 RockOrgan = 19,
499 ChurchOrgan = 20,
500 ReedOrgan = 21,
501 Accordion = 22,
502 Harmonica = 23,
503 TangoAccordion = 24,
509 OverdrivenGuitar = 30,
510 DistortionGuitar = 31,
511 Guitarharmonics = 32,
512 AcousticBass = 33,
514 ElectricBassPick = 35,
515 FretlessBass = 36,
516 SlapBass1 = 37,
517 SlapBass2 = 38,
518 SynthBass1 = 39,
519 SynthBass2 = 40,
520 Violin = 41,
521 Viola = 42,
522 Cello = 43,
523 Contrabass = 44,
524 TremoloStrings = 45,
525 PizzicatoStrings = 46,
526 OrchestralHarp = 47,
527 Timpani = 48,
528 StringEnsemble1 = 49,
529 StringEnsemble2 = 50,
530 SynthStrings1 = 51,
531 SynthStrings2 = 52,
532 ChoirAahs = 53,
533 VoiceOohs = 54,
534 SynthVoice = 55,
535 OrchestraHit = 56,
536 Trumpet = 57,
537 Trombone = 58,
538 Tuba = 59,
539 MutedTrumpet = 60,
540 FrenchHorn = 61,
541 BrassSection = 62,
542 SynthBrass1 = 63,
543 SynthBrass2 = 64,
544 SopranoSax = 65,
545 AltoSax = 66,
546 TenorSax = 67,
547 BaritoneSax = 68,
548 Oboe = 69,
549 EnglishHorn = 70,
550 Bassoon = 71,
551 Clarinet = 72,
552 Piccolo = 73,
553 Flute = 74,
554 Recorder = 75,
555 PanFlute = 76,
556 BlownBottle = 77,
557 Shakuhachi = 78,
558 Whistle = 79,
559 Ocarina = 80,
560 Lead1 = 81,
561 Lead2 = 82,
562 Lead3 = 83,
563 Lead4 = 84,
564 Lead5 = 85,
565 Lead6 = 86,
566 Lead7 = 87,
567 Lead8 = 88,
568 Pad1 = 89,
569 Pad2 = 90,
570 Pad3 = 91,
571 Pad4 = 92,
572 Pad5 = 93,
573 Pad6 = 94,
574 Pad7 = 95,
575 Pad8 = 96,
576 FX1 = 97,
577 FX2 = 98,
578 FX3 = 99,
579 FX4 = 100,
580 FX5 = 101,
581 FX6 = 102,
582 FX7 = 103,
583 FX8 = 104,
584 Sitar = 105,
585 Banjo = 106,
586 Shamisen = 107,
587 Koto = 108,
588 Kalimba = 109,
589 Bagpipe = 110,
590 Fiddle = 111,
591 Shanai = 112,
592 TinkleBell = 113,
593 Agogo = 114,
594 SteelDrums = 115,
595 Woodblock = 116,
596 TaikoDrum = 117,
597 MelodicTom = 118,
598 SynthDrum = 119,
599 ReverseCymbal = 120,
600 GuitarFretNoise = 121,
601 BreathNoise = 122,
602 Seashore = 123,
603 BirdTweet = 124,
604 TelephoneRing = 125,
605 Helicopter = 126,
606 Applause = 127,
607 Gunshot = 128
608 };
609
611 {
612 AcousticBassDrum = 35,
613 BassDrum1 = 36,
614 SideStick = 37,
615 AcousticSnare = 38,
616 HandClap = 39,
617 ElectricSnare = 40,
618 LowFloorTom = 41,
619 ClosedHiHat = 42,
620 HighFloorTom = 43,
621 PedalHiHat = 44,
622 LowTom = 45,
623 OpenHiHat = 46,
624 LowMidTom = 47,
625 HiMidTom = 48,
626 CrashCymbal1 = 49,
627 HighTom = 50,
628 RideCymbal1 = 51,
629 ChineseCymbal = 52,
630 RideBell = 53,
631 Tambourine = 54,
632 SplashCymbal = 55,
633 Cowbell = 56,
634 CrashCymbal2 = 57,
635 Vibraslap = 58,
636 RideCymbal2 = 59,
637 HiBongo = 60,
638 LowBongo = 61,
639 MuteHiConga = 62,
640 OpenHiConga = 63,
641 LowConga = 64,
642 HighTimbale = 65,
643 LowTimbale = 66,
644 HighAgogo = 67,
645 LowAgogo = 68,
646 Cabasa = 69,
647 Maracas = 70,
648 ShortWhistle = 71,
649 LongWhistle = 72,
650 ShortGuiro = 73,
651 LongGuiro = 74,
652 Claves = 75,
653 HiWoodBlock = 76,
654 LowWoodBlock = 77,
655 MuteCuica = 78,
656 OpenCuica = 79,
657 MuteTriangle = 80,
658 OpenTriangle = 81
659 };
660
662 {
663 static std::unordered_map<neogfx::instrument, std::string> const sMap =
664 {
665 { neogfx::instrument::AcousticGrandPiano, "Acoustic Grand Piano" },
666 { neogfx::instrument::BrightAcousticPiano, "Bright Acoustic Piano" },
667 { neogfx::instrument::ElectricGrandPiano, "Electric Grand Piano" },
668 { neogfx::instrument::HonkytonkPiano, "Honky - tonk Piano" },
669 { neogfx::instrument::ElectricPiano1, "Electric Piano 1" },
670 { neogfx::instrument::ElectricPiano2, "Electric Piano 2" },
671 { neogfx::instrument::Harpsichord, "Harpsichord" },
672 { neogfx::instrument::Clavi, "Clavi" },
673 { neogfx::instrument::Celesta, "Celesta" },
674 { neogfx::instrument::Glockenspiel, "Glockenspiel" },
675 { neogfx::instrument::MusicBox, "Music Box" },
676 { neogfx::instrument::Vibraphone, "Vibraphone" },
677 { neogfx::instrument::Marimba, "Marimba" },
678 { neogfx::instrument::Xylophone, "Xylophone" },
679 { neogfx::instrument::TubularBells, "Tubular Bells" },
680 { neogfx::instrument::Dulcimer, "Dulcimer" },
681 { neogfx::instrument::DrawbarOrgan, "Drawbar Organ" },
682 { neogfx::instrument::PercussiveOrgan, "Percussive Organ" },
683 { neogfx::instrument::RockOrgan, "Rock Organ" },
684 { neogfx::instrument::ChurchOrgan, "Church Organ" },
685 { neogfx::instrument::ReedOrgan, "Reed Organ" },
686 { neogfx::instrument::Accordion, "Accordion" },
687 { neogfx::instrument::Harmonica, "Harmonica" },
688 { neogfx::instrument::TangoAccordion, "Tango Accordion" },
689 { neogfx::instrument::AcousticGuitarNylon, "Acoustic Guitar(nylon)" },
690 { neogfx::instrument::AcousticGuitarSteel, "Acoustic Guitar(steel)" },
691 { neogfx::instrument::ElectricGuitarJazz, "Electric Guitar(jazz)" },
692 { neogfx::instrument::ElectricGuitarClean, "Electric Guitar(clean)" },
693 { neogfx::instrument::ElectricGuitarMuted, "Electric Guitar(muted)" },
694 { neogfx::instrument::OverdrivenGuitar, "Overdriven Guitar" },
695 { neogfx::instrument::DistortionGuitar, "Distortion Guitar" },
696 { neogfx::instrument::Guitarharmonics, "Guitar harmonics" },
697 { neogfx::instrument::AcousticBass, "Acoustic Bass" },
698 { neogfx::instrument::ElectricBassFinger, "Electric Bass(finger)" },
699 { neogfx::instrument::ElectricBassPick, "Electric Bass(pick)" },
700 { neogfx::instrument::FretlessBass, "Fretless Bass" },
701 { neogfx::instrument::SlapBass1, "Slap Bass 1" },
702 { neogfx::instrument::SlapBass2, "Slap Bass 2" },
703 { neogfx::instrument::SynthBass1, "Synth Bass 1" },
704 { neogfx::instrument::SynthBass2, "Synth Bass 2" },
705 { neogfx::instrument::Violin, "Violin" },
706 { neogfx::instrument::Viola, "Viola" },
707 { neogfx::instrument::Cello, "Cello" },
708 { neogfx::instrument::Contrabass, "Contrabass" },
709 { neogfx::instrument::TremoloStrings, "Tremolo Strings" },
710 { neogfx::instrument::PizzicatoStrings, "Pizzicato Strings" },
711 { neogfx::instrument::OrchestralHarp, "Orchestral Harp" },
712 { neogfx::instrument::Timpani, "Timpani" },
713 { neogfx::instrument::StringEnsemble1, "String Ensemble 1" },
714 { neogfx::instrument::StringEnsemble2, "String Ensemble 2" },
715 { neogfx::instrument::SynthStrings1, "SynthStrings 1" },
716 { neogfx::instrument::SynthStrings2, "SynthStrings 2" },
717 { neogfx::instrument::ChoirAahs, "Choir Aahs" },
718 { neogfx::instrument::VoiceOohs, "Voice Oohs" },
719 { neogfx::instrument::SynthVoice, "Synth Voice" },
720 { neogfx::instrument::OrchestraHit, "Orchestra Hit" },
721 { neogfx::instrument::Trumpet, "Trumpet" },
722 { neogfx::instrument::Trombone, "Trombone" },
723 { neogfx::instrument::Tuba, "Tuba" },
724 { neogfx::instrument::MutedTrumpet, "Muted Trumpet" },
725 { neogfx::instrument::FrenchHorn, "French Horn" },
726 { neogfx::instrument::BrassSection, "Brass Section" },
727 { neogfx::instrument::SynthBrass1, "SynthBrass 1" },
728 { neogfx::instrument::SynthBrass2, "SynthBrass 2" },
729 { neogfx::instrument::SopranoSax, "Soprano Sax" },
730 { neogfx::instrument::AltoSax, "Alto Sax" },
731 { neogfx::instrument::TenorSax, "Tenor Sax" },
732 { neogfx::instrument::BaritoneSax, "Baritone Sax" },
733 { neogfx::instrument::Oboe, "Oboe" },
734 { neogfx::instrument::EnglishHorn, "English Horn" },
735 { neogfx::instrument::Bassoon, "Bassoon" },
736 { neogfx::instrument::Clarinet, "Clarinet" },
737 { neogfx::instrument::Piccolo, "Piccolo" },
738 { neogfx::instrument::Flute, "Flute" },
739 { neogfx::instrument::Recorder, "Recorder" },
740 { neogfx::instrument::PanFlute, "Pan Flute" },
741 { neogfx::instrument::BlownBottle, "Blown Bottle" },
742 { neogfx::instrument::Shakuhachi, "Shakuhachi" },
743 { neogfx::instrument::Whistle, "Whistle" },
744 { neogfx::instrument::Ocarina, "Ocarina" },
745 { neogfx::instrument::Lead1, "Lead 1 (square)" },
746 { neogfx::instrument::Lead2, "Lead 2 (sawtooth)" },
747 { neogfx::instrument::Lead3, "Lead 3 (calliope)" },
748 { neogfx::instrument::Lead4, "Lead 4 (chiff)" },
749 { neogfx::instrument::Lead5, "Lead 5 (charang)" },
750 { neogfx::instrument::Lead6, "Lead 6 (voice)" },
751 { neogfx::instrument::Lead7, "Lead 7 (fifths)" },
752 { neogfx::instrument::Lead8, "Lead 8 (bass + lead)" },
753 { neogfx::instrument::Pad1, "Pad 1 (new age)" },
754 { neogfx::instrument::Pad2, "Pad 2 (warm)" },
755 { neogfx::instrument::Pad3, "Pad 3 (polysynth)" },
756 { neogfx::instrument::Pad4, "Pad 4 (choir)" },
757 { neogfx::instrument::Pad5, "Pad 5 (bowed)" },
758 { neogfx::instrument::Pad6, "Pad 6 (metallic)" },
759 { neogfx::instrument::Pad7, "Pad 7 (halo)" },
760 { neogfx::instrument::Pad8, "Pad 8 (sweep)" },
761 { neogfx::instrument::FX1, "FX 1 (rain)" },
762 { neogfx::instrument::FX2, "FX 2 (soundtrack)" },
763 { neogfx::instrument::FX3, "FX 3 (crystal)" },
764 { neogfx::instrument::FX4, "FX 4 (atmosphere)" },
765 { neogfx::instrument::FX5, "FX 5 (brightness)" },
766 { neogfx::instrument::FX6, "FX 6 (goblins)" },
767 { neogfx::instrument::FX7, "FX 7 (echoes)" },
768 { neogfx::instrument::FX8, "FX 8 (sci - fi)" },
769 { neogfx::instrument::Sitar, "Sitar" },
770 { neogfx::instrument::Banjo, "Banjo" },
771 { neogfx::instrument::Shamisen, "Shamisen" },
772 { neogfx::instrument::Koto, "Koto" },
773 { neogfx::instrument::Kalimba, "Kalimba" },
774 { neogfx::instrument::Bagpipe, "Bag pipe" },
775 { neogfx::instrument::Fiddle, "Fiddle" },
776 { neogfx::instrument::Shanai, "Shanai" },
777 { neogfx::instrument::TinkleBell, "Tinkle Bell" },
778 { neogfx::instrument::Agogo, "Agogo" },
779 { neogfx::instrument::SteelDrums, "Steel Drums" },
780 { neogfx::instrument::Woodblock, "Woodblock" },
781 { neogfx::instrument::TaikoDrum, "Taiko Drum" },
782 { neogfx::instrument::MelodicTom, "Melodic Tom" },
783 { neogfx::instrument::SynthDrum, "Synth Drum" },
784 { neogfx::instrument::ReverseCymbal, "Reverse Cymbal" },
785 { neogfx::instrument::GuitarFretNoise, "Guitar Fret Noise" },
786 { neogfx::instrument::BreathNoise, "Breath Noise" },
787 { neogfx::instrument::Seashore, "Seashore" },
788 { neogfx::instrument::BirdTweet, "Bird Tweet" },
789 { neogfx::instrument::TelephoneRing, "Telephone Ring" },
790 { neogfx::instrument::Helicopter, "Helicopter" },
791 { neogfx::instrument::Applause, "Applause" },
792 { neogfx::instrument::Gunshot, "Gunshot" }
793 };
794
795 return sMap.at(instrument);
796 }
797
799 {
800 static std::unordered_map<percussion_instrument, std::string> const sMap =
801 {
802 { neogfx::percussion_instrument::AcousticBassDrum , "Acoustic Bass Drum" },
808 { neogfx::percussion_instrument::LowFloorTom , "Low Floor Tom" },
809 { neogfx::percussion_instrument::ClosedHiHat , "Closed Hi Hat" },
810 { neogfx::percussion_instrument::HighFloorTom , "High Floor Tom" },
811 { neogfx::percussion_instrument::PedalHiHat , "Pedal Hi - Hat" },
813 { neogfx::percussion_instrument::OpenHiHat , "Open Hi - Hat" },
814 { neogfx::percussion_instrument::LowMidTom , "Low - Mid Tom" },
815 { neogfx::percussion_instrument::HiMidTom , "Hi - Mid Tom" },
816 { neogfx::percussion_instrument::CrashCymbal1 , "Crash Cymbal 1" },
818 { neogfx::percussion_instrument::RideCymbal1 , "Ride Cymbal 1" },
824 { neogfx::percussion_instrument::CrashCymbal2 , "Crash Cymbal 2" },
826 { neogfx::percussion_instrument::RideCymbal2 , "Ride Cymbal 2" },
829 { neogfx::percussion_instrument::MuteHiConga , "Mute Hi Conga" },
830 { neogfx::percussion_instrument::OpenHiConga , "Open Hi Conga" },
843 { neogfx::percussion_instrument::HiWoodBlock , "Hi Wood Block" },
844 { neogfx::percussion_instrument::LowWoodBlock , "Low Wood Block" },
849 };
850
851 return sMap.at(instrument);
852 }
853
854 enum class audio_channel : std::uint64_t
855 {
856 None = 0x0000000000000000ULL,
857 Mono = 0x0000000000000001ULL,
858 FrontLeft = 0x0000000000000002ULL,
859 FrontRight = 0x0000000000000004ULL,
860 FrontCenter = 0x0000000000000008ULL,
861 Lfe = 0x0000000000000010ULL,
862 BackLeft = 0x0000000000000020ULL,
863 BackRight = 0x0000000000000040ULL,
864 FrontLeftCenter = 0x0000000000000080ULL,
865 FrontRightCenter = 0x0000000000000100ULL,
866 BackCenter = 0x0000000000000200ULL,
867 SideLeft = 0x0000000000000400ULL,
868 SideRight = 0x0000000000000800ULL,
869 TopCenter = 0x0000000000001000ULL,
870 TopFrontLeft = 0x0000000000002000ULL,
871 TopFrontCenter = 0x0000000000004000ULL,
872 TopFrontRight = 0x0000000000008000ULL,
873 TopBackLeft = 0x0000000000010000ULL,
874 TopBackCenter = 0x0000000000020000ULL,
875 TopBackRight = 0x0000000000040000ULL,
876 Aux0 = 0x0000000000080000ULL,
877 Aux1 = 0x0000000000100000ULL,
878 Aux2 = 0x0000000000200000ULL,
879 Aux3 = 0x0000000000400000ULL,
880 Aux4 = 0x0000000000800000ULL,
881 Aux5 = 0x0000000001000000ULL,
882 Aux6 = 0x0000000002000000ULL,
883 Aux7 = 0x0000000004000000ULL,
884 Aux8 = 0x0000000008000000ULL,
885 Aux9 = 0x0000000010000000ULL,
886 Aux10 = 0x0000000020000000ULL,
887 Aux11 = 0x0000000040000000ULL,
888 Aux12 = 0x0000000080000000ULL,
889 Aux13 = 0x0000000100000000ULL,
890 Aux14 = 0x0000000200000000ULL,
891 Aux15 = 0x0000000400000000ULL,
892 Aux16 = 0x0000000800000000ULL,
893 Aux17 = 0x0000001000000000ULL,
894 Aux18 = 0x0000002000000000ULL,
895 Aux19 = 0x0000004000000000ULL,
896 Aux20 = 0x0000008000000000ULL,
897 Aux21 = 0x0000010000000000ULL,
898 Aux22 = 0x0000020000000000ULL,
899 Aux23 = 0x0000040000000000ULL,
900 Aux24 = 0x0000080000000000ULL,
901 Aux25 = 0x0000100000000000ULL,
902 Aux26 = 0x0000200000000000ULL,
903 Aux27 = 0x0000400000000000ULL,
904 Aux28 = 0x0000800000000000ULL,
905 Aux29 = 0x0001000000000000ULL,
906 Aux30 = 0x0002000000000000ULL,
907 Aux31 = 0x0004000000000000ULL,
908
909 Left = FrontLeft,
911 };
912
914 {
915 return static_cast<audio_channel>(static_cast<std::uint64_t>(lhs) & static_cast<std::uint64_t>(rhs));
916 }
917
919 {
920 return static_cast<audio_channel>(static_cast<std::uint64_t>(lhs) | static_cast<std::uint64_t>(rhs));
921 }
922
924 {
925 return static_cast<audio_channel>(static_cast<std::uint64_t>(lhs) ^ static_cast<std::uint64_t>(rhs));
926 }
927
929 {
930 return static_cast<audio_channel>(~static_cast<std::uint64_t>(lhs));
931 }
932
933 inline std::uint64_t channel_count(audio_channel channels)
934 {
935 return static_cast<std::uint64_t>(std::popcount(static_cast<std::uint64_t>(channels)));
936 }
937
938 enum class audio_stream_format : std::uint32_t
939 {
940 Unknown = 0,
941
942 Pcm = 1
943 };
944
945 enum class audio_sample_format : std::uint32_t
946 {
947 Unknown = 0,
948
949 U8 = 1,
950 S16 = 2,
951 S24 = 3,
952 S32 = 4,
953 F32 = 5
954 };
955
956 typedef std::uint64_t audio_sample_rate;
957
958 enum class audio_standard_sample_rate : std::uint64_t
959 {
960 Rate48000 = 48000,
961 Rate44100 = 44100,
962
963 Rate32000 = 32000,
964 Rate24000 = 24000,
965 Rate22050 = 22050,
966
967 Rate88200 = 88200,
968 Rate96000 = 96000,
969 Rate176400 = 176400,
970 Rate192000 = 192000,
971
972 Rate16000 = 16000,
973 Rate11025 = 11250,
974 Rate8000 = 8000,
975
976 Rate352800 = 352800,
977 Rate384000 = 384000,
978 };
979
988
989 typedef std::uint64_t audio_sample_index;
990 typedef std::uint64_t audio_sample_count;
991
992 typedef std::uint64_t audio_frame_index;
993 typedef std::uint64_t audio_frame_count;
994
995 template <typename SampleType, std::size_t Channels>
996 using audio_frame = std::array<SampleType, Channels>;
997
999 {
1000 float attack;
1001 float decay;
1002 float sustain;
1003 float release;
1004 };
1005}
constexpr style_aspect operator&(style_aspect aLhs, style_aspect aRhs)
Definition i_style.hpp:60
std::uint64_t audio_frame_index
audio_channel operator^(audio_channel lhs, audio_channel rhs)
audio_channel operator~(audio_channel lhs)
std::uint64_t audio_sample_count
std::string to_string(note const &aNote)
std::uint64_t audio_sample_index
std::uint64_t audio_frame_count
constexpr style_aspect operator|(style_aspect aLhs, style_aspect aRhs)
Definition i_style.hpp:55
std::array< SampleType, Channels > audio_frame
note string_to_note(std::string const &aNote)
std::uint64_t audio_sample_rate
std::uint64_t channel_count(audio_channel channels)
float frequency()
audio_sample_format sampleFormat