Output .bin file for direct sound metadata (loop point, pitch adust, and number of samples). This was needed since we couldn't incbin a string argument in a macro.

This commit is contained in:
Marcus Huderle 2016-09-08 16:42:47 -07:00
parent fe1fad3aa5
commit 001e1c77b8
5 changed files with 252 additions and 369 deletions

1
.gitignore vendored
View File

@ -13,6 +13,7 @@
*.latfont
*.hwjpnfont
*.fwjpnfont
data/music/direct_sound_samples/*.bin
pokeas
pokeld
pokeobjcopy

View File

@ -31,7 +31,7 @@ PREPROC := tools/preproc/preproc
# Secondary expansion is required for dependency variables in object rules.
.SECONDEXPANSION:
.PRECIOUS: %.1bpp %.4bpp %.8bpp %.gbapal %.lz %.rl %.pcm
.PRECIOUS: %.1bpp %.4bpp %.8bpp %.gbapal %.lz %.rl %.pcm %.bin
.PHONY: all clean compare ruby sapphire
@ -91,6 +91,7 @@ include misc.mk
%.lz: % ; $(GFX) $< $@
%.rl: % ; $(GFX) $< $@
%.pcm: %.aif ; $(AIF) $< $@
%.bin: %.aif ; $(AIF) $< $@
src/libc_ruby.o src/libc_sapphire.o: CC1 := tools/agbcc/bin/old_agbcc
src/libc_ruby.o src/libc_sapphire.o: CFLAGS := -O2

View File

@ -111,17 +111,3 @@
.4byte \voice_group_pointer
.4byte 0
.endm
.macro directsound_looped pitch_adjust, loop_start_sample_index, num_samples
.4byte 0x40000000
.4byte \pitch_adjust
.4byte \loop_start_sample_index
.4byte \num_samples
.endm
.macro directsound_not_looped pitch_adjust, num_samples
.4byte 0x0
.4byte \pitch_adjust
.4byte 0x0
.4byte \num_samples
.endm

File diff suppressed because it is too large Load Diff

View File

@ -228,6 +228,11 @@ void aif2pcm(const char *aif_filename)
strcpy(pcm_filename, aif_filename);
change_file_extension(pcm_filename, "pcm");
// Get .metadata filename.
char metadata_filename[strlen(aif_filename)];
strcpy(metadata_filename, aif_filename);
change_file_extension(metadata_filename, "bin");
// Open the given .aif file so we can read its contents.
FILE *aif_file;
aif_file = fopen(aif_filename, "rb");
@ -264,6 +269,14 @@ void aif2pcm(const char *aif_filename)
fwrite(aif_data->samples, aif_data->num_samples, 1, pcm_file);
fclose(pcm_file);
// Write the output .bin file containing .aif metadata.
FILE *metadata_file;
metadata_file = fopen(metadata_filename, "wb");
unsigned long pitch_adjust = (unsigned long)(aif_data->sample_rate * 1024);
fwrite(&pitch_adjust, sizeof(unsigned long), 1, metadata_file);
fwrite(&(aif_data->loop_offset), sizeof(unsigned long), 1, metadata_file);
fclose(metadata_file);
free(aif_data->samples);
free(aif_data);
free(aif_file_data);