2009-05-10 09:14:29 +02:00
|
|
|
#include "meta.h"
|
2018-04-20 21:00:17 +02:00
|
|
|
#include "../coding/coding.h"
|
2009-05-10 09:14:29 +02:00
|
|
|
|
2018-04-20 21:00:17 +02:00
|
|
|
/* ADPCM - from NAOMI/NAOMI2 Arcade games [F355 Challenge (Naomi)] */
|
2009-05-10 09:14:29 +02:00
|
|
|
VGMSTREAM * init_vgmstream_naomi_adpcm(STREAMFILE *streamFile) {
|
|
|
|
VGMSTREAM * vgmstream = NULL;
|
|
|
|
off_t start_offset;
|
2018-04-20 21:00:17 +02:00
|
|
|
int loop_flag, channel_count;
|
|
|
|
size_t data_size;
|
2009-05-10 09:14:29 +02:00
|
|
|
|
|
|
|
|
2018-04-20 21:00:17 +02:00
|
|
|
/* checks */
|
|
|
|
if (!check_extensions(streamFile, "adpcm"))
|
|
|
|
goto fail;
|
|
|
|
if (read_32bitBE(0x00,streamFile) != 0x41445043 || /* "ADPC" */
|
|
|
|
read_32bitBE(0x04,streamFile) != 0x4D5F7630) /* "M_v0" */
|
|
|
|
goto fail;
|
|
|
|
/* there is some kind of info in the end padding, loop related? */
|
2009-05-10 09:14:29 +02:00
|
|
|
|
|
|
|
loop_flag = 0;
|
|
|
|
channel_count = 2;
|
2018-04-20 21:00:17 +02:00
|
|
|
start_offset = 0x40;
|
|
|
|
data_size = read_32bitLE(0x10,streamFile) * 0x100; /* data has padding */
|
|
|
|
|
|
|
|
/* build the VGMSTREAM */
|
2009-05-10 09:14:29 +02:00
|
|
|
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
|
|
|
if (!vgmstream) goto fail;
|
|
|
|
|
|
|
|
vgmstream->sample_rate = 44100;
|
2019-03-03 02:30:52 +01:00
|
|
|
vgmstream->num_samples = yamaha_bytes_to_samples(data_size, channel_count);
|
2009-05-10 09:14:29 +02:00
|
|
|
|
2019-09-21 19:15:01 +02:00
|
|
|
vgmstream->coding_type = coding_AICA_int;
|
2009-05-10 09:14:29 +02:00
|
|
|
vgmstream->layout_type = layout_interleave;
|
2018-04-20 21:00:17 +02:00
|
|
|
vgmstream->interleave_block_size = data_size / channel_count;
|
2009-05-10 09:14:29 +02:00
|
|
|
vgmstream->meta_type = meta_NAOMI_ADPCM;
|
|
|
|
|
2018-04-20 21:00:17 +02:00
|
|
|
if (!vgmstream_open_stream(vgmstream,streamFile,start_offset))
|
|
|
|
goto fail;
|
2009-05-10 09:14:29 +02:00
|
|
|
return vgmstream;
|
|
|
|
|
|
|
|
fail:
|
2018-04-20 21:00:17 +02:00
|
|
|
close_vgmstream(vgmstream);
|
2009-05-10 09:14:29 +02:00
|
|
|
return NULL;
|
|
|
|
}
|