Add non-looping .btsnd

This commit is contained in:
bnnm 2023-09-02 12:22:32 +02:00
parent 3b61d09fc5
commit 0b713d01f6
3 changed files with 19 additions and 12 deletions

View File

@ -1229,7 +1229,7 @@ static const meta_info meta_info_list[] = {
{meta_KT_WIIBGM, "Koei Tecmo WiiBGM Header"},
{meta_KTSS, "Koei Tecmo KTSS header"},
{meta_IDSP_NAMCO, "Namco IDSP header"},
{meta_WIIU_BTSND, "Nintendo Wii U Menu Boot Sound"},
{meta_BTSND, "Nintendo Wii U Menu Boot Sound header"},
{meta_MCA, "Capcom MCA header"},
{meta_ADX_MONSTER, "Monster Games .ADX header"},
{meta_HCA, "CRI HCA header"},

View File

@ -11,30 +11,37 @@ VGMSTREAM* init_vgmstream_btsnd(STREAMFILE* sf) {
/* checks */
if (!check_extensions(sf, "btsnd"))
goto fail;
return NULL;
if (read_u32be(0x00,sf) != 0x02)
goto fail;
uint32_t type = read_u32be(0x00,sf);
if (type == 0x00) {
loop_flag = 0;
}
else if (type == 0x02) {
loop_flag = 1;
}
else {
return NULL;
}
loop_start = read_s32be(0x04, sf);
loop_start = read_s32be(0x04, sf); /* non-looping: 0 or some number lower than samples */
start_offset = 0x08;
channels = 2;
loop_flag = loop_start > 0;
/* extra check since format is so simple */
/* extra checks since format is so simple */
data_size = get_streamfile_size(sf);
num_samples = pcm16_bytes_to_samples(data_size - start_offset, channels);
if (loop_start >= num_samples)
goto fail;
return NULL;
if (num_samples > 960000) /* known max reached by various games, encoder/Wii U limit? */
return NULL;
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channels, loop_flag);
if (!vgmstream) goto fail;
vgmstream->meta_type = meta_WIIU_BTSND;
vgmstream->meta_type = meta_BTSND;
vgmstream->sample_rate = 48000;
vgmstream->num_samples = num_samples;
vgmstream->loop_start_sample = loop_start;

View File

@ -276,7 +276,7 @@ typedef enum {
meta_SWAV,
meta_NDS_RRDS, /* Ridge Racer DS */
meta_BNS,
meta_WIIU_BTSND, /* Wii U Boot Sound */
meta_BTSND,
meta_ADX_03, /* CRI ADX "type 03" */
meta_ADX_04, /* CRI ADX "type 04" */