diff --git a/src/meta/agsc.c b/src/meta/agsc.c index d2f55b42..72629315 100644 --- a/src/meta/agsc.c +++ b/src/meta/agsc.c @@ -43,6 +43,7 @@ VGMSTREAM * init_vgmstream_agsc(STREAMFILE *streamFile) { vgmstream->coding_type = coding_NGC_DSP; vgmstream->layout_type = layout_none; vgmstream->meta_type = meta_DSP_AGSC; + vgmstream->allow_dual_stereo = 1; for (i=0;i<16;i++) { vgmstream->ch[0].adpcm_coef[i]=read_16bitBE(header_offset+0xf6+i*2,streamFile); diff --git a/src/meta/excitebots.c b/src/meta/excitebots.c index 5ba06f00..2f5de05b 100644 --- a/src/meta/excitebots.c +++ b/src/meta/excitebots.c @@ -82,6 +82,7 @@ VGMSTREAM * init_vgmstream_eb_sfx(STREAMFILE *streamFile) { vgmstream->layout_type = layout_none; vgmstream->meta_type = meta_EB_SFX; + vgmstream->allow_dual_stereo = 1; /* open the file for reading */ { diff --git a/src/meta/genh.c b/src/meta/genh.c index 70cac106..22a39025 100644 --- a/src/meta/genh.c +++ b/src/meta/genh.c @@ -325,6 +325,7 @@ VGMSTREAM * init_vgmstream_genh(STREAMFILE *streamFile) { vgmstream->coding_type = coding; vgmstream->meta_type = meta_GENH; + vgmstream->allow_dual_stereo = 1; if ( !vgmstream_open_stream(vgmstream,streamFile,genh.start_offset) ) diff --git a/src/meta/kraw.c b/src/meta/kraw.c index 2fd4123e..a14a2146 100644 --- a/src/meta/kraw.c +++ b/src/meta/kraw.c @@ -37,6 +37,7 @@ VGMSTREAM * init_vgmstream_kraw(STREAMFILE *streamFile) { vgmstream->layout_type = layout_none; vgmstream->meta_type = meta_KRAW; + vgmstream->allow_dual_stereo = 1; /* open the file for reading */ { diff --git a/src/meta/ngc_dsp_std.c b/src/meta/ngc_dsp_std.c index 7908131a..b3ee0110 100644 --- a/src/meta/ngc_dsp_std.c +++ b/src/meta/ngc_dsp_std.c @@ -348,6 +348,7 @@ VGMSTREAM * init_vgmstream_ngc_dsp_std(STREAMFILE *streamFile) { vgmstream->loop_end_sample = vgmstream->num_samples; vgmstream->meta_type = meta_DSP_STD; + vgmstream->allow_dual_stereo = 1; /* very common in .dsp */ vgmstream->coding_type = coding_NGC_DSP; vgmstream->layout_type = layout_none; diff --git a/src/meta/ngc_dsp_ygo.c b/src/meta/ngc_dsp_ygo.c index 77608018..e53905ef 100644 --- a/src/meta/ngc_dsp_ygo.c +++ b/src/meta/ngc_dsp_ygo.c @@ -39,6 +39,7 @@ VGMSTREAM * init_vgmstream_dsp_ygo(STREAMFILE *streamFile) { vgmstream->num_samples = read_32bitBE(0x20,streamFile); vgmstream->layout_type = layout_none; vgmstream->meta_type = meta_DSP_YGO; + vgmstream->allow_dual_stereo = 1; if (loop_flag) { vgmstream->loop_start_sample = (read_32bitBE(0x30,streamFile)*14/16); vgmstream->loop_end_sample = (read_32bitBE(0x34,streamFile)*14/16); diff --git a/src/meta/ngc_lps.c b/src/meta/ngc_lps.c index 6957a782..bafa5f90 100644 --- a/src/meta/ngc_lps.c +++ b/src/meta/ngc_lps.c @@ -37,6 +37,7 @@ VGMSTREAM * init_vgmstream_ngc_lps(STREAMFILE *streamFile) { vgmstream->layout_type = layout_none; vgmstream->meta_type = meta_NGC_LPS; + vgmstream->allow_dual_stereo = 1; if (vgmstream->coding_type == coding_NGC_DSP) { int i; diff --git a/src/meta/ngca.c b/src/meta/ngca.c index 271be64e..fb135204 100644 --- a/src/meta/ngca.c +++ b/src/meta/ngca.c @@ -34,6 +34,7 @@ VGMSTREAM * init_vgmstream_ngca(STREAMFILE *streamFile) { vgmstream->layout_type = layout_none; vgmstream->meta_type = meta_NGCA; + vgmstream->allow_dual_stereo = 1; if (vgmstream->coding_type == coding_NGC_DSP) { int i; diff --git a/src/meta/nub_vag.c b/src/meta/nub_vag.c index c74393e9..6d68746c 100644 --- a/src/meta/nub_vag.c +++ b/src/meta/nub_vag.c @@ -32,6 +32,7 @@ VGMSTREAM * init_vgmstream_nub_vag(STREAMFILE *streamFile) { vgmstream->layout_type = layout_none; vgmstream->meta_type = meta_NUB_VAG; + vgmstream->allow_dual_stereo = 1; start_offset = 0xC0; diff --git a/src/meta/ps2_smpl.c b/src/meta/ps2_smpl.c index e44bd7ed..b4a03712 100644 --- a/src/meta/ps2_smpl.c +++ b/src/meta/ps2_smpl.c @@ -8,11 +8,11 @@ VGMSTREAM * init_vgmstream_ps2_smpl(STREAMFILE *streamFile) { int loop_flag, channel_count; size_t channel_size; - /* check extension (.v0: left channel, .v1: right channel, .smpl: header id) */ + /* checks*/ + /* .v0: left channel, .v1: right channel + * .smpl: header id */ if ( !check_extensions(streamFile,"v0,v1,smpl") ) goto fail; - - /* check header */ if (read_32bitBE(0x00,streamFile) != 0x534D504C) /* "SMPL" */ goto fail; @@ -31,13 +31,12 @@ VGMSTREAM * init_vgmstream_ps2_smpl(STREAMFILE *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; - /* always, but can be null or used as special string */ read_string(vgmstream->stream_name,0x10+1, 0x20,streamFile); - /* open the file for reading */ if ( !vgmstream_open_stream(vgmstream, streamFile, start_offset) ) goto fail; return vgmstream; diff --git a/src/meta/ps_headerless.c b/src/meta/ps_headerless.c index e722e4d0..8a4a7d97 100644 --- a/src/meta/ps_headerless.c +++ b/src/meta/ps_headerless.c @@ -276,6 +276,7 @@ VGMSTREAM * init_vgmstream_ps_headerless(STREAMFILE *streamFile) { } vgmstream->meta_type = meta_PS_HEADERLESS; + vgmstream->allow_dual_stereo = 1; if (!vgmstream_open_stream(vgmstream,streamFile,start_offset)) goto fail; diff --git a/src/meta/rwsd.c b/src/meta/rwsd.c index 769f2bbf..7dd87f08 100644 --- a/src/meta/rwsd.c +++ b/src/meta/rwsd.c @@ -280,10 +280,13 @@ VGMSTREAM * init_vgmstream_rwsd(STREAMFILE *streamFile) { vgmstream->meta_type = meta_RWAR; else if (rwav) { - if (big_endian) + if (big_endian) { vgmstream->meta_type = meta_RWAV; - else + } + else { vgmstream->meta_type = meta_CWAV; + vgmstream->allow_dual_stereo = 1; /* LEGO 3DS games */ + } } else vgmstream->meta_type = meta_RWSD; diff --git a/src/meta/spt_spd.c b/src/meta/spt_spd.c index 749ef0f8..5535a74b 100644 --- a/src/meta/spt_spd.c +++ b/src/meta/spt_spd.c @@ -71,7 +71,8 @@ VGMSTREAM * init_vgmstream_spt_spd(STREAMFILE *streamFile) { } vgmstream->meta_type = meta_SPT_SPD; - + vgmstream->allow_dual_stereo = 1; + /* open the file for reading */ { for (i=0;icoding_type = coding; vgmstream->meta_type = meta_TXTH; + vgmstream->allow_dual_stereo = 1; if ( !vgmstream_open_stream(vgmstream,streamFile,txth.start_offset) ) diff --git a/src/meta/vag.c b/src/meta/vag.c index 2e58441c..e88a78a5 100644 --- a/src/meta/vag.c +++ b/src/meta/vag.c @@ -11,7 +11,7 @@ VGMSTREAM * init_vgmstream_vag(STREAMFILE *streamFile) { int channel_count = 0, loop_flag, sample_rate; uint32_t vag_id, version; int32_t loop_start_sample = 0, loop_end_sample = 0; - //int allow_dual_stereo = 0; + int allow_dual_stereo = 0; /* checks */ @@ -195,7 +195,7 @@ VGMSTREAM * init_vgmstream_vag(STREAMFILE *streamFile) { channel_count = 1; loop_flag = ps_find_loop_offsets_full(streamFile, start_offset, channel_size*channel_count, channel_count, interleave, &loop_start_sample, &loop_end_sample); - //allow_dual_stereo = 1; /* often found with external L/R files */ + allow_dual_stereo = 1; /* often found with external L/R files */ } break; @@ -209,6 +209,8 @@ VGMSTREAM * init_vgmstream_vag(STREAMFILE *streamFile) { if (!vgmstream) goto fail; vgmstream->meta_type = meta_type; + vgmstream->allow_dual_stereo = allow_dual_stereo; + vgmstream->sample_rate = sample_rate; vgmstream->num_samples = ps_bytes_to_samples(channel_size,1); vgmstream->loop_start_sample = loop_start_sample; diff --git a/src/vgmstream.c b/src/vgmstream.c index f0f4e738..a691fc69 100644 --- a/src/vgmstream.c +++ b/src/vgmstream.c @@ -474,23 +474,7 @@ static VGMSTREAM * init_vgmstream_internal(STREAMFILE *streamFile) { } /* test if candidate for dual stereo */ - if (vgmstream->channels == 1 && ( - (vgmstream->meta_type == meta_DSP_STD) || - (vgmstream->meta_type == meta_PS2_VAGp) || - (vgmstream->meta_type == meta_GENH) || - (vgmstream->meta_type == meta_TXTH) || - (vgmstream->meta_type == meta_KRAW) || - (vgmstream->meta_type == meta_PS_HEADERLESS) || - (vgmstream->meta_type == meta_NGC_LPS) || - (vgmstream->meta_type == meta_DSP_YGO) || - (vgmstream->meta_type == meta_DSP_AGSC) || - (vgmstream->meta_type == meta_PS2_SMPL) || - (vgmstream->meta_type == meta_NGCA) || - (vgmstream->meta_type == meta_NUB_VAG) || - (vgmstream->meta_type == meta_SPT_SPD) || - (vgmstream->meta_type == meta_EB_SFX) || - (vgmstream->meta_type == meta_CWAV) - )) { + if (vgmstream->channels == 1 && vgmstream->allow_dual_stereo == 1) { try_dual_file_stereo(vgmstream, streamFile, init_vgmstream_functions[i]); } diff --git a/src/vgmstream.h b/src/vgmstream.h index b6f63345..1366371b 100644 --- a/src/vgmstream.h +++ b/src/vgmstream.h @@ -757,10 +757,11 @@ typedef struct { int num_streams; /* for multi-stream formats (0=not set/one stream, 1=one stream) */ int stream_index; /* selected stream (also 1-based) */ char stream_name[STREAM_NAME_SIZE]; /* name of the current stream (info), if the file stores it and it's filled */ - size_t stream_size; /* info to properly calculate bitrate */ + size_t stream_size; /* info to properly calculate bitrate in case of subsongs */ uint32_t channel_mask; /* to silence crossfading subsongs/layers */ int channel_mappings_on; /* channel mappings are active */ int channel_mappings[32]; /* swap channel "i" with "[i]" */ + int allow_dual_stereo; /* search for dual stereo (file_L.ext + file_R.ext = single stereo file) */ /* looping */ int loop_flag; /* is this stream looped? */ @@ -804,7 +805,7 @@ typedef struct { int32_t ws_output_size; /* WS ADPCM: output bytes for this block */ - void * start_vgmstream; /* a copy of the VGMSTREAM as it was at the beginning of the stream (for AAX/AIX/SCD) */ + void * start_vgmstream; /* a copy of the VGMSTREAM as it was at the beginning of the stream (for custom layouts) */ /* Data the codec needs for the whole stream. This is for codecs too * different from vgmstream's structure to be reasonably shoehorned into @@ -812,9 +813,7 @@ typedef struct { * Note also that support must be added for resetting, looping and * closing for every codec that uses this, as it will not be handled. */ void * codec_data; - /* Same, for special layouts. - * Reusing the above pointer causes bugs when it's using special layout + codec - * (vgmstream may try to free/loop/etc codec_data). */ + /* Same, for special layouts. layout_data + codec_data may exist at the same time. */ void * layout_data; } VGMSTREAM;