diff --git a/multi_boot/roms/collect_rings/.gitignore b/multi_boot/roms/collect_rings/.gitignore index dc68d67c8..15a5fc661 100644 --- a/multi_boot/roms/collect_rings/.gitignore +++ b/multi_boot/roms/collect_rings/.gitignore @@ -2,3 +2,4 @@ graphics/*.pal src/sa2 sound/sa2/songs/midi sound/sa2/programmable_wave_samples +sound/shared/programmable_wave_samples diff --git a/multi_boot/roms/collect_rings/Makefile b/multi_boot/roms/collect_rings/Makefile index 925daef53..ee86d78cd 100644 --- a/multi_boot/roms/collect_rings/Makefile +++ b/multi_boot/roms/collect_rings/Makefile @@ -91,7 +91,7 @@ SOUND_ASM_SUBDIR = sound SOUND_ASM_BUILDDIR = $(OBJ_DIR)/$(SOUND_ASM_SUBDIR) SAMPLE_SUBDIR = sound/direct_sound_samples -WAVE_SAMPLES_SUBDIR = sound/sa2/programmable_wave_samples +WAVE_SAMPLES_SUBDIR = sound/shared/programmable_wave_samples C_SUBDIR = src C_BUILDDIR = $(OBJ_DIR)/$(C_SUBDIR) diff --git a/multi_boot/roms/collect_rings/sound/programmable_wave_data.inc b/multi_boot/roms/collect_rings/sound/programmable_wave_data.inc index 20b161718..80486711d 100644 --- a/multi_boot/roms/collect_rings/sound/programmable_wave_data.inc +++ b/multi_boot/roms/collect_rings/sound/programmable_wave_data.inc @@ -1,44 +1,44 @@ .align 2 .global ProgrammableWaveData_2016CCC ProgrammableWaveData_2016CCC: - .incbin "sound/sa2/programmable_wave_samples/02.pcm" + .incbin "sound/shared/programmable_wave_samples/02.pcm" .align 2 .global ProgrammableWaveData_2016CDC ProgrammableWaveData_2016CDC: - .incbin "sound/sa2/programmable_wave_samples/03.pcm" + .incbin "sound/shared/programmable_wave_samples/03.pcm" .align 2 .global ProgrammableWaveData_2016CEC ProgrammableWaveData_2016CEC: - .incbin "sound/sa2/programmable_wave_samples/04.pcm" + .incbin "sound/shared/programmable_wave_samples/04.pcm" .align 2 .global ProgrammableWaveData_2016CFC ProgrammableWaveData_2016CFC: - .incbin "sound/sa2/programmable_wave_samples/05.pcm" + .incbin "sound/shared/programmable_wave_samples/05.pcm" .align 2 .global ProgrammableWaveData_2016D0C ProgrammableWaveData_2016D0C: - .incbin "sound/sa2/programmable_wave_samples/06.pcm" + .incbin "sound/shared/programmable_wave_samples/06.pcm" .align 2 .global ProgrammableWaveData_2016D1C ProgrammableWaveData_2016D1C: - .incbin "sound/sa2/programmable_wave_samples/07.pcm" + .incbin "sound/shared/programmable_wave_samples/07.pcm" .align 2 .global ProgrammableWaveData_2016D2C ProgrammableWaveData_2016D2C: - .incbin "sound/sa2/programmable_wave_samples/08.pcm" + .incbin "sound/shared/programmable_wave_samples/08.pcm" .align 2 .global ProgrammableWaveData_2016D3C ProgrammableWaveData_2016D3C: - .incbin "sound/sa2/programmable_wave_samples/09.pcm" + .incbin "sound/shared/programmable_wave_samples/09.pcm" .align 2 .global ProgrammableWaveData_2016D4C ProgrammableWaveData_2016D4C: - .incbin "sound/sa2/programmable_wave_samples/10.pcm" + .incbin "sound/shared/programmable_wave_samples/10.pcm" diff --git a/scripts/match_samples.py b/scripts/sound/match_samples.py similarity index 100% rename from scripts/match_samples.py rename to scripts/sound/match_samples.py diff --git a/scripts/sound/match_waves.py b/scripts/sound/match_waves.py new file mode 100644 index 000000000..f6c64fb83 --- /dev/null +++ b/scripts/sound/match_waves.py @@ -0,0 +1,53 @@ +import os +import hashlib +import shutil +from pathlib import Path + + +files_by_hash = {} +sa2_to_sa1_sample = {} + + +for root, _, files in os.walk("sound/sa2/programmable_wave_samples"): + for file in files: + if file.endswith(".pcm"): + path = root + "/" + file + with open(path, 'rb') as f: + files_by_hash[hashlib.md5(f.read()).hexdigest()] = path + +for root, _, files in os.walk("sound/sa1/programmable_wave_samples"): + for file in files: + if file.endswith(".pcm"): + path = root + "/" + file + with open(path, 'rb') as f: + hash = hashlib.md5(f.read()).hexdigest() + if hash in files_by_hash: + sa2_to_sa1_sample[files_by_hash[hash]] = path + +for file in sa2_to_sa1_sample: + new_path = file.replace("/sa2/", "/shared/") + Path(new_path).parent.mkdir(parents=True, exist_ok=True) + shutil.copy(file, new_path) + +contents = "" +with open("sound/sa1/programmable_wave_data.inc") as sound_data_file: + contents = sound_data_file.read() + for file in sa2_to_sa1_sample: + sa1_file = sa2_to_sa1_sample[file] + contents = contents.replace(sa1_file, file.replace("/sa2/", "/shared/")) + +with open("sound/sa1/programmable_wave_data.inc", "w") as sound_data_file: + sound_data_file.write(contents) + +contents = "" +with open("sound/sa2/programmable_wave_data.inc") as sound_data_file: + contents = sound_data_file.read() + for file in sa2_to_sa1_sample: + contents = contents.replace(file.replace(".aif", ".bin"), file.replace("/sa2/", "/shared/")) + +with open("sound/sa2/programmable_wave_data.inc", "w") as sound_data_file: + sound_data_file.write(contents) + +for sa2_file, sa1_file in sa2_to_sa1_sample.items(): + os.remove(sa2_file) + os.remove(sa1_file) diff --git a/sound/sa1/programmable_wave_data.inc b/sound/sa1/programmable_wave_data.inc index 3faa46221..26e37a7f3 100644 --- a/sound/sa1/programmable_wave_data.inc +++ b/sound/sa1/programmable_wave_data.inc @@ -1,44 +1,44 @@ mAlignWord .global ProgrammableWaveData_86DD6D0 ProgrammableWaveData_86DD6D0: - .incbin "sound/sa1/programmable_wave_samples/086DD6D0.pcm" + .incbin "sound/shared/programmable_wave_samples/02.pcm" mAlignWord .global ProgrammableWaveData_86DD6E0 ProgrammableWaveData_86DD6E0: - .incbin "sound/sa1/programmable_wave_samples/086DD6E0.pcm" + .incbin "sound/shared/programmable_wave_samples/03.pcm" mAlignWord .global ProgrammableWaveData_86DD6F0 ProgrammableWaveData_86DD6F0: - .incbin "sound/sa1/programmable_wave_samples/086DD6F0.pcm" + .incbin "sound/shared/programmable_wave_samples/04.pcm" mAlignWord .global ProgrammableWaveData_86DD700 ProgrammableWaveData_86DD700: - .incbin "sound/sa1/programmable_wave_samples/086DD700.pcm" + .incbin "sound/shared/programmable_wave_samples/05.pcm" mAlignWord .global ProgrammableWaveData_86DD710 ProgrammableWaveData_86DD710: - .incbin "sound/sa1/programmable_wave_samples/086DD710.pcm" + .incbin "sound/shared/programmable_wave_samples/06.pcm" mAlignWord .global ProgrammableWaveData_86DD720 ProgrammableWaveData_86DD720: - .incbin "sound/sa1/programmable_wave_samples/086DD720.pcm" + .incbin "sound/shared/programmable_wave_samples/07.pcm" mAlignWord .global ProgrammableWaveData_86DD730 ProgrammableWaveData_86DD730: - .incbin "sound/sa1/programmable_wave_samples/086DD730.pcm" + .incbin "sound/shared/programmable_wave_samples/08.pcm" mAlignWord .global ProgrammableWaveData_86DD740 ProgrammableWaveData_86DD740: - .incbin "sound/sa1/programmable_wave_samples/086DD740.pcm" + .incbin "sound/shared/programmable_wave_samples/09.pcm" mAlignWord .global ProgrammableWaveData_86DD750 ProgrammableWaveData_86DD750: - .incbin "sound/sa1/programmable_wave_samples/086DD750.pcm" + .incbin "sound/shared/programmable_wave_samples/10.pcm" diff --git a/sound/sa1/programmable_wave_samples/086DD6D0.pcm b/sound/sa1/programmable_wave_samples/086DD6D0.pcm deleted file mode 100644 index 553e99bc8..000000000 Binary files a/sound/sa1/programmable_wave_samples/086DD6D0.pcm and /dev/null differ diff --git a/sound/sa1/programmable_wave_samples/086DD6E0.pcm b/sound/sa1/programmable_wave_samples/086DD6E0.pcm deleted file mode 100644 index d79c8eed5..000000000 --- a/sound/sa1/programmable_wave_samples/086DD6E0.pcm +++ /dev/null @@ -1 +0,0 @@ -#Eg‰«Íïþܺ˜vT2 \ No newline at end of file diff --git a/sound/sa1/programmable_wave_samples/086DD6F0.pcm b/sound/sa1/programmable_wave_samples/086DD6F0.pcm deleted file mode 100644 index d19ebafe4..000000000 Binary files a/sound/sa1/programmable_wave_samples/086DD6F0.pcm and /dev/null differ diff --git a/sound/sa1/programmable_wave_samples/086DD700.pcm b/sound/sa1/programmable_wave_samples/086DD700.pcm deleted file mode 100644 index 93a798654..000000000 --- a/sound/sa1/programmable_wave_samples/086DD700.pcm +++ /dev/null @@ -1 +0,0 @@ -þܺ™ˆˆˆˆwwwwfT2 \ No newline at end of file diff --git a/sound/sa1/programmable_wave_samples/086DD710.pcm b/sound/sa1/programmable_wave_samples/086DD710.pcm deleted file mode 100644 index 46ba2f195..000000000 Binary files a/sound/sa1/programmable_wave_samples/086DD710.pcm and /dev/null differ diff --git a/sound/sa1/programmable_wave_samples/086DD720.pcm b/sound/sa1/programmable_wave_samples/086DD720.pcm deleted file mode 100644 index 6f3ee57a8..000000000 Binary files a/sound/sa1/programmable_wave_samples/086DD720.pcm and /dev/null differ diff --git a/sound/sa1/programmable_wave_samples/086DD730.pcm b/sound/sa1/programmable_wave_samples/086DD730.pcm deleted file mode 100644 index 2584b93e7..000000000 Binary files a/sound/sa1/programmable_wave_samples/086DD730.pcm and /dev/null differ diff --git a/sound/sa1/programmable_wave_samples/086DD740.pcm b/sound/sa1/programmable_wave_samples/086DD740.pcm deleted file mode 100644 index 919625001..000000000 Binary files a/sound/sa1/programmable_wave_samples/086DD740.pcm and /dev/null differ diff --git a/sound/sa1/programmable_wave_samples/086DD750.pcm b/sound/sa1/programmable_wave_samples/086DD750.pcm deleted file mode 100644 index 0f00ddced..000000000 --- a/sound/sa1/programmable_wave_samples/086DD750.pcm +++ /dev/null @@ -1 +0,0 @@ -íþý¼¬ƒB@GV…‹Þ \ No newline at end of file diff --git a/sound/sa2/programmable_wave_data.inc b/sound/sa2/programmable_wave_data.inc index e30dcdee8..11899c438 100644 --- a/sound/sa2/programmable_wave_data.inc +++ b/sound/sa2/programmable_wave_data.inc @@ -4,36 +4,36 @@ ProgrammableWaveData_1: mAlignWord ProgrammableWaveData_2: - .incbin "sound/sa2/programmable_wave_samples/02.pcm" + .incbin "sound/shared/programmable_wave_samples/02.pcm" mAlignWord ProgrammableWaveData_3: - .incbin "sound/sa2/programmable_wave_samples/03.pcm" + .incbin "sound/shared/programmable_wave_samples/03.pcm" mAlignWord ProgrammableWaveData_4: - .incbin "sound/sa2/programmable_wave_samples/04.pcm" + .incbin "sound/shared/programmable_wave_samples/04.pcm" mAlignWord ProgrammableWaveData_5: - .incbin "sound/sa2/programmable_wave_samples/05.pcm" + .incbin "sound/shared/programmable_wave_samples/05.pcm" mAlignWord ProgrammableWaveData_6: - .incbin "sound/sa2/programmable_wave_samples/06.pcm" + .incbin "sound/shared/programmable_wave_samples/06.pcm" mAlignWord ProgrammableWaveData_7: - .incbin "sound/sa2/programmable_wave_samples/07.pcm" + .incbin "sound/shared/programmable_wave_samples/07.pcm" mAlignWord ProgrammableWaveData_8: - .incbin "sound/sa2/programmable_wave_samples/08.pcm" + .incbin "sound/shared/programmable_wave_samples/08.pcm" mAlignWord ProgrammableWaveData_9: - .incbin "sound/sa2/programmable_wave_samples/09.pcm" + .incbin "sound/shared/programmable_wave_samples/09.pcm" mAlignWord ProgrammableWaveData_10: - .incbin "sound/sa2/programmable_wave_samples/10.pcm" + .incbin "sound/shared/programmable_wave_samples/10.pcm" diff --git a/sound/sa2/programmable_wave_samples/02.pcm b/sound/shared/programmable_wave_samples/02.pcm similarity index 100% rename from sound/sa2/programmable_wave_samples/02.pcm rename to sound/shared/programmable_wave_samples/02.pcm diff --git a/sound/sa2/programmable_wave_samples/03.pcm b/sound/shared/programmable_wave_samples/03.pcm similarity index 100% rename from sound/sa2/programmable_wave_samples/03.pcm rename to sound/shared/programmable_wave_samples/03.pcm diff --git a/sound/sa2/programmable_wave_samples/04.pcm b/sound/shared/programmable_wave_samples/04.pcm similarity index 100% rename from sound/sa2/programmable_wave_samples/04.pcm rename to sound/shared/programmable_wave_samples/04.pcm diff --git a/sound/sa2/programmable_wave_samples/05.pcm b/sound/shared/programmable_wave_samples/05.pcm similarity index 100% rename from sound/sa2/programmable_wave_samples/05.pcm rename to sound/shared/programmable_wave_samples/05.pcm diff --git a/sound/sa2/programmable_wave_samples/06.pcm b/sound/shared/programmable_wave_samples/06.pcm similarity index 100% rename from sound/sa2/programmable_wave_samples/06.pcm rename to sound/shared/programmable_wave_samples/06.pcm diff --git a/sound/sa2/programmable_wave_samples/07.pcm b/sound/shared/programmable_wave_samples/07.pcm similarity index 100% rename from sound/sa2/programmable_wave_samples/07.pcm rename to sound/shared/programmable_wave_samples/07.pcm diff --git a/sound/sa2/programmable_wave_samples/08.pcm b/sound/shared/programmable_wave_samples/08.pcm similarity index 100% rename from sound/sa2/programmable_wave_samples/08.pcm rename to sound/shared/programmable_wave_samples/08.pcm diff --git a/sound/sa2/programmable_wave_samples/09.pcm b/sound/shared/programmable_wave_samples/09.pcm similarity index 100% rename from sound/sa2/programmable_wave_samples/09.pcm rename to sound/shared/programmable_wave_samples/09.pcm diff --git a/sound/sa2/programmable_wave_samples/10.pcm b/sound/shared/programmable_wave_samples/10.pcm similarity index 100% rename from sound/sa2/programmable_wave_samples/10.pcm rename to sound/shared/programmable_wave_samples/10.pcm