exporting samples as wav for debugging

This commit is contained in:
Luke Hubmayer-Werner 2023-12-02 00:05:28 +10:30
parent 08f50779a9
commit 6f0f6fa1a2
1 changed files with 12 additions and 10 deletions

View File

@ -166,20 +166,22 @@ func load_sfx_samples_data(snes_data: Dictionary, buffer: StreamPeerBuffer):
# Called when the node enters the scene tree for the first time.
func load_samples(snes_data: Dictionary, buffer: StreamPeerBuffer):
load_sfx_samples_data(snes_data, buffer)
var largest_sample_idx := -1
var largest_sample_sample_count := 0
var total_frames := 0
# var largest_sample_idx := -1
# var largest_sample_sample_count := 0
# var total_frames := 0
# For some reason, this is a bit slow currently under certain editor conditions. Might optimize later.
for i in INST_NUM:
instrument_samples.append(get_inst_sample_data(snes_data, buffer, i))
total_frames += instrument_samples[i].loop_end
if largest_sample_sample_count < instrument_samples[i].loop_end:
largest_sample_sample_count = instrument_samples[i].loop_end
largest_sample_idx = i
var samp := get_inst_sample_data(snes_data, buffer, i)
instrument_samples.append(samp)
# total_frames += samp.loop_end
# if largest_sample_sample_count < samp.loop_end:
# largest_sample_sample_count = samp.loop_end
# largest_sample_idx = i
# Workaround for Godot 3.x quirk where looping samples are interpolated as if they go to nothing instead of looping
instrument_samples_HACK_EXTENDED_LOOPS.append(HACK_EXTEND_LOOP_SAMPLE(instrument_samples[i]))
# print('Instrument %02X has mix_rate %d Hz and %d samples'%[i, instrument_samples[i].mix_rate, len(instrument_samples[i].data)/2])
instrument_samples_HACK_EXTENDED_LOOPS.append(HACK_EXTEND_LOOP_SAMPLE(samp))
# print('Instrument %02X has mix_rate %d Hz and %d samples'%[i, samp.mix_rate, len(samp.data)/2])
emit_signal('audio_inst_sample_loaded', i)
# samp.save_to_wav('output/instrument%02d(%dHz)(loop from %d).wav' % [i, samp.mix_rate, samp.loop_begin])
# print('Largest sample is instrument %d with length %d and mix_rate %d'%[largest_sample_idx, largest_sample_sample_count, instrument_samples[largest_sample_idx].mix_rate])
# print('Total frames: %d'%total_frames)