Now that bgm_is_active and channel_is_active are removed, we need a way to notify the game logic how long a sound will last.
I propose adding two more functions to the data_api
bgm_length_secs(index: i32) -> f32 which returns the length of the BGM in seconds.
bgm_length_frames(index: i32) -> i32 which returns the length of the BGM in frames.
sfx_length_secs(index: i32) -> f32 same as 1, but for SFX.
sfx_length_frames(index: i32) -> i32 same as 2, but for SFX.
While we don't have looping BGM or SFX yet, I figure we could use INFINITY or NaN or a negative number to represent looping ones in the future.
For the "frame" based ones, this should be an integer for the sound to completely complete. For example, if a SFX would take 15.5 game frames to complete, it should return 16.
Task List:
[x] Figure out how to calculate length of a sequence in seconds (f32) from the BPM
[x] Figure out how to calculate the length of a sequence in frames, from the previous step.
Now that
bgm_is_active
andchannel_is_active
are removed, we need a way to notify the game logic how long a sound will last.I propose adding two more functions to the
data_api
bgm_length_secs(index: i32) -> f32
which returns the length of the BGM in seconds.bgm_length_frames(index: i32) -> i32
which returns the length of the BGM in frames.sfx_length_secs(index: i32) -> f32
same as 1, but for SFX.sfx_length_frames(index: i32) -> i32
same as 2, but for SFX.While we don't have looping BGM or SFX yet, I figure we could use INFINITY or NaN or a negative number to represent looping ones in the future.
For the "frame" based ones, this should be an integer for the sound to completely complete. For example, if a SFX would take 15.5 game frames to complete, it should return 16.
Task List:
bgm_length_secs
bgm_length_frames
sfx_length_secs
sfx_length_frames