cleanup: misc meta stuff

This commit is contained in:
bnnm 2024-08-09 00:14:14 +02:00
parent 6628099255
commit 2bd2c3e5e9
10 changed files with 189 additions and 219 deletions

View File

@ -342,7 +342,7 @@ static int play_vgmstream(const char* filename, song_settings_t* cfg) {
if (!buffer) goto fail; if (!buffer) goto fail;
} }
max_buffer_samples = buffer_size / (input_channels * sizeof(sample)); max_buffer_samples = buffer_size / (input_channels * sizeof(sample_t));
vgmstream_mixing_enable(vgmstream, max_buffer_samples, NULL, NULL); /* enable */ vgmstream_mixing_enable(vgmstream, max_buffer_samples, NULL, NULL); /* enable */
@ -423,7 +423,7 @@ static int play_vgmstream(const char* filename, song_settings_t* cfg) {
fflush(stdout); fflush(stdout);
} }
if (!ao_play(device, (char *)buffer, to_do * output_channels * sizeof(sample))) { if (!ao_play(device, (char *)buffer, to_do * output_channels * sizeof(sample_t))) {
fputs("\nAudio playback error\n", stderr); fputs("\nAudio playback error\n", stderr);
ao_close(device); ao_close(device);
device = NULL; device = NULL;

View File

@ -502,7 +502,7 @@ int decode_get_samples_per_frame(VGMSTREAM* vgmstream) {
return (0x40-0x04) * 2; return (0x40-0x04) * 2;
case coding_NDS_PROCYON: case coding_NDS_PROCYON:
return 30; return 30;
case coding_L5_555: case coding_LEVEL5:
return 32; return 32;
case coding_LSF: case coding_LSF:
return 54; return 54;
@ -729,7 +729,7 @@ int decode_get_frame_size(VGMSTREAM* vgmstream) {
return 0x40; return 0x40;
case coding_NDS_PROCYON: case coding_NDS_PROCYON:
return 0x10; return 0x10;
case coding_L5_555: case coding_LEVEL5:
return 0x12; return 0x12;
case coding_LSF: case coding_LSF:
return 0x1C; return 0x1C;
@ -1447,7 +1447,7 @@ void decode_vgmstream(VGMSTREAM* vgmstream, int samples_written, int samples_to_
vgmstream->channels, vgmstream->samples_into_block, samples_to_do); vgmstream->channels, vgmstream->samples_into_block, samples_to_do);
} }
break; break;
case coding_L5_555: case coding_LEVEL5:
for (ch = 0; ch < vgmstream->channels; ch++) { for (ch = 0; ch < vgmstream->channels; ch++) {
decode_l5_555(&vgmstream->ch[ch], buffer+ch, decode_l5_555(&vgmstream->ch[ch], buffer+ch,
vgmstream->channels, vgmstream->samples_into_block, samples_to_do); vgmstream->channels, vgmstream->samples_into_block, samples_to_do);

View File

@ -864,7 +864,7 @@ static const coding_info coding_info_list[] = {
{coding_NXAP, "Nex NXAP 4-bit ADPCM"}, {coding_NXAP, "Nex NXAP 4-bit ADPCM"},
{coding_TGC, "Tiger Game.com 4-bit ADPCM"}, {coding_TGC, "Tiger Game.com 4-bit ADPCM"},
{coding_NDS_PROCYON, "Procyon Studio Digital Sound Elements NDS 4-bit APDCM"}, {coding_NDS_PROCYON, "Procyon Studio Digital Sound Elements NDS 4-bit APDCM"},
{coding_L5_555, "Level-5 0x555 4-bit ADPCM"}, {coding_LEVEL5, "Level-5 4-bit ADPCM"},
{coding_LSF, "Gizmondo Studios Helsingborg LSF 4-bit ADPCM"}, {coding_LSF, "Gizmondo Studios Helsingborg LSF 4-bit ADPCM"},
{coding_MTAF, "Konami MTAF 4-bit ADPCM"}, {coding_MTAF, "Konami MTAF 4-bit ADPCM"},
{coding_MTA2, "Konami MTA2 4-bit ADPCM"}, {coding_MTA2, "Konami MTA2 4-bit ADPCM"},
@ -1096,7 +1096,7 @@ static const meta_info meta_info_list[] = {
{meta_RIFX_WAVE_smpl, "RIFX WAVE header (smpl looping)"}, {meta_RIFX_WAVE_smpl, "RIFX WAVE header (smpl looping)"},
{meta_XNB, "Microsoft XNA Game Studio header"}, {meta_XNB, "Microsoft XNA Game Studio header"},
{meta_SCD_PCM, "Lunar: Eternal Blue .PCM header"}, {meta_SCD_PCM, "Lunar: Eternal Blue .PCM header"},
{meta_PS2_PCM, "Konami .PCM header"}, {meta_PCM_KCEJE, "Konami .PCM header"},
{meta_PS2_RKV, "Legacy of Kain - Blood Omen 2 RKV PS2 header"}, {meta_PS2_RKV, "Legacy of Kain - Blood Omen 2 RKV PS2 header"},
{meta_VAS_KCEO, "Konami .VAS header"}, {meta_VAS_KCEO, "Konami .VAS header"},
{meta_LP_AP_LEP, "Konami LP/AP/LEP header"}, {meta_LP_AP_LEP, "Konami LP/AP/LEP header"},
@ -1120,8 +1120,8 @@ static const meta_info meta_info_list[] = {
{meta_RSD, "Radical RSD header"}, {meta_RSD, "Radical RSD header"},
{meta_ASD_NAXAT, "Naxat .ASD header"}, {meta_ASD_NAXAT, "Naxat .ASD header"},
{meta_SPSD, "Sega Naomi SPSD header"}, {meta_SPSD, "Sega Naomi SPSD header"},
{meta_FFXI_BGW, "Square Enix .BGW header"}, {meta_BGW, "Square Enix BGMStream header"},
{meta_FFXI_SPW, "Square Enix .SPW header"}, {meta_SPW, "Square Enix SeWave header"},
{meta_PS2_ASS, "SystemSoft .ASS header"}, {meta_PS2_ASS, "SystemSoft .ASS header"},
{meta_NUB, "Namco NUB header"}, {meta_NUB, "Namco NUB header"},
{meta_IDSP_NL, "Next Level IDSP header"}, {meta_IDSP_NL, "Next Level IDSP header"},
@ -1168,7 +1168,7 @@ static const meta_info meta_info_list[] = {
{meta_NAOMI_ADPCM, "NAOMI/NAOMI2 Arcade games ADPCM header"}, {meta_NAOMI_ADPCM, "NAOMI/NAOMI2 Arcade games ADPCM header"},
{meta_SD9, "beatmania IIDX SD9 header"}, {meta_SD9, "beatmania IIDX SD9 header"},
{meta_2DX9, "beatmania IIDX 2DX9 header"}, {meta_2DX9, "beatmania IIDX 2DX9 header"},
{meta_DSP_YGO, "Konami custom DSP Header"}, {meta_DSP_KCEJE, "Konami .DSP Header"},
{meta_PS2_VGV, "Rune: Viking Warlord VGV Header"}, {meta_PS2_VGV, "Rune: Viking Warlord VGV Header"},
{meta_GCUB, "Sega GCub header"}, {meta_GCUB, "Sega GCub header"},
{meta_NGC_SCK_DSP, "The Scorpion King SCK Header"}, {meta_NGC_SCK_DSP, "The Scorpion King SCK Header"},

View File

@ -4,47 +4,45 @@
/* BGW - from Final Fantasy XI (PC) music files */ /* BGW - from Final Fantasy XI (PC) music files */
VGMSTREAM * init_vgmstream_bgw(STREAMFILE *streamFile) { VGMSTREAM* init_vgmstream_bgw(STREAMFILE* sf) {
VGMSTREAM * vgmstream = NULL; VGMSTREAM* vgmstream = NULL;
STREAMFILE *temp_streamFile = NULL; STREAMFILE* temp_sf = NULL;
uint32_t codec, file_size, block_size, sample_rate, block_align; uint32_t codec, file_size, block_size, sample_rate, block_align;
int32_t loop_start; int32_t loop_start;
off_t start_offset; off_t start_offset;
int channel_count, loop_flag = 0; int channels, loop_flag = 0;
/* check extensions */
if ( !check_extensions(streamFile, "bgw") )
goto fail;
/* check header */ /* checks */
if (read_32bitBE(0x00,streamFile) != 0x42474d53 || /* "BGMS" */ if (!is_id32be(0x00,sf, "BGMS") || !is_id32be(0x04,sf, "trea") || !is_id32be(0x08,sf, "m\0\0\0"))
read_32bitBE(0x04,streamFile) != 0x74726561 || /* "trea" */ return NULL;
read_32bitBE(0x08,streamFile) != 0x6d000000 ) /* "m\0\0\0" */
goto fail;
codec = read_32bitLE(0x0c,streamFile); if (!check_extensions(sf, "bgw"))
file_size = read_32bitLE(0x10,streamFile); return NULL;
/* file_id = read_32bitLE(0x14,streamFile); */
block_size = read_32bitLE(0x18,streamFile);
loop_start = read_32bitLE(0x1c,streamFile);
sample_rate = (read_32bitLE(0x20,streamFile) + read_32bitLE(0x24,streamFile)) & 0x7FFFFFFF; /* bizarrely obfuscated sample rate */
start_offset = read_32bitLE(0x28,streamFile);
/* 0x2c: unk (vol?) */
/* 0x2d: unk (0x10?) */
channel_count = read_8bit(0x2e,streamFile);
block_align = (uint8_t)read_8bit(0x2f,streamFile);
if (file_size != get_streamfile_size(streamFile)) codec = read_u32le(0x0c,sf);
file_size = read_u32le(0x10,sf);
//14: file_id
block_size = read_u32le(0x18,sf);
loop_start = read_s32le(0x1c,sf);
sample_rate = (read_u32le(0x20,sf) + read_u32le(0x24,sf)) & 0x7FFFFFFF; /* bizarrely obfuscated sample rate */
start_offset = read_u32le(0x28,sf);
//2c: unk (vol?)
//2d: unk (bps?)
channels = read_s8(0x2e,sf);
block_align = read_u8(0x2f,sf);
if (file_size != get_streamfile_size(sf))
goto fail; goto fail;
loop_flag = (loop_start > 0); loop_flag = (loop_start > 0);
/* build the VGMSTREAM */ /* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channel_count,loop_flag); vgmstream = allocate_vgmstream(channels,loop_flag);
if (!vgmstream) goto fail; if (!vgmstream) goto fail;
vgmstream->meta_type = meta_FFXI_BGW; vgmstream->meta_type = meta_BGW;
vgmstream->sample_rate = sample_rate; vgmstream->sample_rate = sample_rate;
switch (codec) { switch (codec) {
@ -64,16 +62,16 @@ VGMSTREAM * init_vgmstream_bgw(STREAMFILE *streamFile) {
#ifdef VGM_USE_FFMPEG #ifdef VGM_USE_FFMPEG
case 3: { /* ATRAC3 (encrypted) */ case 3: { /* ATRAC3 (encrypted) */
size_t data_size = file_size - start_offset; size_t data_size = file_size - start_offset;
int encoder_delay, block_align; int encoder_delay, frame_size;
encoder_delay = 1024*2 + 69*2; /* observed value, all files start at +2200 (PS-ADPCM also starts around 50-150 samples in) */ encoder_delay = 1024*2 + 69*2; /* observed value, all files start at +2200 (PS-ADPCM also starts around 50-150 samples in) */
block_align = 0xC0 * vgmstream->channels; /* 0x00 in header */ frame_size = 0xC0 * vgmstream->channels; /* 0x00 in header */
vgmstream->num_samples = block_size - encoder_delay; /* atrac3_bytes_to_samples gives block_size */ vgmstream->num_samples = block_size - encoder_delay; /* atrac3_bytes_to_samples gives block_size */
temp_streamFile = setup_bgw_atrac3_streamfile(streamFile, start_offset,data_size, 0xC0,channel_count); temp_sf = setup_bgw_atrac3_streamfile(sf, start_offset,data_size, 0xC0,channels);
if (!temp_streamFile) goto fail; if (!temp_sf) goto fail;
vgmstream->codec_data = init_ffmpeg_atrac3_raw(temp_streamFile, 0x00,data_size, vgmstream->num_samples,vgmstream->channels,vgmstream->sample_rate, block_align, encoder_delay); vgmstream->codec_data = init_ffmpeg_atrac3_raw(temp_sf, 0x00, data_size, vgmstream->num_samples, vgmstream->channels, vgmstream->sample_rate, frame_size, encoder_delay);
if (!vgmstream->codec_data) goto fail; if (!vgmstream->codec_data) goto fail;
vgmstream->coding_type = coding_FFmpeg; vgmstream->coding_type = coding_FFmpeg;
vgmstream->layout_type = layout_none; vgmstream->layout_type = layout_none;
@ -83,7 +81,8 @@ VGMSTREAM * init_vgmstream_bgw(STREAMFILE *streamFile) {
vgmstream->loop_end_sample = vgmstream->num_samples; vgmstream->loop_end_sample = vgmstream->num_samples;
} }
close_streamfile(temp_streamFile); close_streamfile(temp_sf);
temp_sf = NULL;
break; break;
} }
#endif #endif
@ -93,59 +92,57 @@ VGMSTREAM * init_vgmstream_bgw(STREAMFILE *streamFile) {
} }
if ( !vgmstream_open_stream(vgmstream, streamFile, start_offset) ) if (!vgmstream_open_stream(vgmstream, sf, start_offset))
goto fail; goto fail;
return vgmstream; return vgmstream;
fail: fail:
close_streamfile(temp_streamFile); close_streamfile(temp_sf);
close_vgmstream(vgmstream); close_vgmstream(vgmstream);
return NULL; return NULL;
} }
/* SPW (SEWave) - from PlayOnline viewer for Final Fantasy XI (PC) */ /* SPW (SEWave) - from PlayOnline viewer for Final Fantasy XI (PC) */
VGMSTREAM * init_vgmstream_spw(STREAMFILE *streamFile) { VGMSTREAM* init_vgmstream_spw(STREAMFILE* sf) {
VGMSTREAM * vgmstream = NULL; VGMSTREAM* vgmstream = NULL;
STREAMFILE *temp_streamFile = NULL; STREAMFILE* temp_sf = NULL;
uint32_t codec, file_size, block_size, sample_rate, block_align; uint32_t codec, file_size, block_size, sample_rate, block_align;
int32_t loop_start; int32_t loop_start;
off_t start_offset; off_t start_offset;
int channel_count, loop_flag = 0; int channels, loop_flag = 0;
/* check extensions */ /* checks */
if ( !check_extensions(streamFile, "spw") ) if (!is_id32be(0x00,sf, "SeWa") || !is_id32be(0x04,sf, "ve\0\0"))
goto fail; return NULL;
/* check header */ if (!check_extensions(sf, "spw"))
if (read_32bitBE(0,streamFile) != 0x53655761 || /* "SeWa" */ return NULL;
read_32bitBE(4,streamFile) != 0x76650000) /* "ve\0\0" */
goto fail;
file_size = read_32bitLE(0x08,streamFile); file_size = read_u32le(0x08,sf);
codec = read_32bitLE(0x0c,streamFile); codec = read_u32le(0x0c,sf);
/* file_id = read_32bitLE(0x10,streamFile);*/ //10: file_id
block_size = read_32bitLE(0x14,streamFile); block_size = read_u32le(0x14,sf);
loop_start = read_32bitLE(0x18,streamFile); loop_start = read_s32le(0x18,sf);
sample_rate = (read_32bitLE(0x1c,streamFile) + read_32bitLE(0x20,streamFile)) & 0x7FFFFFFF; /* bizarrely obfuscated sample rate */ sample_rate = (read_u32le(0x1c,sf) + read_u32le(0x20,sf)) & 0x7FFFFFFF; /* bizarrely obfuscated sample rate */
start_offset = read_32bitLE(0x24,streamFile); start_offset = read_u32le(0x24,sf);
/* 0x2c: unk (0x00?) */ // 2c: unk (0x00?)
/* 0x2d: unk (0x00/01?) */ // 2d: unk (0x00/01?)
channel_count = read_8bit(0x2a,streamFile); channels = read_s8(0x2a,sf);
/*0x2b: unk (0x01 when PCM, 0x10 when VAG?) */ /*0x2b: unk (0x01 when PCM, 0x10 when VAG?) */
block_align = read_8bit(0x2c,streamFile); block_align = read_u8(0x2c,sf);
if (file_size != get_streamfile_size(streamFile)) if (file_size != get_streamfile_size(sf))
goto fail; goto fail;
loop_flag = (loop_start > 0); loop_flag = (loop_start > 0);
/* build the VGMSTREAM */ /* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channel_count,loop_flag); vgmstream = allocate_vgmstream(channels,loop_flag);
if (!vgmstream) goto fail; if (!vgmstream) goto fail;
vgmstream->meta_type = meta_FFXI_SPW; vgmstream->meta_type = meta_SPW;
vgmstream->sample_rate = sample_rate; vgmstream->sample_rate = sample_rate;
switch (codec) { switch (codec) {
@ -178,16 +175,16 @@ VGMSTREAM * init_vgmstream_spw(STREAMFILE *streamFile) {
#ifdef VGM_USE_FFMPEG #ifdef VGM_USE_FFMPEG
case 3: { /* ATRAC3 (encrypted) */ case 3: { /* ATRAC3 (encrypted) */
size_t data_size = file_size - start_offset; size_t data_size = file_size - start_offset;
int encoder_delay, block_align; int encoder_delay, frame_size;
encoder_delay = 1024*2 + 69*2; /* observed value, all files start at +2200 (PS-ADPCM also starts around 50-150 samples in) */ encoder_delay = 1024*2 + 69*2; /* observed value, all files start at +2200 (PS-ADPCM also starts around 50-150 samples in) */
block_align = 0xC0 * vgmstream->channels; /* 0x00 in header */ frame_size = 0xC0 * vgmstream->channels; /* 0x00 in header */
vgmstream->num_samples = block_size - encoder_delay; /* atrac3_bytes_to_samples gives block_size */ vgmstream->num_samples = block_size - encoder_delay; /* atrac3_bytes_to_samples gives block_size */
temp_streamFile = setup_bgw_atrac3_streamfile(streamFile, start_offset,data_size, 0xC0,channel_count); temp_sf = setup_bgw_atrac3_streamfile(sf, start_offset,data_size, 0xC0, channels);
if (!temp_streamFile) goto fail; if (!temp_sf) goto fail;
vgmstream->codec_data = init_ffmpeg_atrac3_raw(temp_streamFile, 0x00,data_size, vgmstream->num_samples,vgmstream->channels,vgmstream->sample_rate, block_align, encoder_delay); vgmstream->codec_data = init_ffmpeg_atrac3_raw(temp_sf, 0x00, data_size, vgmstream->num_samples, vgmstream->channels, vgmstream->sample_rate, frame_size, encoder_delay);
if (!vgmstream->codec_data) goto fail; if (!vgmstream->codec_data) goto fail;
vgmstream->coding_type = coding_FFmpeg; vgmstream->coding_type = coding_FFmpeg;
vgmstream->layout_type = layout_none; vgmstream->layout_type = layout_none;
@ -197,7 +194,8 @@ VGMSTREAM * init_vgmstream_spw(STREAMFILE *streamFile) {
vgmstream->loop_end_sample = vgmstream->num_samples; vgmstream->loop_end_sample = vgmstream->num_samples;
} }
close_streamfile(temp_streamFile); close_streamfile(temp_sf);
temp_sf = NULL;
break; break;
} }
#endif #endif
@ -206,15 +204,12 @@ VGMSTREAM * init_vgmstream_spw(STREAMFILE *streamFile) {
goto fail; goto fail;
} }
if (!vgmstream_open_stream(vgmstream, sf, start_offset))
/* open the file for reading */
if ( !vgmstream_open_stream(vgmstream, streamFile, start_offset) )
goto fail; goto fail;
return vgmstream; return vgmstream;
fail: fail:
close_streamfile(temp_streamFile); close_streamfile(temp_sf);
close_vgmstream(vgmstream); close_vgmstream(vgmstream);
return NULL; return NULL;
} }

View File

@ -248,7 +248,7 @@ VGMSTREAM * init_vgmstream_mus_acm(STREAMFILE * streamFile);
VGMSTREAM * init_vgmstream_scd_pcm(STREAMFILE * streamFile); VGMSTREAM * init_vgmstream_scd_pcm(STREAMFILE * streamFile);
VGMSTREAM * init_vgmstream_ps2_pcm(STREAMFILE * streamFile); VGMSTREAM* init_vgmstream_pcm_kceje(STREAMFILE* sf);
VGMSTREAM * init_vgmstream_ps2_rkv(STREAMFILE * streamFile); VGMSTREAM * init_vgmstream_ps2_rkv(STREAMFILE * streamFile);
@ -394,7 +394,7 @@ VGMSTREAM * init_vgmstream_sd9(STREAMFILE * streamFile);
VGMSTREAM * init_vgmstream_2dx9(STREAMFILE * streamFile); VGMSTREAM * init_vgmstream_2dx9(STREAMFILE * streamFile);
VGMSTREAM * init_vgmstream_dsp_ygo(STREAMFILE * streamFile); VGMSTREAM* init_vgmstream_dsp_kceje(STREAMFILE* sf);
VGMSTREAM * init_vgmstream_ps2_vgv(STREAMFILE * streamFile); VGMSTREAM * init_vgmstream_ps2_vgv(STREAMFILE * streamFile);

View File

@ -1,75 +1,52 @@
#include "meta.h" #include "meta.h"
#include "../util.h" #include "../coding/coding.h"
/* .dsp found in: /* .dsp - from KCE Japan East GC games [Yu-Gi-Oh! The Falsebound Kingdom (GC), Hikaru No Go 3 (GC)] */
Hikaru No Go 3 (NGC) VGMSTREAM* init_vgmstream_dsp_kceje(STREAMFILE* sf) {
Yu-Gi-Oh! The Falsebound Kingdom (NGC) VGMSTREAM* vgmstream = NULL;
int channels, loop_flag;
2010-01-31 - added loop stuff and some header checks... off_t start_offset;
*/
VGMSTREAM * init_vgmstream_dsp_ygo(STREAMFILE *streamFile) { /* checks */
VGMSTREAM * vgmstream = NULL; if (read_u32be(0x00,sf) + 0xE0 != get_streamfile_size(sf))
char filename[PATH_LIMIT]; return NULL;
int loop_flag; if (read_u32be(0x04,sf) != 0x01)
int channel_count; return NULL;
off_t start_offset; if (read_u32be(0x08,sf) != 0x10000000)
int i; return NULL;
if (read_u32be(0x0c,sf) != 0x00)
/* check extension, case insensitive */ return NULL;
streamFile->get_name(streamFile,filename,sizeof(filename));
if (strcasecmp("dsp",filename_extension(filename))) goto fail; /* .dsp: assumed (no names in .pac bigfile and refs to DSP streams) */
if (!check_extensions(sf, "dsp"))
/* check file size with size given in header */ return NULL;
if ((read_32bitBE(0x0,streamFile)+0xE0) != (get_streamfile_size(streamFile)))
goto fail; channels = 1;
loop_flag = read_u16be(0x2C,sf) != 0x00;
loop_flag = (uint16_t)(read_16bitBE(0x2C,streamFile) != 0x0); start_offset = 0xE0;
channel_count = 1;
/* build the VGMSTREAM */
/* build the VGMSTREAM */ vgmstream = allocate_vgmstream(channels, loop_flag);
vgmstream = allocate_vgmstream(channel_count,loop_flag); if (!vgmstream) goto fail;
if (!vgmstream) goto fail;
vgmstream->sample_rate = read_u32be(0x28,sf);
/* fill in the vital statistics */ vgmstream->num_samples = read_u32be(0x20,sf);
start_offset = 0xE0; vgmstream->loop_start_sample = dsp_bytes_to_samples(read_u32be(0x30,sf), 2);
vgmstream->channels = channel_count; vgmstream->loop_end_sample = dsp_bytes_to_samples(read_u32be(0x34,sf), 2);
vgmstream->sample_rate = read_32bitBE(0x28,streamFile); vgmstream->allow_dual_stereo = true;
vgmstream->coding_type = coding_NGC_DSP;
vgmstream->num_samples = read_32bitBE(0x20,streamFile); vgmstream->meta_type = meta_DSP_KCEJE;
vgmstream->layout_type = layout_none; vgmstream->coding_type = coding_NGC_DSP;
vgmstream->meta_type = meta_DSP_YGO; vgmstream->layout_type = layout_none;
vgmstream->allow_dual_stereo = 1;
if (loop_flag) { dsp_read_coefs_be(vgmstream, sf, 0x3c, 0x00);
vgmstream->loop_start_sample = (read_32bitBE(0x30,streamFile)*14/16);
vgmstream->loop_end_sample = (read_32bitBE(0x34,streamFile)*14/16); if (!vgmstream_open_stream(vgmstream, sf, start_offset))
} goto fail;
return vgmstream;
// read coef stuff
{ fail:
for (i=0;i<16;i++) { close_vgmstream(vgmstream);
vgmstream->ch[0].adpcm_coef[i] = read_16bitBE(0x3C+i*2,streamFile); return NULL;
} }
}
/* 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;
}
}
return vgmstream;
fail:
/* clean up anything we may have opened */
if (vgmstream) close_vgmstream(vgmstream);
return NULL;
}

View File

@ -1,48 +1,46 @@
#include "meta.h" #include "meta.h"
#include "../coding/coding.h" #include "../coding/coding.h"
/* .PCM - KCE Japan East PS2 games (Ephemeral Fantasia, Yu-Gi-Oh! The Duelists of the Roses, 7 Blades) */ /* .PCM - from KCE Japan East PS2 games [Ephemeral Fantasia (PS2), Yu-Gi-Oh! The Duelists of the Roses (PS2), 7 Blades (PS2)] */
VGMSTREAM * init_vgmstream_ps2_pcm(STREAMFILE *streamFile) { VGMSTREAM* init_vgmstream_pcm_kceje(STREAMFILE* sf) {
VGMSTREAM * vgmstream = NULL; VGMSTREAM* vgmstream = NULL;
off_t start_offset; off_t start_offset;
int loop_flag, channel_count; int loop_flag, channels;
/* check extension */ /* checks */
if ( !check_extensions(streamFile,"pcm") ) uint32_t data_size = read_u32le(0x00,sf);
goto fail; if (data_size > 0x00 && data_size + 0x800 >= get_streamfile_size(sf) && data_size + 0x1000 <= get_streamfile_size(sf))
return NULL; /* usually 0x800 but may be padded */
/* check header (data_size vs num_samples) */ if (pcm16_bytes_to_samples(data_size, 2) != read_u32le(0x04,sf))
if (pcm_bytes_to_samples(read_32bitLE(0x00,streamFile), 2, 16) != read_32bitLE(0x04,streamFile)) return NULL;
goto fail;
/* should work too */ if (!check_extensions(sf,"pcm"))
//if (read_32bitLE(0x00,streamFile)+0x800 != get_streamfile_size(streamFile)) return NULL;
// goto fail;
loop_flag = (read_s32le(0x0C,sf) != 0x00);
loop_flag = (read_32bitLE(0x0C,streamFile) != 0x00); channels = 2;
channel_count = 2; start_offset = 0x800;
start_offset = 0x800;
/* build the VGMSTREAM */
/* build the VGMSTREAM */ vgmstream = allocate_vgmstream(channels, loop_flag);
vgmstream = allocate_vgmstream(channel_count,loop_flag); if (!vgmstream) goto fail;
if (!vgmstream) goto fail;
vgmstream->channels = channels;
vgmstream->channels = channel_count; vgmstream->sample_rate = 24000;
vgmstream->sample_rate = 24000; vgmstream->num_samples = read_s32le(0x04,sf);
vgmstream->num_samples = read_32bitLE(0x04,streamFile); vgmstream->loop_start_sample = read_s32le(0x08,sf);
vgmstream->loop_start_sample = read_32bitLE(0x08,streamFile); vgmstream->loop_end_sample = read_s32le(0x0C,sf);
vgmstream->loop_end_sample = read_32bitLE(0x0C,streamFile);
vgmstream->coding_type = coding_PCM16LE;
vgmstream->coding_type = coding_PCM16LE; vgmstream->layout_type = layout_interleave;
vgmstream->layout_type = layout_interleave; vgmstream->interleave_block_size = 0x02;
vgmstream->interleave_block_size = 0x2; vgmstream->meta_type = meta_PCM_KCEJE;
vgmstream->meta_type = meta_PS2_PCM;
if (!vgmstream_open_stream(vgmstream, sf, start_offset))
/* open the file for reading */ goto fail;
if ( !vgmstream_open_stream(vgmstream, streamFile, start_offset) ) return vgmstream;
goto fail;
return vgmstream; fail:
if (vgmstream) close_vgmstream(vgmstream);
fail: return NULL;
if (vgmstream) close_vgmstream(vgmstream); }
return NULL;
}

View File

@ -244,8 +244,8 @@ static int read_fmt(int big_endian, STREAMFILE* sf, off_t offset, riff_fmt_chunk
/* real 0x300 is "Fujitsu FM Towns SND" with block align 0x01 */ /* real 0x300 is "Fujitsu FM Towns SND" with block align 0x01 */
break; break;
case 0x0555: /* Level-5 0x555 ADPCM (unofficial) */ case 0x0555: /* Level-5 ADPCM (unofficial) */
fmt->coding_type = coding_L5_555; fmt->coding_type = coding_LEVEL5;
fmt->interleave = 0x12; fmt->interleave = 0x12;
break; break;
@ -473,7 +473,7 @@ VGMSTREAM* init_vgmstream_riff(STREAMFILE* sf) {
file_size -= 0x40; /* [Megami no Etsubo (PSP)] (has extra padding in all files) */ file_size -= 0x40; /* [Megami no Etsubo (PSP)] (has extra padding in all files) */
else if (codec == 0x0011 && file_size - riff_size - 0x08 <= 0x900 && is_id32be(riff_size + 0x08, sf, "cont")) else if (codec == 0x0011 && file_size - riff_size - 0x08 <= 0x900 && is_id32be(riff_size + 0x08, sf, "cont"))
riff_size = file_size - 0x08; /* [Shin Megami Tensei: Imagine (PC)] (extra "cont" info 0x800/0x900 chunk) */ riff_size = file_size - 0x08; /* [Shin Megami Tensei: Imagine (PC)] (extra "cont" info 0x800/0x900 chunk) */
} }
@ -738,7 +738,7 @@ VGMSTREAM* init_vgmstream_riff(STREAMFILE* sf) {
vgmstream->num_samples = pcm_bytes_to_samples(data_size, fmt.channels, fmt.bps); vgmstream->num_samples = pcm_bytes_to_samples(data_size, fmt.channels, fmt.bps);
break; break;
case coding_L5_555: case coding_LEVEL5:
vgmstream->num_samples = data_size / 0x12 / fmt.channels * 32; vgmstream->num_samples = data_size / 0x12 / fmt.channels * 32;
/* coefs */ /* coefs */
@ -912,7 +912,7 @@ VGMSTREAM* init_vgmstream_riff(STREAMFILE* sf) {
vgmstream->loop_end_sample = loop_end_wsmp; vgmstream->loop_end_sample = loop_end_wsmp;
vgmstream->meta_type = meta_RIFF_WAVE_wsmp; vgmstream->meta_type = meta_RIFF_WAVE_wsmp;
} }
else if (fmt.coding_type == coding_L5_555 && mwv_ctrl_offset) { else if (fmt.coding_type == coding_LEVEL5 && mwv_ctrl_offset) {
vgmstream->loop_start_sample = read_s32le(mwv_ctrl_offset + 0x0c, sf); vgmstream->loop_start_sample = read_s32le(mwv_ctrl_offset + 0x0c, sf);
vgmstream->loop_end_sample = vgmstream->num_samples; vgmstream->loop_end_sample = vgmstream->num_samples;
vgmstream->meta_type = meta_RIFF_WAVE_MWV; vgmstream->meta_type = meta_RIFF_WAVE_MWV;

View File

@ -81,7 +81,6 @@ init_vgmstream_t init_vgmstream_functions[] = {
init_vgmstream_vig_kces, init_vgmstream_vig_kces,
init_vgmstream_hxd, init_vgmstream_hxd,
init_vgmstream_vsv, init_vgmstream_vsv,
init_vgmstream_ps2_pcm,
init_vgmstream_ps2_rkv, init_vgmstream_ps2_rkv,
init_vgmstream_lp_ap_lep, init_vgmstream_lp_ap_lep,
init_vgmstream_sdt, init_vgmstream_sdt,
@ -158,7 +157,7 @@ init_vgmstream_t init_vgmstream_functions[] = {
init_vgmstream_naomi_adpcm, init_vgmstream_naomi_adpcm,
init_vgmstream_sd9, init_vgmstream_sd9,
init_vgmstream_2dx9, init_vgmstream_2dx9,
init_vgmstream_dsp_ygo, init_vgmstream_dsp_kceje,
init_vgmstream_ps2_vgv, init_vgmstream_ps2_vgv,
init_vgmstream_gcub, init_vgmstream_gcub,
init_vgmstream_maxis_xa, init_vgmstream_maxis_xa,
@ -527,6 +526,7 @@ init_vgmstream_t init_vgmstream_functions[] = {
init_vgmstream_tgc, init_vgmstream_tgc,
init_vgmstream_rage_aud, init_vgmstream_rage_aud,
init_vgmstream_asd_naxat, init_vgmstream_asd_naxat,
init_vgmstream_pcm_kceje,
/* need companion files */ /* need companion files */
init_vgmstream_pos, init_vgmstream_pos,
init_vgmstream_sli_loops, init_vgmstream_sli_loops,

View File

@ -106,7 +106,7 @@ typedef enum {
coding_TGC, /* Tiger Game.com 4-bit ADPCM */ coding_TGC, /* Tiger Game.com 4-bit ADPCM */
coding_NDS_PROCYON, /* Procyon Studio ADPCM */ coding_NDS_PROCYON, /* Procyon Studio ADPCM */
coding_L5_555, /* Level-5 0x555 ADPCM */ coding_LEVEL5, /* Level-5 ADPCM */
coding_LSF, /* lsf ADPCM (Fastlane Street Racing iPhone)*/ coding_LSF, /* lsf ADPCM (Fastlane Street Racing iPhone)*/
coding_MTAF, /* Konami MTAF ADPCM */ coding_MTAF, /* Konami MTAF ADPCM */
coding_MTA2, /* Konami MTA2 ADPCM */ coding_MTA2, /* Konami MTA2 ADPCM */
@ -265,7 +265,7 @@ typedef enum {
meta_MUS_KROME, meta_MUS_KROME,
meta_DSP_WII_WSD, /* Phantom Brave (WII) */ meta_DSP_WII_WSD, /* Phantom Brave (WII) */
meta_WII_NDP, /* Vertigo (Wii) */ meta_WII_NDP, /* Vertigo (Wii) */
meta_DSP_YGO, /* Konami: Yu-Gi-Oh! The Falsebound Kingdom (NGC), Hikaru no Go 3 (NGC) */ meta_DSP_KCEJE,
meta_STRM, /* Nintendo STRM */ meta_STRM, /* Nintendo STRM */
meta_RSTM, /* Nintendo RSTM (Revolution Stream, similar to STRM) */ meta_RSTM, /* Nintendo RSTM (Revolution Stream, similar to STRM) */
@ -345,7 +345,7 @@ typedef enum {
meta_HXD, meta_HXD,
meta_VSV, meta_VSV,
meta_SCD_PCM, /* Lunar - Eternal Blue */ meta_SCD_PCM, /* Lunar - Eternal Blue */
meta_PS2_PCM, /* Konami KCEJ East: Ephemeral Fantasia, Yu-Gi-Oh! The Duelists of the Roses, 7 Blades */ meta_PCM_KCEJE,
meta_PS2_RKV, /* Legacy of Kain - Blood Omen 2 (PS2) */ meta_PS2_RKV, /* Legacy of Kain - Blood Omen 2 (PS2) */
meta_VAS_KCEO, meta_VAS_KCEO,
meta_LP_AP_LEP, meta_LP_AP_LEP,
@ -429,8 +429,8 @@ typedef enum {
meta_MUS_ACM, /* MUS playlist of InterPlay ACM files */ meta_MUS_ACM, /* MUS playlist of InterPlay ACM files */
meta_DEC, /* Falcom PC games (Xanadu Next, Gurumin) */ meta_DEC, /* Falcom PC games (Xanadu Next, Gurumin) */
meta_VS, /* Men in Black .vs */ meta_VS, /* Men in Black .vs */
meta_FFXI_BGW, /* FFXI (PC) BGW */ meta_BGW,
meta_FFXI_SPW, /* FFXI (PC) SPW */ meta_SPW,
meta_STS, meta_STS,
meta_P2BT_MOVE_VISA, meta_P2BT_MOVE_VISA,
meta_GBTS, meta_GBTS,
@ -505,7 +505,7 @@ typedef enum {
meta_EB_SF0, /* Excitebots .sf0 */ meta_EB_SF0, /* Excitebots .sf0 */
meta_MTAF, meta_MTAF,
meta_ALP, meta_ALP,
meta_WPD, /* Shuffle! (PC) */ meta_WPD,
meta_MN_STR, /* Mini Ninjas (PC/PS3/WII) */ meta_MN_STR, /* Mini Ninjas (PC/PS3/WII) */
meta_MSS, /* Guerilla: ShellShock Nam '67 (PS2/Xbox), Killzone (PS2) */ meta_MSS, /* Guerilla: ShellShock Nam '67 (PS2/Xbox), Killzone (PS2) */
meta_PS2_HSF, /* Lowrider (PS2) */ meta_PS2_HSF, /* Lowrider (PS2) */