diff --git a/src/formats.c b/src/formats.c index d156cef0..e0dd4491 100644 --- a/src/formats.c +++ b/src/formats.c @@ -508,7 +508,6 @@ static const char* extension_list[] = { "smc", "smk", "smp", - "smpl", //fake extension/header id for .v0/v1 (renamed, to be removed) "smv", "snb", "snd", @@ -1179,7 +1178,7 @@ static const meta_info meta_info_list[] = { {meta_S14, "Namco .S14 raw header"}, {meta_SSS, "Namco .SSS raw header"}, {meta_PS2_GCM, "Namco GCM header"}, - {meta_PS2_SMPL, "Homura SMPL header"}, + {meta_SMPL, "Skonec SMPL header"}, {meta_PS2_MSA, "Success .MSA header"}, {meta_NGC_PDT, "Hudson .PDT header"}, {meta_NGC_RKV, "Legacy of Kain - Blood Omen 2 RKV GC header"}, diff --git a/src/meta/meta.h b/src/meta/meta.h index 1832e750..1db64229 100644 --- a/src/meta/meta.h +++ b/src/meta/meta.h @@ -448,7 +448,7 @@ VGMSTREAM * init_vgmstream_s14_sss(STREAMFILE* streamFile); VGMSTREAM * init_vgmstream_ps2_gcm(STREAMFILE* streamFile); -VGMSTREAM * init_vgmstream_ps2_smpl(STREAMFILE* streamFile); +VGMSTREAM* init_vgmstream_smpl(STREAMFILE* sf); VGMSTREAM * init_vgmstream_ps2_msa(STREAMFILE* streamFile); diff --git a/src/meta/ps2_smpl.c b/src/meta/ps2_smpl.c index b4a03712..359ef481 100644 --- a/src/meta/ps2_smpl.c +++ b/src/meta/ps2_smpl.c @@ -1,47 +1,48 @@ -#include "meta.h" -#include "../coding/coding.h" - -/* SMPL - from Homura (PS2) */ -VGMSTREAM * init_vgmstream_ps2_smpl(STREAMFILE *streamFile) { - VGMSTREAM * vgmstream = NULL; - off_t start_offset; - int loop_flag, channel_count; - size_t channel_size; - - /* checks*/ - /* .v0: left channel, .v1: right channel - * .smpl: header id */ - if ( !check_extensions(streamFile,"v0,v1,smpl") ) - goto fail; - if (read_32bitBE(0x00,streamFile) != 0x534D504C) /* "SMPL" */ - goto fail; - - channel_count = 1; - loop_flag = (read_32bitLE(0x30,streamFile) != 0); /* .v1 doesn't have loop points */ - start_offset = 0x40; - channel_size = read_32bitBE(0x0c,streamFile) - 0x10; - - /* build the VGMSTREAM */ - vgmstream = allocate_vgmstream(channel_count,loop_flag); - if (!vgmstream) goto fail; - - vgmstream->sample_rate = read_32bitBE(0x10,streamFile); - vgmstream->num_samples = ps_bytes_to_samples(channel_size*channel_count, channel_count); - vgmstream->loop_start_sample = read_32bitLE(0x30,streamFile); - vgmstream->loop_end_sample = vgmstream->num_samples; - - vgmstream->meta_type = meta_PS2_SMPL; - vgmstream->allow_dual_stereo = 1; - vgmstream->coding_type = coding_PSX; - vgmstream->layout_type = layout_none; - - read_string(vgmstream->stream_name,0x10+1, 0x20,streamFile); - - if ( !vgmstream_open_stream(vgmstream, streamFile, start_offset) ) - goto fail; - return vgmstream; - -fail: - close_vgmstream(vgmstream); - return NULL; -} +#include "meta.h" +#include "../coding/coding.h" + +/* SMPL - from Homura (PS2) */ +VGMSTREAM* init_vgmstream_smpl(STREAMFILE* sf) { + VGMSTREAM* vgmstream = NULL; + uint32_t start_offset, channel_size; + int loop_flag, channels; + + /* checks*/ + if (!is_id32be(0x00,sf, "SMPL")) + return NULL; + + /* .v0: left channel, .v1: right channel + * .smpl: header id */ + if (!check_extensions(sf,"v0,v1") ) + return NULL; + + /* 0x04: version (VAG-clone) */ + channels = 1; + loop_flag = (read_s32le(0x30,sf) != 0); /* .v1 doesn't have loop points */ + start_offset = 0x40; + channel_size = read_u32be(0x0c,sf) - 0x10; + + /* build the VGMSTREAM */ + vgmstream = allocate_vgmstream(channels,loop_flag); + if (!vgmstream) goto fail; + + vgmstream->sample_rate = read_s32be(0x10,sf); + vgmstream->num_samples = ps_bytes_to_samples(channel_size*channels, channels); + vgmstream->loop_start_sample = read_s32le(0x30,sf); + vgmstream->loop_end_sample = vgmstream->num_samples; + + vgmstream->meta_type = meta_SMPL; + vgmstream->allow_dual_stereo = 1; + vgmstream->coding_type = coding_PSX; + vgmstream->layout_type = layout_none; + + read_string(vgmstream->stream_name,0x10+1, 0x20,sf); + + if (!vgmstream_open_stream(vgmstream, sf, start_offset)) + goto fail; + return vgmstream; + +fail: + close_vgmstream(vgmstream); + return NULL; +} diff --git a/src/vgmstream.c b/src/vgmstream.c index 329eea77..2ecaf6b0 100644 --- a/src/vgmstream.c +++ b/src/vgmstream.c @@ -207,7 +207,7 @@ init_vgmstream_t init_vgmstream_functions[] = { init_vgmstream_ps2_wb, init_vgmstream_bnsf, init_vgmstream_ps2_gcm, - init_vgmstream_ps2_smpl, + init_vgmstream_smpl, init_vgmstream_ps2_msa, init_vgmstream_ps2_voi, init_vgmstream_ngc_rkv, @@ -1024,7 +1024,7 @@ static void try_dual_file_stereo(VGMSTREAM* opened_vgmstream, STREAMFILE* sf, in /* check these even if there is no loop, because they should then be zero in both * (Homura PS2 right channel doesn't have loop points so this check is ignored) */ - if (new_vgmstream->meta_type != meta_PS2_SMPL && + if (new_vgmstream->meta_type != meta_SMPL && !(new_vgmstream->loop_flag == opened_vgmstream->loop_flag && new_vgmstream->loop_start_sample== opened_vgmstream->loop_start_sample && new_vgmstream->loop_end_sample == opened_vgmstream->loop_end_sample)) { diff --git a/src/vgmstream_types.h b/src/vgmstream_types.h index 282abf20..2e647d70 100644 --- a/src/vgmstream_types.h +++ b/src/vgmstream_types.h @@ -465,7 +465,7 @@ typedef enum { meta_S14, /* raw Siren 14, 24kbit mono */ meta_SSS, /* raw Siren 14, 48kbit stereo */ meta_PS2_GCM, /* NamCollection */ - meta_PS2_SMPL, /* Homura */ + meta_SMPL, meta_PS2_MSA, /* Psyvariar -Complete Edition- */ meta_PS2_VOI, /* RAW Danger (Zettaizetsumei Toshi 2 - Itetsuita Kiokutachi) [PS2] */ meta_P3D, /* Prototype P3D */