From e5bf3ca9c09e60f5a7752a43b894007785df2a8c Mon Sep 17 00:00:00 2001 From: Nes370 Date: Wed, 24 Jul 2024 09:43:40 -0700 Subject: [PATCH] Added Encoding CSV table --- res/Encoding.csv | 247 +++++++++++++++++++ res/pack_dj_menu.csv | 2 +- src/goblincave/gitea/nes/AudioExtractor.java | 63 +++-- 3 files changed, 292 insertions(+), 20 deletions(-) create mode 100644 res/Encoding.csv diff --git a/res/Encoding.csv b/res/Encoding.csv new file mode 100644 index 0000000..c034b88 --- /dev/null +++ b/res/Encoding.csv @@ -0,0 +1,247 @@ +Decimal value,Hexadecimal value,Description +0,0x0000,Unknown +1,0x0001,PCM (Pulse-Code Modulation) +2,0x0002,ADPCM (Adaptive Differential Pulse-Code Modulation) +3,0x0003,IEEE float +4,0x0004,Compaq VSELP (Vector Sum Excited Linear Prediction) +5,0x0005,IBM CVSDM (Continuously Variable Slope Delta Modulation) +6,0x0006,ITU G.711 a-law +7,0x0007,ITU G.711 u-law +8,0x0008,Microsoft DTS +9,0x0009,DRM +10,0x000A,WMA 9 Speech +11,0x000B,Microsoft Windows Media RT Voice +16,0x0010,OKI-ADPCM +17,0x0011,Intel IMA/DVI-ADPCM +18,0x0012,Videologic Mediaspace ADPCM +19,0x0013,Sierra ADPCM +20,0x0014,Antex G.723 ADPCM +21,0x0015,DSP Solutions DIGISTD +22,0x0016,DSP Solutions DIGIFIX +23,0x0017,Dialogic OKI ADPCM +24,0x0018,Media Vision ADPCM +25,0x0019,HP CU +26,0x001A,HP Dynamic Voice +32,0x0020,Yamaha ADPCM +33,0x0021,SONARC Speech Compression +34,0x0022,DSP Group True Speech +35,0x0023,Echo Speech Corp. +36,0x0024,Virtual Music Audiofile AF36 +37,0x0025,Audio Processing Tech. +38,0x0026,Virtual Music Audiofile AF10 +39,0x0027,Aculab Prosody 1612 +40,0x0028,Merging Tech. LRC +48,0x0030,Dolby AC2 +49,0x0031,Microsoft GSM610 +50,0x0032,MSN Audio +51,0x0033,Antex ADPCM +52,0x0034,Control Resources VQLPC +53,0x0035,DSP Solutions DIGIREAL +54,0x0036,DSP Solutions DIGIADPCM +55,0x0037,Control Resources CR10 +56,0x0038,Natural MicroSystems VBX ADPCM +57,0x0039,Crystal Semiconductors IMA ADPCM +58,0x003A,Echo Speech ECHOSC3 +59,0x003B,Rockwell ADPCM +60,0x003C,Rockwell DIGITALK +61,0x003D,Xebec Multimedia +64,0x0040,Antex G.721 ADPCM +65,0x0041,Antex G.728 CELP +66,0x0042,Microsoft MSG723 +67,0x0043,IBM AVC ADPCM +69,0x0045,ITU-T G.726 +80,0x0050,Microsoft MPEG +81,0x0051,RT23 or PAC +82,0x0052,InSoft RT24 +83,0x0053,InSoft PAC +85,0x0055,MP3 +89,0x0059,Cirrus +96,0x0060,Cirrus Logic +97,0x0061,ESS Tech. PCM +98,0x0062,Voxware Inc. +99,0x0063,Canopus ATRAC +100,0x0064,APICOM G.726 ADPCM +101,0x0065,APICOM G.722 ADPCM +102,0x0066,Microsoft DSAT +103,0x0067,Microsoft DSAT-DISPLAY +105,0x0069,Voxware Byte Aligned +112,0x0070,Voxware ACB +113,0x0071,Voxware AC10 +114,0x0072,Voxware AC16 +115,0x0073,Voxware AC20 +116,0x0074,Voxware MetaVoice +117,0x0075,Voxware MetaSound +118,0x0076,Voxware RT29HW +119,0x0077,Voxware VR12 +120,0x0078,Voxware VR18 +121,0x0079,Voxware TQ40 +122,0x007A,Voxware SC3 +123,0x007B,Voxware SC3 +128,0x0080,Soundsoft +129,0x0081,Voxware TQ60 +130,0x0082,Microsoft MSRT24 +131,0x0083,AT&T G.729A +132,0x0084,Motion Pixels MVI-MV12 +133,0x0085,DataFusion G.726 +134,0x0086,DataFusion GSM610 +136,0x0088,Iterated Systems Audio +137,0x0089,Onlive +138,0x008A,"Multitude, Inc. FT SX20" +139,0x008B,Infocom IT’S A/S G.721 ADPCM +140,0x008C,Convedia G729 +141,0x008D,"Congruency, Inc. (not specified)" +145,0x0091,Siemens SBC24 +146,0x0092,Sonic Foundry Dolby AC3 APDIF +147,0x0093,MediaSonic G.723 +148,0x0094,Aculab Prosody 8kbps +151,0x0097,ZyXEL ADPCM +152,0x0098,Philips LPCBB +153,0x0099,Studer Professional Audio Packed +160,0x00A0,Maiden PhonyTalk +161,0x00A1,Racal Recorder GSM +162,0x00A2,Racal Recorder G720.a +163,0x00A3,Racal G723.1 +164,0x00A4,Racal Tetra ACELP +176,0x00B0,NEC AAC NEC Corporation +255,0x00FF,AAC +256,0x0100,Rhetorex ADPCM +257,0x0101,IBM u-Law +258,0x0102,IBM a-Law +259,0x0103,IBM ADPCM +273,0x0111,Vivo G.723 +274,0x0112,Vivo Siren +288,0x0120,Philips Speech Processing CELP +289,0x0121,Philips Speech Processing GRUNDIG +291,0x0123,Digital G.723 +293,0x0125,Sanyo LD ADPCM +304,0x0130,Sipro Lab ACEPLNET +305,0x0131,Sipro Lab ACELP4800 +306,0x0132,Sipro Lab ACELP8V3 +307,0x0133,Sipro Lab G.729 +308,0x0134,Sipro Lab G.729A +309,0x0135,Sipro Lab Kelvin +310,0x0136,VoiceAge AMR +320,0x0140,Dictaphone G.726 ADPCM +336,0x0150,Qualcomm PureVoice +337,0x0151,Qualcomm HalfRate +341,0x0155,Ring Zero Systems TUBGSM +352,0x0160,Microsoft Audio1 +353,0x0161,Windows Media Audio V2 V7 V8 V9 / DivX audio (WMA) / Alex AC3 Audio +354,0x0162,Windows Media Audio Professional V9 +355,0x0163,Windows Media Audio Lossless V9 +356,0x0164,WMA Pro over S/PDIF +357,0x0165,XMA (Xbox Media Audio) +358,0x0166,XMA2 (Xbox Media Audio V2) +368,0x0170,UNISYS NAP ADPCM +369,0x0171,UNISYS NAP ULAW +370,0x0172,UNISYS NAP ALAW +371,0x0173,UNISYS NAP 16K +372,0x0174,MM SYCOM ACM SYC008 SyCom Technologies +373,0x0175,MM SYCOM ACM SYC701 G726L SyCom Technologies +374,0x0176,MM SYCOM ACM SYC701 CELP54 SyCom Technologies +375,0x0177,MM SYCOM ACM SYC701 CELP68 SyCom Technologies +376,0x0178,Knowledge Adventure ADPCM +384,0x0180,Fraunhofer IIS MPEG2AAC +400,0x0190,Digital Theater Systems DTS DS +512,0x0200,Creative Labs ADPCM +514,0x0202,Creative Labs FASTSPEECH8 +515,0x0203,Creative Labs FASTSPEECH10 +528,0x0210,UHER ADPCM +533,0x0215,Ulead DV ACM +534,0x0216,Ulead DV ACM +544,0x0220,Quarterdeck Corp. +560,0x0230,I-Link VC +576,0x0240,Aureal Semiconductor Raw Sport +577,0x0241,ESST AC3 +592,0x0250,Interactive Products HSX +593,0x0251,Interactive Products RPELP +608,0x0260,Consistent CS2 +624,0x0270,Sony SCX +625,0x0271,Sony SCY +626,0x0272,Sony ATRAC3 +627,0x0273,Sony SPC +640,0x0280,TELUM Telum Inc. +641,0x0281,TELUMIA Telum Inc. +645,0x0285,Norcom Voice Systems ADPCM +768,0x0300,Fujitsu FM TOWNS SND +769,0x0301,Fujitsu (not specified) +770,0x0302,Fujitsu (not specified) +771,0x0303,Fujitsu (not specified) +772,0x0304,Fujitsu (not specified) +773,0x0305,Fujitsu (not specified) +774,0x0306,Fujitsu (not specified) +775,0x0307,Fujitsu (not specified) +776,0x0308,Fujitsu (not specified) +848,0x0350,"Micronas Semiconductors, Inc. Development" +849,0x0351,"Micronas Semiconductors, Inc. CELP833" +1024,0x0400,Brooktree Digital +1025,0x0401,Intel Music Coder (IMC) +1026,0x0402,Ligos Indeo Audio +1104,0x0450,QDesign Music +1280,0x0500,On2 VP7 On2 Technologies +1281,0x0501,On2 VP6 On2 Technologies +1664,0x0680,AT&T VME VMPCM +1665,0x0681,AT&T TCP +1792,0x0700,YMPEG Alpha (dummy for MPEG-2 compressor) +2222,0x08AE,ClearJump LiteWave (lossless) +4096,0x1000,Olivetti GSM +4097,0x1001,Olivetti ADPCM +4098,0x1002,Olivetti CELP +4099,0x1003,Olivetti SBC +4100,0x1004,Olivetti OPR +4352,0x1100,Lernout & Hauspie +4353,0x1101,Lernout & Hauspie CELP codec +4354,0x1102,Lernout & Hauspie SBC codec +4355,0x1103,Lernout & Hauspie SBC codec +4356,0x1104,Lernout & Hauspie SBC codec +5120,0x1400,Norris Comm. Inc. +5121,0x1401,ISIAudio +5376,0x1500,AT&T Soundspace Music Compression +6172,0x181C,VoxWare RT24 speech codec +6174,0x181E,Lucent elemedia AX24000P Music codec +6513,0x1971,Sonic Foundry LOSSLESS +6521,0x1979,Innings Telecom Inc. ADPCM +7175,0x1C07,Lucent SX8300P speech codec +7180,0x1C0C,Lucent SX5363S G.723 compliant codec +7939,0x1F03,CUseeMe DigiTalk (ex-Rocwell) +8132,0x1FC4,NCT Soft ALF2CD ACM +8192,0x2000,FAST Multimedia DVM +8193,0x2001,Dolby DTS (Digital Theater System) +8194,0x2002,RealAudio 1 / 2 14.4 +8195,0x2003,RealAudio 1 / 2 28.8 +8196,0x2004,RealAudio G2 / 8 Cook (low bitrate) +8197,0x2005,RealAudio 3 / 4 / 5 Music (DNET) +8198,0x2006,RealAudio 10 AAC (RAAC) +8199,0x2007,RealAudio 10 AAC+ (RACP) +9472,0x2500,Reserved range to 0x2600 Microsoft +13075,0x3313,makeAVIS (ffvfw fake AVI sound from AviSynth scripts) +16707,0x4143,Divio MPEG-4 AAC audio +16897,0x4201,Nokia adaptive multirate +16963,0x4243,"Divio G726 Divio, Inc." +17228,0x434C,LEAD Speech +22092,0x564C,LEAD Vorbis +22358,0x5756,WavPack Audio +26447,0x674F,Ogg Vorbis (mode 1) +26448,0x6750,Ogg Vorbis (mode 2) +26449,0x6751,Ogg Vorbis (mode 3) +26479,0x676F,Ogg Vorbis (mode 1+) +26480,0x6770,Ogg Vorbis (mode 2+) +26481,0x6771,Ogg Vorbis (mode 3+) +28672,0x7000,3COM NBX 3Com Corporation +28781,0x706D,FAAD AAC +31265,0x7A21,"GSM-AMR (CBR, no SID)" +31266,0x7A22,"GSM-AMR (VBR, including SID)" +41216,0xA100,Comverse Infosys Ltd. G723 1 +41217,0xA101,Comverse Infosys Ltd. AVQSBC +41218,0xA102,Comverse Infosys Ltd. OLDSBC +41219,0xA103,Symbol Technologies G729A +41220,0xA104,VoiceAge AMR WB VoiceAge Corporation +41221,0xA105,Ingenient Technologies Inc. G726 +41222,0xA106,ISO/MPEG-4 advanced audio Coding +41223,0xA107,Encore Software Ltd G726 +41225,0xA109,Speex ACM Codec xiph.org +57260,0xDFAC,DebugMode SonicFoundry Vegas FrameServer ACM Codec +59144,0xE708,Unknown +61868,0xF1AC,Free Lossless Audio Codec FLAC +65534,0xFFFE,Extensible +65535,0xFFFF,Development diff --git a/res/pack_dj_menu.csv b/res/pack_dj_menu.csv index b8e3c80..5158e0e 100644 --- a/res/pack_dj_menu.csv +++ b/res/pack_dj_menu.csv @@ -17,7 +17,7 @@ 16,Normal,Here's the next tune.,AV Player 17,Normal,I can feel this race is gonna be really hot. Now start your engine and get ready.,Pre-race 18,Normal,I can feel this race is gonna be really hot. Now start your engine and get ready.,Pre-race -19,Normal,Hah aww yeah… I can feel this race is gonna be really hot. Now start your engine and get ready.,Pre-race +19,Normal,Heh aww yeah… I can feel this race is gonna be really hot. Now start your engine and get ready.,Pre-race 20,Normal,, 21,Normal,, 22,Normal,, diff --git a/src/goblincave/gitea/nes/AudioExtractor.java b/src/goblincave/gitea/nes/AudioExtractor.java index bf79e44..8f801a8 100644 --- a/src/goblincave/gitea/nes/AudioExtractor.java +++ b/src/goblincave/gitea/nes/AudioExtractor.java @@ -263,6 +263,21 @@ public class AudioExtractor { } + /** + * Helper method that converts a little-endian byte array into a long value. + * + * @param bytes (up to 8 bytes) + * @return value + */ + public static long littleEndianToLong(byte[] bytes) { + if(bytes.length > 8) + throw new IllegalArgumentException("Byte array must be 8 bytes or shorter."); + long value = 0; + for(int i = 0; i < bytes.length; i++) + value |= (long) (bytes[i] & 0xFF) << (8 * i); + return value; + } + public static void identify(File unknownFile) { // TODO check for characteristics of BIN or WAV files @@ -281,8 +296,17 @@ public class AudioExtractor { try { RandomAccessFile file = new RandomAccessFile(unknownFile, "r"); switch(extension.toLowerCase()) { + case "bin": { + + break; + } + case "flac": { + + break; + } case "wav": - case "xma": { + case "xma": + default: { byte[] buffer = new byte[4]; for(long i = 0; i < size - 4; i += 4) { file.seek(i); @@ -299,7 +323,7 @@ public class AudioExtractor { value = file.readInt(); if(value == ASCII_WAVE) System.out.println(formatAddress(i + 8) + ":\tWAVE (Waveform Audio File Format) type"); - i += 12; + i += 8; } System.out.println(); break; @@ -313,10 +337,22 @@ public class AudioExtractor { } if(i + fmtSize < size) { file.seek(i + 8); - byte[] compression = new byte[2]; - file.read(compression); - - + byte[] LEBytes = new byte[2]; + file.read(LEBytes); + long encoding = littleEndianToLong(LEBytes); + System.out.print(formatAddress(i + 8) + "\t"); + if(encoding == 0x0001) + System.out.print("PCM (Pulse-Code Modulation)"); + else if(encoding == 0x0002) + System.out.print("ADPCM (Adaptive Differential Pulse-Code Modulation)"); + else if(encoding == 0x0165) + System.out.print("XMA (Xbox Media Audio)"); + else if(encoding == 0x0166) + System.out.print("XMA2 (Xbox Media Audio 2)"); + else System.out.print("Unknown"); + // TODO lookup values from CSV + System.out.println(" encoding"); + i += fmtSize; } System.out.println(); @@ -326,17 +362,6 @@ public class AudioExtractor { } break; } - case "bin": { - - break; - } - case "flac": { - - break; - } - default: { - break; - } } } catch (IOException e) { System.out.println("Could not read file."); @@ -355,8 +380,8 @@ public class AudioExtractor { private static String formatAddress(long address) { if(address > 0xFFFF) - return String.format("%08x", address); - else return String.format("%04x", address); + return String.format("%08X", address); + else return String.format("%04X", address); }