Line data Source code
1 : /*
2 : * SPDX-License-Identifier: GPL-3.0-only
3 : * MuseScore-Studio-CLA-applies
4 : *
5 : * MuseScore Studio
6 : * Music Composition & Notation
7 : *
8 : * Copyright (C) 2025 MuseScore Limited and others
9 : *
10 : * This program is free software: you can redistribute it and/or modify
11 : * it under the terms of the GNU General Public License version 3 as
12 : * published by the Free Software Foundation.
13 : *
14 : * This program is distributed in the hope that it will be useful,
15 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 : * GNU General Public License for more details.
18 : *
19 : * You should have received a copy of the GNU General Public License
20 : * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 : */
22 : #pragma once
23 :
24 : #include <cstdint>
25 : #include <optional>
26 : #include <string_view>
27 :
28 : namespace mu::iex::midi {
29 : // General MIDI Level 1 program numbers
30 : enum class GM1Program : std::uint8_t {
31 : // 0-7: Piano
32 : AcousticGrandPiano = 0,
33 : BrightAcousticPiano,
34 : ElectricGrandPiano,
35 : HonkyTonkPiano,
36 : ElectricPiano1,
37 : ElectricPiano2,
38 : Harpsichord,
39 : Clavi,
40 : // 8-15: Chromatic Percussion
41 : Celesta,
42 : Glockenspiel,
43 : MusicBox,
44 : Vibraphone,
45 : Marimba,
46 : Xylophone,
47 : TubularBells,
48 : Dulcimer,
49 : // 16-23: Organ
50 : DrawbarOrgan,
51 : PercussiveOrgan,
52 : RockOrgan,
53 : ChurchOrgan,
54 : ReedOrgan,
55 : Accordion,
56 : Harmonica,
57 : TangoAccordion,
58 : // 24-31: Guitar
59 : AcousticGuitarNylon,
60 : AcousticGuitarSteel,
61 : ElectricGuitarJazz,
62 : ElectricGuitarClean,
63 : ElectricGuitarMuted,
64 : OverdrivenGuitar,
65 : DistortionGuitar,
66 : GuitarHarmonics,
67 : // 32-39: Bass
68 : AcousticBass,
69 : ElectricBassFinger,
70 : ElectricBassPick,
71 : FretlessBass,
72 : SlapBass1,
73 : SlapBass2,
74 : SynthBass1,
75 : SynthBass2,
76 : // 40-47: Strings
77 : Violin,
78 : Viola,
79 : Cello,
80 : Contrabass,
81 : TremoloStrings,
82 : PizzicatoStrings,
83 : OrchestralHarp,
84 : Timpani,
85 : // 48-55: Ensemble
86 : StringEnsemble1,
87 : StringEnsemble2,
88 : SynthStrings1,
89 : SynthStrings2,
90 : ChoirAahs,
91 : VoiceOohs,
92 : SynthVoice,
93 : OrchestraHit,
94 : // 56-63: Brass
95 : Trumpet,
96 : Trombone,
97 : Tuba,
98 : MutedTrumpet,
99 : FrenchHorn,
100 : BrassSection,
101 : SynthBrass1,
102 : SynthBrass2,
103 : // 64-71: Reed
104 : SopranoSax,
105 : AltoSax,
106 : TenorSax,
107 : BaritoneSax,
108 : Oboe,
109 : EnglishHorn,
110 : Bassoon,
111 : Clarinet,
112 : // 72-79: Pipe
113 : Piccolo,
114 : Flute,
115 : Recorder,
116 : PanFlute,
117 : BlownBottle,
118 : Shakuhachi,
119 : Whistle,
120 : Ocarina,
121 : // 80-87: Synth Lead
122 : Lead1Square,
123 : Lead2Sawtooth,
124 : Lead3Calliope,
125 : Lead4Chiff,
126 : Lead5Charang,
127 : Lead6Voice,
128 : Lead7Fifths,
129 : Lead8BassAndLead,
130 : // 88-95: Synth Pad
131 : Pad1NewAge,
132 : Pad2Warm,
133 : Pad3Polysynth,
134 : Pad4Choir,
135 : Pad5Bowed,
136 : Pad6Metallic,
137 : Pad7Halo,
138 : Pad8Sweep,
139 : // 96-103: Synth Effects
140 : FX1Rain,
141 : FX2Soundtrack,
142 : FX3Crystal,
143 : FX4Atmosphere,
144 : FX5Brightness,
145 : FX6Goblins,
146 : FX7Echoes,
147 : FX8SciFi,
148 : // 104-111: Ethnic
149 : Sitar,
150 : Banjo,
151 : Shamisen,
152 : Koto,
153 : Kalimba,
154 : BagPipe,
155 : Fiddle,
156 : Shanai,
157 : // 112-119: Percussive
158 : TinkleBell,
159 : Agogo,
160 : SteelDrums,
161 : Woodblock,
162 : TaikoDrum,
163 : MelodicTom,
164 : SynthDrum,
165 : ReverseCymbal,
166 : // 120-127: Sound Effects
167 : GuitarFretNoise,
168 : BreathNoise,
169 : Seashore,
170 : BirdTweet,
171 : TelephoneRing,
172 : Helicopter,
173 : Applause,
174 : Gunshot,
175 : };
176 :
177 133 : constexpr std::optional<GM1Program> toGm1Program(const std::uint8_t v)
178 : {
179 133 : if (v > 127) {
180 0 : return std::nullopt;
181 : }
182 :
183 133 : return GM1Program { v };
184 : }
185 :
186 79010 : constexpr std::uint8_t toMidiData(const GM1Program p)
187 : {
188 79010 : return static_cast<std::uint8_t>(p);
189 : }
190 :
191 : std::string_view getMidiName(GM1Program);
192 : } // namespace mu::iex::midi
|