mirror of
https://github.com/vgmstream/vgmstream.git
synced 2024-11-28 00:20:47 +01:00
cleanup: misc
This commit is contained in:
parent
d96cf21fc0
commit
88b54b5257
@ -1316,7 +1316,7 @@ static const meta_info meta_info_list[] = {
|
||||
{meta_MSB_MSH, "Sony MultiStream MSH+MSB header"},
|
||||
{meta_TXTP, "TXTP generic header"},
|
||||
{meta_SMC_SMH, "Genki SMC+SMH header"},
|
||||
{meta_PPST, "Parappa PPST header"},
|
||||
{meta_PPST, "epics PPST header"},
|
||||
{meta_SPS_N1, "Nippon Ichi .SPS header"},
|
||||
{meta_UBI_BAO, "Ubisoft BAO header"},
|
||||
{meta_DSP_SWITCH_AUDIO, "UE4 Switch Audio header"},
|
||||
|
109
src/meta/gin.c
109
src/meta/gin.c
@ -1,55 +1,54 @@
|
||||
#include "meta.h"
|
||||
#include "../coding/coding.h"
|
||||
|
||||
/* .gin - EA engine sounds [Need for Speed: Most Wanted (multi)] */
|
||||
VGMSTREAM * init_vgmstream_gin(STREAMFILE *sf) {
|
||||
VGMSTREAM *vgmstream = NULL;
|
||||
off_t start_offset;
|
||||
int loop_flag, channel_count, sample_rate, num_samples;
|
||||
|
||||
if (!check_extensions(sf, "gin"))
|
||||
goto fail;
|
||||
|
||||
/* checks */
|
||||
if (!is_id32be(0x00, sf, "Gnsu") && /* original */
|
||||
!is_id32be(0x00, sf, "Octn")) /* later (2013+) games, looks same as "Gnsu" */
|
||||
goto fail;
|
||||
|
||||
/* contains mapped values for engine RPM sounds but we'll just play the whole thing */
|
||||
/* 0x04: size? "20\00\00"? */
|
||||
/* 0x08/0c: min/max float RPM? */
|
||||
/* 0x10: RPM up? (pitch/frequency) table size */
|
||||
/* 0x14: RPM ??? table size */
|
||||
/* always LE even on X360/PS3 */
|
||||
|
||||
num_samples = read_u32le(0x18, sf);
|
||||
sample_rate = read_u32le(0x1c, sf);
|
||||
start_offset = 0x20 +
|
||||
(read_u32le(0x10, sf) + 1) * 0x04 +
|
||||
(read_u32le(0x14, sf) + 1) * 0x04;
|
||||
channel_count = 1;
|
||||
loop_flag = 0;
|
||||
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
vgmstream = allocate_vgmstream(channel_count, loop_flag);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
vgmstream->meta_type = meta_GIN;
|
||||
vgmstream->sample_rate = sample_rate;
|
||||
vgmstream->num_samples = num_samples;
|
||||
|
||||
vgmstream->coding_type = coding_EA_XAS_V0;
|
||||
vgmstream->layout_type = layout_none;
|
||||
|
||||
/* calculate size for TMX */
|
||||
vgmstream->stream_size = (align_size_to_block(num_samples, 32) / 32) * 0x13;
|
||||
|
||||
if (!vgmstream_open_stream(vgmstream, sf, start_offset))
|
||||
goto fail;
|
||||
return vgmstream;
|
||||
|
||||
fail:
|
||||
close_vgmstream(vgmstream);
|
||||
return NULL;
|
||||
}
|
||||
#include "meta.h"
|
||||
#include "../coding/coding.h"
|
||||
|
||||
/* .gin - EA engine sounds [Need for Speed: Most Wanted (multi)] */
|
||||
VGMSTREAM* init_vgmstream_gin(STREAMFILE* sf) {
|
||||
VGMSTREAM* vgmstream = NULL;
|
||||
off_t start_offset;
|
||||
int loop_flag, channel_count, sample_rate, num_samples;
|
||||
|
||||
/* checks */
|
||||
if (!is_id32be(0x00, sf, "Gnsu") && /* original */
|
||||
!is_id32be(0x00, sf, "Octn")) /* later (2013+) games */
|
||||
return NULL;
|
||||
if (!check_extensions(sf, "gin"))
|
||||
return NULL;
|
||||
|
||||
/* contains mapped values for engine RPM sounds but we'll just play the whole thing */
|
||||
/* 0x04: size? "20\00\00"? */
|
||||
/* 0x08/0c: min/max float RPM? */
|
||||
/* 0x10: RPM up? (pitch/frequency) table size */
|
||||
/* 0x14: RPM ??? table size */
|
||||
/* always LE even on X360/PS3 */
|
||||
|
||||
num_samples = read_u32le(0x18, sf);
|
||||
sample_rate = read_u32le(0x1c, sf);
|
||||
start_offset = 0x20 +
|
||||
(read_u32le(0x10, sf) + 1) * 0x04 +
|
||||
(read_u32le(0x14, sf) + 1) * 0x04;
|
||||
channel_count = 1;
|
||||
loop_flag = 0;
|
||||
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
vgmstream = allocate_vgmstream(channel_count, loop_flag);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
vgmstream->meta_type = meta_GIN;
|
||||
vgmstream->sample_rate = sample_rate;
|
||||
vgmstream->num_samples = num_samples;
|
||||
|
||||
vgmstream->coding_type = coding_EA_XAS_V0;
|
||||
vgmstream->layout_type = layout_none;
|
||||
|
||||
/* calculate size for TMX */
|
||||
vgmstream->stream_size = (align_size_to_block(num_samples, 32) / 32) * 0x13;
|
||||
|
||||
if (!vgmstream_open_stream(vgmstream, sf, start_offset))
|
||||
goto fail;
|
||||
return vgmstream;
|
||||
|
||||
fail:
|
||||
close_vgmstream(vgmstream);
|
||||
return NULL;
|
||||
}
|
||||
|
165
src/meta/kma9.c
165
src/meta/kma9.c
@ -1,83 +1,82 @@
|
||||
#include "meta.h"
|
||||
#include "../coding/coding.h"
|
||||
#include "kma9_streamfile.h"
|
||||
|
||||
|
||||
/* KMA9 - Koei Tecmo's interleaved ATRAC9 [Nobunaga no Yabou - Souzou (Vita)] */
|
||||
VGMSTREAM * init_vgmstream_kma9(STREAMFILE *streamFile) {
|
||||
VGMSTREAM * vgmstream = NULL;
|
||||
STREAMFILE* temp_streamFile = NULL;
|
||||
off_t start_offset;
|
||||
size_t stream_size, interleave;
|
||||
int loop_flag, channel_count;
|
||||
int total_subsongs = 0, target_subsong = streamFile->stream_index;
|
||||
|
||||
|
||||
/* checks */
|
||||
if ( !check_extensions(streamFile,"km9") )
|
||||
goto fail;
|
||||
if (read_32bitBE(0x00,streamFile) != 0x4B4D4139) /* "KMA9" */
|
||||
goto fail;
|
||||
|
||||
start_offset = read_32bitLE(0x04,streamFile);
|
||||
channel_count = read_16bitLE(0x32,streamFile);
|
||||
loop_flag = (read_32bitLE(0x28,streamFile) != 0);
|
||||
|
||||
total_subsongs = read_32bitLE(0x08,streamFile);
|
||||
if (target_subsong == 0) target_subsong = 1;
|
||||
if (target_subsong < 0 || target_subsong > total_subsongs || total_subsongs < 1) goto fail;
|
||||
/* 0x0c: unknown */
|
||||
interleave = read_32bitLE(0x10,streamFile); /* 1 superframe */
|
||||
stream_size = read_32bitLE(0x14,streamFile); /* per subsong */
|
||||
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
vgmstream->sample_rate = read_32bitLE(0x34,streamFile);
|
||||
vgmstream->num_samples = read_32bitLE(0x18,streamFile); /* without skip_samples? */
|
||||
vgmstream->loop_start_sample = read_32bitLE(0x24,streamFile); /* with skip_samples? */
|
||||
vgmstream->loop_end_sample = vgmstream->num_samples; /* 0x28 looks like end samples but isn't, no idea */
|
||||
vgmstream->num_streams = total_subsongs;
|
||||
vgmstream->stream_size = stream_size;
|
||||
vgmstream->meta_type = meta_KMA9;
|
||||
|
||||
#ifdef VGM_USE_ATRAC9
|
||||
{
|
||||
atrac9_config cfg = {0};
|
||||
|
||||
cfg.channels = vgmstream->channels;
|
||||
cfg.encoder_delay = read_32bitLE(0x20,streamFile);
|
||||
cfg.config_data = read_32bitBE(0x5c,streamFile);
|
||||
|
||||
vgmstream->codec_data = init_atrac9(&cfg);
|
||||
if (!vgmstream->codec_data) goto fail;
|
||||
vgmstream->coding_type = coding_ATRAC9;
|
||||
vgmstream->layout_type = layout_none;
|
||||
|
||||
if (loop_flag) { /* seems correct but must double check */
|
||||
vgmstream->loop_start_sample -= cfg.encoder_delay;
|
||||
//vgmstream->loop_end_sample -= cfg.encoder_delay;
|
||||
}
|
||||
|
||||
/* KMA9 interleaves one ATRAC9 frame per subsong */
|
||||
temp_streamFile = setup_kma9_streamfile(streamFile, start_offset, stream_size, interleave, (target_subsong-1), total_subsongs);
|
||||
if (!temp_streamFile) goto fail;
|
||||
start_offset = 0;
|
||||
}
|
||||
#else
|
||||
goto fail;
|
||||
#endif
|
||||
|
||||
/* open the file for reading */
|
||||
if ( !vgmstream_open_stream(vgmstream, temp_streamFile, start_offset) )
|
||||
goto fail;
|
||||
close_streamfile(temp_streamFile);
|
||||
return vgmstream;
|
||||
|
||||
fail:
|
||||
close_streamfile(temp_streamFile);
|
||||
close_vgmstream(vgmstream);
|
||||
return NULL;
|
||||
}
|
||||
#include "meta.h"
|
||||
#include "../coding/coding.h"
|
||||
#include "kma9_streamfile.h"
|
||||
|
||||
|
||||
/* KMA9 - Koei Tecmo games [Nobunaga no Yabou: Souzou (Vita)] */
|
||||
VGMSTREAM* init_vgmstream_kma9(STREAMFILE* sf) {
|
||||
VGMSTREAM* vgmstream = NULL;
|
||||
STREAMFILE* temp_sf = NULL;
|
||||
off_t start_offset;
|
||||
size_t stream_size, interleave;
|
||||
int loop_flag, channels;
|
||||
int total_subsongs = 0, target_subsong = sf->stream_index;
|
||||
|
||||
|
||||
/* checks */
|
||||
if (!is_id32be(0x00,sf, "KMA9"))
|
||||
return NULL;
|
||||
if (!check_extensions(sf,"km9"))
|
||||
return NULL;
|
||||
|
||||
start_offset = read_u32le(0x04,sf);
|
||||
channels = read_u16le(0x32,sf);
|
||||
loop_flag = (read_s32le(0x28,sf) != 0);
|
||||
|
||||
total_subsongs = read_s32le(0x08,sf);
|
||||
if (target_subsong == 0) target_subsong = 1;
|
||||
if (target_subsong < 0 || target_subsong > total_subsongs || total_subsongs < 1) goto fail;
|
||||
/* 0x0c: unknown */
|
||||
interleave = read_u32le(0x10,sf); /* 1 superframe */
|
||||
stream_size = read_u32le(0x14,sf); /* per subsong */
|
||||
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
vgmstream = allocate_vgmstream(channels, loop_flag);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
vgmstream->sample_rate = read_s32le(0x34,sf);
|
||||
vgmstream->num_samples = read_s32le(0x18,sf); /* without skip_samples? */
|
||||
vgmstream->loop_start_sample = read_s32le(0x24,sf); /* with skip_samples? */
|
||||
vgmstream->loop_end_sample = vgmstream->num_samples; /* 0x28 looks like end samples but isn't, no idea */
|
||||
vgmstream->num_streams = total_subsongs;
|
||||
vgmstream->stream_size = stream_size;
|
||||
vgmstream->meta_type = meta_KMA9;
|
||||
|
||||
#ifdef VGM_USE_ATRAC9
|
||||
{
|
||||
atrac9_config cfg = {0};
|
||||
|
||||
cfg.channels = channels;
|
||||
cfg.encoder_delay = read_s32le(0x20,sf);
|
||||
cfg.config_data = read_u32be(0x5c,sf);
|
||||
|
||||
vgmstream->codec_data = init_atrac9(&cfg);
|
||||
if (!vgmstream->codec_data) goto fail;
|
||||
vgmstream->coding_type = coding_ATRAC9;
|
||||
vgmstream->layout_type = layout_none;
|
||||
|
||||
if (loop_flag) { /* seems correct but must double check */
|
||||
vgmstream->loop_start_sample -= cfg.encoder_delay;
|
||||
//vgmstream->loop_end_sample -= cfg.encoder_delay;
|
||||
}
|
||||
|
||||
/* KMA9 interleaves one ATRAC9 frame per subsong */
|
||||
temp_sf = setup_kma9_streamfile(sf, start_offset, stream_size, interleave, (target_subsong-1), total_subsongs);
|
||||
if (!temp_sf) goto fail;
|
||||
start_offset = 0;
|
||||
}
|
||||
#else
|
||||
goto fail;
|
||||
#endif
|
||||
|
||||
if (!vgmstream_open_stream(vgmstream, temp_sf, start_offset))
|
||||
goto fail;
|
||||
close_streamfile(temp_sf);
|
||||
return vgmstream;
|
||||
|
||||
fail:
|
||||
close_streamfile(temp_sf);
|
||||
close_vgmstream(vgmstream);
|
||||
return NULL;
|
||||
}
|
||||
|
120
src/meta/ppst.c
120
src/meta/ppst.c
@ -1,60 +1,60 @@
|
||||
#include "meta.h"
|
||||
#include "../coding/coding.h"
|
||||
#include "ppst_streamfile.h"
|
||||
|
||||
|
||||
/* PPST - ParaPpa STream (maybe), extracted from .img bigfile [Parappa the Rapper (PSP)] */
|
||||
VGMSTREAM * init_vgmstream_ppst(STREAMFILE *streamFile) {
|
||||
VGMSTREAM * vgmstream = NULL;
|
||||
int total_subsongs, target_subsong = streamFile->stream_index;
|
||||
|
||||
|
||||
/* checks */
|
||||
if (!check_extensions(streamFile, "sng"))
|
||||
goto fail;
|
||||
if (read_32bitBE(0x00,streamFile) != 0x50505354) /* "PPST" */
|
||||
goto fail;
|
||||
|
||||
/* header has some control and comment fields then interleaved RIFF .at3 */
|
||||
|
||||
/* count subsongs (mainly 4, rarely 1) */
|
||||
{
|
||||
off_t offset = 0xa0;
|
||||
|
||||
total_subsongs = 0;
|
||||
while (offset < 0x800) {
|
||||
if (read_32bitLE(offset + 0x04, streamFile) == 0) /* subsong size */
|
||||
break;
|
||||
total_subsongs++;
|
||||
offset += 0x08;
|
||||
}
|
||||
|
||||
if (target_subsong == 0) target_subsong = 1;
|
||||
if (target_subsong < 0 || target_subsong > total_subsongs || total_subsongs < 1) goto fail;
|
||||
}
|
||||
|
||||
{
|
||||
off_t start_offset = 0x800;
|
||||
size_t interleave_size = 0x4000;
|
||||
size_t stride_size = 0x4000*total_subsongs;
|
||||
/* subsong header at 0xa0, 0x00(1): id, 0x01(3): blocks of interleave */
|
||||
size_t stream_size = read_32bitLE(0xA0+0x08*(target_subsong-1)+0x04, streamFile);
|
||||
|
||||
STREAMFILE* temp_streamFile = setup_ppst_streamfile(streamFile, start_offset+interleave_size*(target_subsong-1), interleave_size, stride_size, stream_size);
|
||||
if (!temp_streamFile) goto fail;
|
||||
|
||||
vgmstream = init_vgmstream_riff(temp_streamFile);
|
||||
close_streamfile(temp_streamFile);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
vgmstream->num_streams = total_subsongs;
|
||||
vgmstream->stream_size = stream_size;
|
||||
vgmstream->meta_type = meta_PPST;
|
||||
}
|
||||
|
||||
return vgmstream;
|
||||
|
||||
fail:
|
||||
close_vgmstream(vgmstream);
|
||||
return NULL;
|
||||
}
|
||||
#include "meta.h"
|
||||
#include "../coding/coding.h"
|
||||
#include "ppst_streamfile.h"
|
||||
|
||||
|
||||
/* PPST - ParaPpa STream (maybe) [Parappa the Rapper (PSP)] */
|
||||
VGMSTREAM* init_vgmstream_ppst(STREAMFILE* sf) {
|
||||
VGMSTREAM* vgmstream = NULL;
|
||||
int total_subsongs, target_subsong = sf->stream_index;
|
||||
|
||||
|
||||
/* checks */
|
||||
if (!is_id32be(0x00,sf, "PPST"))
|
||||
return NULL;
|
||||
if (!check_extensions(sf, "sng"))
|
||||
return NULL;
|
||||
|
||||
/* header has some control and comment fields then interleaved RIFF .at3 */
|
||||
|
||||
/* count subsongs (mainly 4, rarely 1) */
|
||||
{
|
||||
off_t offset = 0xa0;
|
||||
|
||||
total_subsongs = 0;
|
||||
while (offset < 0x800) {
|
||||
if (read_u32le(offset + 0x04, sf) == 0) /* subsong size */
|
||||
break;
|
||||
total_subsongs++;
|
||||
offset += 0x08;
|
||||
}
|
||||
|
||||
if (target_subsong == 0) target_subsong = 1;
|
||||
if (target_subsong < 0 || target_subsong > total_subsongs || total_subsongs < 1) goto fail;
|
||||
}
|
||||
|
||||
{
|
||||
off_t start_offset = 0x800;
|
||||
size_t interleave_size = 0x4000;
|
||||
size_t stride_size = 0x4000 * total_subsongs;
|
||||
/* subsong header at 0xa0, 0x00(1): id, 0x01(3): blocks of interleave */
|
||||
size_t stream_size = read_u32le(0xA0 + 0x08 * (target_subsong - 1) + 0x04, sf);
|
||||
|
||||
STREAMFILE* temp_sf = setup_ppst_streamfile(sf, start_offset + interleave_size * (target_subsong - 1), interleave_size, stride_size, stream_size);
|
||||
if (!temp_sf) goto fail;
|
||||
|
||||
vgmstream = init_vgmstream_riff(temp_sf);
|
||||
close_streamfile(temp_sf);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
vgmstream->num_streams = total_subsongs;
|
||||
vgmstream->stream_size = stream_size;
|
||||
vgmstream->meta_type = meta_PPST;
|
||||
}
|
||||
|
||||
return vgmstream;
|
||||
|
||||
fail:
|
||||
close_vgmstream(vgmstream);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -14,9 +14,9 @@ VGMSTREAM* init_vgmstream_sndp(STREAMFILE* sf) {
|
||||
|
||||
bool loop_flag = (read_u32be(0x1c,sf) !=0);
|
||||
int channels = read_u16be(0x0c,sf);
|
||||
off_t start_offset = 0x30;
|
||||
off_t start_offset = 0x30;
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
/* build the VGMSTREAM */
|
||||
vgmstream = allocate_vgmstream(channels, loop_flag);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
|
@ -583,7 +583,7 @@ typedef enum {
|
||||
meta_MSB_MSH, /* sfx companion of MIH+MIB */
|
||||
meta_TXTP,
|
||||
meta_SMC_SMH, /* Wangan Midnight (System 246) */
|
||||
meta_PPST, /* PPST [Parappa the Rapper (PSP)] */
|
||||
meta_PPST,
|
||||
meta_SPS_N1,
|
||||
meta_UBI_BAO,
|
||||
meta_DSP_SWITCH_AUDIO, /* Gal Gun 2 (Switch) */
|
||||
|
Loading…
Reference in New Issue
Block a user