mirror of
https://github.com/vgmstream/vgmstream.git
synced 2025-01-18 07:44:43 +01:00
Tweak .svs sample rate
This commit is contained in:
parent
1380faf5bb
commit
ec63b8ff38
@ -758,7 +758,7 @@ static const meta_info meta_info_list[] = {
|
|||||||
{meta_WS_AUD, "Westwood Studios .aud header"},
|
{meta_WS_AUD, "Westwood Studios .aud header"},
|
||||||
{meta_WS_AUD_old, "Westwood Studios .aud (old) header"},
|
{meta_WS_AUD_old, "Westwood Studios .aud (old) header"},
|
||||||
{meta_PS2_IVB, "IVB/BVII header"},
|
{meta_PS2_IVB, "IVB/BVII header"},
|
||||||
{meta_PS2_SVS, "Square SVS header"},
|
{meta_SVS, "Square SVS header"},
|
||||||
{meta_RIFF_WAVE, "RIFF WAVE header"},
|
{meta_RIFF_WAVE, "RIFF WAVE header"},
|
||||||
{meta_RIFF_WAVE_POS, "RIFF WAVE header and .pos for looping"},
|
{meta_RIFF_WAVE_POS, "RIFF WAVE header and .pos for looping"},
|
||||||
{meta_NWA, "VisualArt's NWA header"},
|
{meta_NWA, "VisualArt's NWA header"},
|
||||||
|
@ -1,69 +1,54 @@
|
|||||||
#include "meta.h"
|
#include "meta.h"
|
||||||
#include "../util.h"
|
#include "../coding/coding.h"
|
||||||
|
|
||||||
/* SVS (from Unlimited Saga) */
|
|
||||||
/* probably Square Vag Stream */
|
/* SVS - SeqVagStream from Square games [Unlimited Saga (PS2) music] */
|
||||||
VGMSTREAM * init_vgmstream_svs(STREAMFILE *streamFile) {
|
VGMSTREAM * init_vgmstream_svs(STREAMFILE *streamFile) {
|
||||||
VGMSTREAM * vgmstream = NULL;
|
VGMSTREAM * vgmstream = NULL;
|
||||||
char filename[PATH_LIMIT];
|
|
||||||
off_t start_offset;
|
off_t start_offset;
|
||||||
|
int channel_count, loop_flag, pitch;
|
||||||
|
|
||||||
int loop_flag = 0;
|
|
||||||
int channel_count;
|
|
||||||
|
|
||||||
/* check extension, case insensitive */
|
/* checks */
|
||||||
streamFile->get_name(streamFile,filename,sizeof(filename));
|
/* .svs: header id (probably ok like The Bouncer's .vs) */
|
||||||
if (strcasecmp("svs",filename_extension(filename))) goto fail;
|
if (!check_extensions(streamFile, "svs"))
|
||||||
|
goto fail;
|
||||||
/* check header */
|
|
||||||
if (read_32bitBE(0x00,streamFile) != 0x53565300) /* "SVS\0" */
|
if (read_32bitBE(0x00,streamFile) != 0x53565300) /* "SVS\0" */
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
loop_flag = (read_32bitLE(0x08,streamFile)!=0);
|
/* 0x04: flags (1=stereo?, 2=loop) */
|
||||||
/* 63.SVS has start and end on the same sample, which crashes stuff */
|
pitch = read_32bitLE(0x10,streamFile); /* usually 0x1000 = 48000 */
|
||||||
if (read_32bitLE(0x08,streamFile)==read_32bitLE(0x0c,streamFile))
|
/* 0x14: volume? */
|
||||||
loop_flag = 0;
|
/* 0x18: file id (may be null) */
|
||||||
channel_count = 2;
|
/* 0x1c: null */
|
||||||
|
|
||||||
/* build the VGMSTREAM */
|
loop_flag = (read_32bitLE(0x08,streamFile) > 0); /* loop start frame, min is 1 */
|
||||||
|
channel_count = 2;
|
||||||
|
start_offset = 0x20;
|
||||||
|
|
||||||
|
|
||||||
|
/* build the VGMSTREAM */
|
||||||
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
||||||
if (!vgmstream) goto fail;
|
if (!vgmstream) goto fail;
|
||||||
|
|
||||||
/* fill in the vital statistics */
|
vgmstream->meta_type = meta_SVS;
|
||||||
start_offset = 0x40;
|
vgmstream->sample_rate = (48000 * pitch) / 4096; /* music = ~44100, ambience = 48000 */
|
||||||
vgmstream->channels = channel_count;
|
vgmstream->num_samples = ps_bytes_to_samples(get_streamfile_size(streamFile) - start_offset, channel_count);
|
||||||
vgmstream->sample_rate = 44100;
|
|
||||||
vgmstream->coding_type = coding_PSX;
|
|
||||||
vgmstream->num_samples = (get_streamfile_size(streamFile)-0x40)*28/16/channel_count;
|
|
||||||
if (loop_flag) {
|
if (loop_flag) {
|
||||||
vgmstream->loop_start_sample = (read_32bitLE(0x08,streamFile)-1)*28;
|
vgmstream->loop_start_sample = read_32bitLE(0x08,streamFile) * 28; /* frame count (0x10*ch) */
|
||||||
vgmstream->loop_end_sample = (read_32bitLE(0x0c,streamFile)-1)*28;
|
vgmstream->loop_end_sample = read_32bitLE(0x0c,streamFile) * 28; /* frame count, (not exact num_samples when no loop) */
|
||||||
|
/* start/end on the same frame rarely happens too (ex. file_id 63 SVS), perhaps loop should be +1 */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vgmstream->coding_type = coding_PSX;
|
||||||
vgmstream->layout_type = layout_interleave;
|
vgmstream->layout_type = layout_interleave;
|
||||||
vgmstream->interleave_block_size = 0x10;
|
vgmstream->interleave_block_size = 0x10;
|
||||||
vgmstream->meta_type = meta_PS2_SVS;
|
|
||||||
|
|
||||||
/* open the file for reading */
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
STREAMFILE * file;
|
|
||||||
file = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE);
|
|
||||||
if (!file) goto fail;
|
|
||||||
for (i=0;i<channel_count;i++) {
|
|
||||||
vgmstream->ch[i].streamfile = file;
|
|
||||||
|
|
||||||
vgmstream->ch[i].channel_start_offset=
|
|
||||||
vgmstream->ch[i].offset=start_offset+
|
|
||||||
vgmstream->interleave_block_size*i;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (!vgmstream_open_stream(vgmstream,streamFile,start_offset))
|
||||||
|
goto fail;
|
||||||
return vgmstream;
|
return vgmstream;
|
||||||
|
|
||||||
/* clean up anything we may have opened */
|
|
||||||
fail:
|
fail:
|
||||||
if (vgmstream) close_vgmstream(vgmstream);
|
close_vgmstream(vgmstream);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -342,7 +342,7 @@ typedef enum {
|
|||||||
meta_PS2_BMDX, /* Beatmania thing */
|
meta_PS2_BMDX, /* Beatmania thing */
|
||||||
meta_PS2_IVB, /* Langrisser 3 IVB */
|
meta_PS2_IVB, /* Langrisser 3 IVB */
|
||||||
meta_PS2_SND, /* some Might & Magics SSND header */
|
meta_PS2_SND, /* some Might & Magics SSND header */
|
||||||
meta_PS2_SVS, /* Square SVS */
|
meta_SVS, /* Square SVS */
|
||||||
meta_XSS, /* Dino Crisis 3 */
|
meta_XSS, /* Dino Crisis 3 */
|
||||||
meta_SL3, /* Test Drive Unlimited */
|
meta_SL3, /* Test Drive Unlimited */
|
||||||
meta_HGC1, /* Knights of the Temple 2 */
|
meta_HGC1, /* Knights of the Temple 2 */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user