Skip to content

Commit 1824458

Browse files
committed
Clean up enums.
1 parent f4216ea commit 1824458

File tree

1 file changed

+78
-120
lines changed

1 file changed

+78
-120
lines changed

pedalboard/juce_overrides/juce_PatchedWavAudioFormat.h

Lines changed: 78 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,28 @@
2222

2323
namespace juce {
2424

25+
/**
26+
* WAV format tags from mmreg.h / RFC 2361.
27+
* https://www.rfc-editor.org/rfc/rfc2361.html
28+
*/
29+
enum class WavFormatTag : unsigned short {
30+
PCM = 0x0001,
31+
ADPCM = 0x0002,
32+
IEEEFloat = 0x0003,
33+
ALaw = 0x0006,
34+
MuLaw = 0x0007,
35+
IMAADPCM = 0x0011,
36+
GSM610 = 0x0031,
37+
MPEG = 0x0050,
38+
MPEGLayer3 = 0x0055,
39+
Extensible = 0xFFFE,
40+
};
41+
2542
/**
2643
* A patched version of WavAudioFormat that adds support for WAV files
27-
* containing compressed audio data (WAVE_FORMAT_MPEGLAYER3, format tag
28-
* 0x55).
44+
* containing compressed audio data (e.g.: WAVE_FORMAT_MPEGLAYER3).
2945
*
30-
* These files are correct WAV files that use MP3 compression for the audio
46+
* These files are valid WAV files that use MP3 compression for the audio
3147
* data, wrapped in a standard RIFF/WAV container.
3248
*/
3349
class JUCE_API PatchedWavAudioFormat : public WavAudioFormat {
@@ -70,9 +86,8 @@ class JUCE_API PatchedWavAudioFormat : public WavAudioFormat {
7086
if (chunkType == chunkName("fmt ")) {
7187
auto format = (unsigned short)sourceStream->readShort();
7288

73-
switch (format) {
74-
// Formats we handle specially:
75-
case 0x55: // WAVE_FORMAT_MPEGLAYER3
89+
switch (static_cast<WavFormatTag>(format)) {
90+
case WavFormatTag::MPEGLayer3:
7691
return createMP3ReaderForWav(sourceStream, chunkEnd, streamStartPos,
7792
deleteStreamIfOpeningFails);
7893

@@ -156,123 +171,66 @@ class JUCE_API PatchedWavAudioFormat : public WavAudioFormat {
156171
* Returns nullptr for unknown formats (which will get a generic error).
157172
*/
158173
static const char *getUnsupportedCodecName(unsigned short format) {
174+
// clang-format off
159175
// Format tags from mmreg.h / RFC 2361: https://www.rfc-editor.org/rfc/rfc2361.html
160176
switch (format) {
161-
case 0x0002:
162-
return "Microsoft ADPCM";
163-
case 0x0006:
164-
return "A-law";
165-
case 0x0007:
166-
return "mu-law (u-law)";
167-
case 0x0010:
168-
return "OKI ADPCM";
169-
case 0x0011:
170-
return "IMA ADPCM (DVI ADPCM)";
171-
case 0x0012:
172-
return "MediaSpace ADPCM";
173-
case 0x0013:
174-
return "Sierra ADPCM";
175-
case 0x0014:
176-
return "G.723 ADPCM";
177-
case 0x0015:
178-
return "DIGISTD";
179-
case 0x0016:
180-
return "DIGIFIX";
181-
case 0x0017:
182-
return "Dialogic OKI ADPCM";
183-
case 0x0020:
184-
return "Yamaha ADPCM";
185-
case 0x0021:
186-
return "SONARC";
187-
case 0x0022:
188-
return "DSP Group TrueSpeech";
189-
case 0x0023:
190-
return "ECHOSC1";
191-
case 0x0024:
192-
return "Audiofile AF36";
193-
case 0x0025:
194-
return "APTX";
195-
case 0x0026:
196-
return "Audiofile AF10";
197-
case 0x0030:
198-
return "Dolby AC-2";
199-
case 0x0031:
200-
return "GSM 6.10";
201-
case 0x0040:
202-
return "G.721 ADPCM";
203-
case 0x0041:
204-
return "G.728 CELP";
205-
case 0x0050:
206-
return "MPEG";
207-
case 0x0052:
208-
return "RT24";
209-
case 0x0053:
210-
return "PAC";
211-
case 0x0061:
212-
return "G.726 ADPCM";
213-
case 0x0062:
214-
return "G.722 ADPCM";
215-
case 0x0064:
216-
return "G.722.1";
217-
case 0x0065:
218-
return "G.728";
219-
case 0x0066:
220-
return "G.726";
221-
case 0x0067:
222-
return "G.722";
223-
case 0x0069:
224-
return "G.729";
225-
case 0x0070:
226-
return "VSELP";
227-
case 0x0075:
228-
return "VOXWARE";
229-
case 0x00FF:
230-
return "AAC";
231-
case 0x0111:
232-
return "VIVO G.723";
233-
case 0x0112:
234-
return "VIVO Siren";
235-
case 0x0160:
236-
return "Windows Media Audio v1";
237-
case 0x0161:
238-
return "Windows Media Audio v2";
239-
case 0x0162:
240-
return "Windows Media Audio Pro";
241-
case 0x0163:
242-
return "Windows Media Audio Lossless";
243-
case 0x0200:
244-
return "Creative ADPCM";
245-
case 0x0202:
246-
return "Creative FastSpeech8";
247-
case 0x0203:
248-
return "Creative FastSpeech10";
249-
case 0x1000:
250-
return "Olivetti GSM";
251-
case 0x1001:
252-
return "Olivetti ADPCM";
253-
case 0x1002:
254-
return "Olivetti CELP";
255-
case 0x1003:
256-
return "Olivetti SBC";
257-
case 0x1004:
258-
return "Olivetti OPR";
259-
case 0x1100:
260-
return "LH Codec";
261-
case 0x1400:
262-
return "Norris";
263-
case 0x1500:
264-
return "SoundSpace Musicompress";
265-
case 0x2000:
266-
return "Dolby AC-3 (SPDIF)";
267-
case 0x2001:
268-
return "DTS";
269-
270-
default:
271-
// Unknown format - don't provide a specific error
272-
// Let it fall through to normal processing which may fail with generic
273-
// error
274-
return nullptr;
177+
case 0x0002: return "Microsoft ADPCM";
178+
case 0x0006: return "A-law";
179+
case 0x0007: return "mu-law (u-law)";
180+
case 0x0010: return "OKI ADPCM";
181+
case 0x0011: return "IMA ADPCM (DVI ADPCM)";
182+
case 0x0012: return "MediaSpace ADPCM";
183+
case 0x0013: return "Sierra ADPCM";
184+
case 0x0014: return "G.723 ADPCM";
185+
case 0x0015: return "DIGISTD";
186+
case 0x0016: return "DIGIFIX";
187+
case 0x0017: return "Dialogic OKI ADPCM";
188+
case 0x0020: return "Yamaha ADPCM";
189+
case 0x0021: return "SONARC";
190+
case 0x0022: return "DSP Group TrueSpeech";
191+
case 0x0023: return "ECHOSC1";
192+
case 0x0024: return "Audiofile AF36";
193+
case 0x0025: return "APTX";
194+
case 0x0026: return "Audiofile AF10";
195+
case 0x0030: return "Dolby AC-2";
196+
case 0x0031: return "GSM 6.10";
197+
case 0x0040: return "G.721 ADPCM";
198+
case 0x0041: return "G.728 CELP";
199+
case 0x0050: return "MPEG";
200+
case 0x0052: return "RT24";
201+
case 0x0053: return "PAC";
202+
case 0x0061: return "G.726 ADPCM";
203+
case 0x0062: return "G.722 ADPCM";
204+
case 0x0064: return "G.722.1";
205+
case 0x0065: return "G.728";
206+
case 0x0066: return "G.726";
207+
case 0x0067: return "G.722";
208+
case 0x0069: return "G.729";
209+
case 0x0070: return "VSELP";
210+
case 0x0075: return "VOXWARE";
211+
case 0x00FF: return "AAC";
212+
case 0x0111: return "VIVO G.723";
213+
case 0x0112: return "VIVO Siren";
214+
case 0x0160: return "Windows Media Audio v1";
215+
case 0x0161: return "Windows Media Audio v2";
216+
case 0x0162: return "Windows Media Audio Pro";
217+
case 0x0163: return "Windows Media Audio Lossless";
218+
case 0x0200: return "Creative ADPCM";
219+
case 0x0202: return "Creative FastSpeech8";
220+
case 0x0203: return "Creative FastSpeech10";
221+
case 0x1000: return "Olivetti GSM";
222+
case 0x1001: return "Olivetti ADPCM";
223+
case 0x1002: return "Olivetti CELP";
224+
case 0x1003: return "Olivetti SBC";
225+
case 0x1004: return "Olivetti OPR";
226+
case 0x1100: return "LH Codec";
227+
case 0x1400: return "Norris";
228+
case 0x1500: return "SoundSpace Musicompress";
229+
case 0x2000: return "Dolby AC-3 (SPDIF)";
230+
case 0x2001: return "DTS";
231+
default: return nullptr;
275232
}
233+
// clang-format on
276234
}
277235

278236
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(PatchedWavAudioFormat)

0 commit comments

Comments
 (0)