Clean up vestigial SoundLoader lines

This commit is contained in:
Luke Hubmayer-Werner 2024-07-05 20:59:54 +09:30
parent adb720668f
commit ea3f3441f6
4 changed files with 20 additions and 53 deletions

View File

@ -9,8 +9,11 @@ character_battle_sprite_stone_palette 0x00F807 N/A N/A 16 of ColorBGR555 Also 0x
character_battle_sprite_disabled_palette 0x00F867 /mnu/memsave.bin 0x000034 16 of ColorBGR555
locations_bg_palettes 0x03BB00 /nar/ff5_binx.bin 0x03BF80 43 of 128 of ColorBGR555
font_glyphs_dialogue 0x03E800 256 of SNESTritile length 0x1800
sfx_brr_data 0x041E3F Use the below SPC pointers
sfx_brr_pointers 0x041F4F 8 of 2 of u16 SPC memory addresses not ROM. Start address followed by loop address.
spc_note_durations 0x041D7E 14 of u8
bytelength_sfx_brr_data 0x041E3F u16 Used by the memcpy routine that copies the below data to the SPC (0x010E = 270 bytes = 16 BRR packets = 480 samples)
sfx_brr_data 0x041E41 Use the below SPC pointers
bytelength_sfx_brr_pointers 0x041F4F u16 Used by the memcpy routine that copies the below data to the SPC (0x0020 = 32 bytes)
sfx_brr_pointers 0x041F51 8 of 2 of u16 SPC memory addresses not ROM. Start address followed by loop address.
sfx_adsrs 0x041F71 8 of u16
sfx_samplerates 0x041F83 8 of u16
sfx_data 0x041F95 Contains SPC pointers and tracks

1 Label SNES PSX_file PSX_offset format Comment
9 character_battle_sprite_disabled_palette 0x00F867 /mnu/memsave.bin 0x000034 16 of ColorBGR555
10 locations_bg_palettes 0x03BB00 /nar/ff5_binx.bin 0x03BF80 43 of 128 of ColorBGR555
11 font_glyphs_dialogue 0x03E800 256 of SNESTritile length 0x1800
12 sfx_brr_data spc_note_durations 0x041E3F 0x041D7E 14 of u8 Use the below SPC pointers
13 sfx_brr_pointers bytelength_sfx_brr_data 0x041F4F 0x041E3F 8 of 2 of u16 u16 SPC memory addresses not ROM. Start address followed by loop address. Used by the memcpy routine that copies the below data to the SPC (0x010E = 270 bytes = 16 BRR packets = 480 samples)
14 sfx_brr_data 0x041E41 Use the below SPC pointers
15 bytelength_sfx_brr_pointers 0x041F4F u16 Used by the memcpy routine that copies the below data to the SPC (0x0020 = 32 bytes)
16 sfx_brr_pointers 0x041F51 8 of 2 of u16 SPC memory addresses not ROM. Start address followed by loop address.
17 sfx_adsrs 0x041F71 8 of u16
18 sfx_samplerates 0x041F83 8 of u16
19 sfx_data 0x041F95 Contains SPC pointers and tracks

8
default_bus_layout.tres Normal file
View File

@ -0,0 +1,8 @@
[gd_resource type="AudioBusLayout" load_steps=2 format=2]
[sub_resource type="AudioEffectCompressor" id=1]
resource_name = "Compressor"
[resource]
bus/0/effect/0/effect = SubResource( 1 )
bus/0/effect/0/enabled = true

View File

@ -104,7 +104,7 @@ func play_channel(channel: int, time_offset: float = 0.0) -> int:
note += (12 * self.channel_octave[channel]) + self.channel_transpose[channel]
player.pitch_scale = pow(2.0, (note - MUSIC.REFERENCE_NOTE)/12.0) #* self.channel_fine_tuning[channel]
player.volume_db = linear2db((self.channel_velocity[channel]/255.0) * (self.master_volume/255.0))
player.play(max(SoundLoader.PLAY_START - time_offset, 0.0))
player.play(max((SoundLoader.PLAY_START - time_offset)/player.pitch_scale, 0))
self.channel_current_note[channel] = note
else:
self.channel_current_note[channel] = -1

View File

@ -6,17 +6,8 @@ signal audio_sfx_sample_loaded(id)
var has_loaded_audio_samples := false
const BGM_NUM := 70
const BGM_LOOKUP := 0x043B97
const INST_NUM := 35
const INST_BRR_LOOKUP := 0x043C6F
const INST_LOOP := 0x043CD8
const INST_SR := 0x043D1E
const INST_ADSR := 0x043D64
const SFX_NUM := 8
const SFX_BRR_SPC_TABLE := 0x041F4F + 2 # (first two bytes are the length of 0x0020 = 32 bytes = 4*8)
const SFX_BRR_START := 0x041E3F + 2 # First two bytes are the length of the block, 0x010E = 270 bytes = 16 BRR packets = 480 samples
const SFX_ADSR := 0x041F71
const SFX_SR := 0x041F83
const PREPEND_MS := 20 # Prepend 20ms of silence to each sample for preplay purposes
const PLAY_START := PREPEND_MS / 1000.0
const BYTES_PER_SAMPLE := 2 # 16bit samples
@ -145,13 +136,14 @@ func get_inst_sample_data(snes_data: Dictionary, buffer: StreamPeerBuffer, id: i
# print_debug('Loaded instrument #%02X with lookup offset $%06X, BRR data offset $%06X, length $%04X (%f packets, %d samples) and loop point %d samples' % [id, lookup_offset, brr_offset, size, size/9.0, num_samples, audio.loop_begin])
return audio
# const SFX_BRR_START := 0x041E3F + 2 # First two bytes are the length of the block, 0x010E = 270 bytes = 16 BRR packets = 480 samples
func load_sfx_samples_data(snes_data: Dictionary, buffer: StreamPeerBuffer):
var brr_spc_addrs = []
var brr_spc_loop_addrs = []
for two_of_u16 in snes_data.sfx_brr_pointers:
brr_spc_addrs.append(two_of_u16[0])
brr_spc_loop_addrs.append(two_of_u16[1])
var brr_spc_start = SFX_BRR_START - brr_spc_addrs[0] # Refactor this later to somehow reference sfx_brr_data address from the tsv
var brr_spc_start = Common.SNES_PSX_addresses.sfx_brr_data.SNES - brr_spc_addrs[0] # Refactor this later
for i in SFX_NUM:
buffer.seek(brr_spc_addrs[i] + brr_spc_start)
# print('Loading sfx sample #%X with BRR data offset $%06X' % [i, buffer.get_position()])
@ -179,52 +171,20 @@ func load_samples(snes_data: Dictionary, buffer: StreamPeerBuffer):
emit_signal('audio_inst_sample_loaded', i)
func get_song_data(buffer: StreamPeerBuffer, id: int):
var lookup_offset := BGM_LOOKUP + (id*3)
buffer.seek(lookup_offset)
var offset := read_rom_address(buffer)
var bank := offset & 0xFF0000
buffer.seek(offset)
var _block_size := buffer.get_u16() # Unused since we pull the individual tracks
var track_ptrs = []
for i in 10:
var a := bank + buffer.get_u16()
if a < offset:
a += 0x010000 # Bank shift
track_ptrs.append(a)
if track_ptrs[0] != track_ptrs[1]:
print('Master is not channel 1, interesting', track_ptrs)
var tracks = []
for i in range(1, track_ptrs.size()-1):
var length = track_ptrs[i+1] - track_ptrs[i]
tracks.append(buffer.get_data(length)[1])
return tracks
func load_bgms(buffer: StreamPeerBuffer):
for i in BGM_NUM:
bgm_tracks.append(get_song_data(buffer, i))
var player := AudioStreamPlayer.new() # Make one for each channel, later
var HACK_EXTEND_LOOP_SAMPLE_playback: bool = false
func play_sample(id: int):
func play_sample(id: int, pitch_scale: float = 1.0):
print('Playing inst sample #%02X' % id)
player.pitch_scale = pitch_scale
if HACK_EXTEND_LOOP_SAMPLE_playback:
player.stream = instrument_samples_HACK_EXTENDED_LOOPS[id]
else:
player.stream = instrument_samples[id]
player.play(PLAY_START)
player.play(PLAY_START/pitch_scale)
func play_sfx(id: int):
print('Playing sfx sample #%02X' % id)
player.pitch_scale = 1.0
player.stream = sfx_samples[id]
player.play(PLAY_START)
@ -236,7 +196,3 @@ func parse_rom(snes_data: Dictionary, buffer: StreamPeerBuffer):
func _ready() -> void:
add_child(player)
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta: float) -> void:
# pass