vgmstream/src/meta/raw_int.c

45 lines
1.2 KiB
C
Raw Normal View History

#include "meta.h"
2018-08-16 20:06:14 +02:00
#include "../coding/coding.h"
2018-08-16 20:06:14 +02:00
/* raw PCM file assumed by extension [PaRappa The Rapper 2 (PS2)? , Amplitude (PS2)?] */
2019-09-02 22:32:02 +02:00
VGMSTREAM * init_vgmstream_raw_int(STREAMFILE *streamFile) {
VGMSTREAM * vgmstream = NULL;
2018-08-16 20:06:14 +02:00
off_t start_offset;
int channel_count;
2018-08-16 20:06:14 +02:00
/* checks */
if (!check_extensions(streamFile, "int,wp2"))
goto fail;
2018-08-16 20:06:14 +02:00
if (check_extensions(streamFile, "int"))
channel_count = 2;
else
channel_count = 4;
2019-09-02 22:32:02 +02:00
/* ignore .int PS-ADPCM */
if (ps_check_format(streamFile, 0x00, 0x10000))
goto fail;
2018-08-16 20:06:14 +02:00
start_offset = 0x00;
2017-12-09 17:03:23 +01:00
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channel_count,0);
if (!vgmstream) goto fail;
2019-09-02 22:32:02 +02:00
vgmstream->meta_type = meta_RAW_INT;
vgmstream->sample_rate = 48000;
2018-08-16 20:06:14 +02:00
vgmstream->num_samples = pcm_bytes_to_samples(get_streamfile_size(streamFile), vgmstream->channels, 16);
vgmstream->coding_type = coding_PCM16LE;
vgmstream->layout_type = layout_interleave;
2018-08-16 20:06:14 +02:00
vgmstream->interleave_block_size = 0x200;
2018-08-16 20:06:14 +02:00
if (!vgmstream_open_stream(vgmstream,streamFile,start_offset))
goto fail;
return vgmstream;
fail:
2019-09-02 22:32:02 +02:00
close_vgmstream(vgmstream);
return NULL;
}