From d2925316548cc95fa86873f7b88db2c5487cf31b Mon Sep 17 00:00:00 2001 From: bnnm Date: Sun, 29 Apr 2018 21:04:55 +0200 Subject: [PATCH] Add switch_audio [Gal Gun 2 (Switch)] --- src/formats.c | 4 +++- src/meta/meta.h | 1 + src/meta/ngc_dsp_std.c | 28 ++++++++++++++++++++++++++++ src/vgmstream.c | 1 + src/vgmstream.h | 1 + 5 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/formats.c b/src/formats.c index 16e8ec66..647ccc51 100644 --- a/src/formats.c +++ b/src/formats.c @@ -338,6 +338,7 @@ static const char* extension_list[] = { "swag", "swav", "swd", + "switch_audio" "sx", "sxd", "sxd2", @@ -487,7 +488,7 @@ static const coding_info coding_info_list[] = { {coding_PSX, "Playstation 4-bit ADPCM"}, {coding_PSX_badflags, "Playstation 4-bit ADPCM (bad flags)"}, {coding_PSX_cfg, "Playstation 4-bit ADPCM (configurable)"}, - {coding_HEVAG, "Playstation Vita HEVAG 4-bit ADPCM"}, + {coding_HEVAG, "Sony HEVAG 4-bit ADPCM"}, {coding_EA_XA, "Electronic Arts EA-XA 4-bit ADPCM v1"}, {coding_EA_XA_int, "Electronic Arts EA-XA 4-bit ADPCM v1 (mono/interleave)"}, @@ -1009,6 +1010,7 @@ static const meta_info meta_info_list[] = { {meta_PPST, "Parappa PPST header"}, {meta_OPUS_PPP, "AT9 OPUS header"}, {meta_UBI_BAO, "Ubisoft BAO header"}, + {meta_DSP_SWITCH_AUDIO, "UE4 Switch Audio header"}, #ifdef VGM_USE_FFMPEG {meta_FFmpeg, "FFmpeg supported file format"}, diff --git a/src/meta/meta.h b/src/meta/meta.h index eb0c4545..c32d4715 100644 --- a/src/meta/meta.h +++ b/src/meta/meta.h @@ -749,4 +749,5 @@ VGMSTREAM * init_vgmstream_opus_ppp(STREAMFILE *streamFile); VGMSTREAM * init_vgmstream_ubi_bao_pk(STREAMFILE *streamFile); +VGMSTREAM * init_vgmstream_dsp_switch_audio(STREAMFILE *streamFile); #endif /*_META_H*/ diff --git a/src/meta/ngc_dsp_std.c b/src/meta/ngc_dsp_std.c index 6476191f..990a1c21 100644 --- a/src/meta/ngc_dsp_std.c +++ b/src/meta/ngc_dsp_std.c @@ -1340,3 +1340,31 @@ VGMSTREAM * init_vgmstream_dsp_mcadpcm(STREAMFILE *streamFile) { fail: return NULL; } + +/* .switch_audio - UE4 standard LE header + full interleaved dsp [Gal Gun 2 (Switch)] */ +VGMSTREAM * init_vgmstream_dsp_switch_audio(STREAMFILE *streamFile) { + dsp_meta dspm = {0}; + + /* checks */ + /* .switch_audio: possibly UE4 class name rather than extension, .dsp: assumed */ + if (!check_extensions(streamFile, "switch_audio,dsp")) + goto fail; + + /* manual double header test */ + if (read_32bitLE(0x00, streamFile) == read_32bitLE(get_streamfile_size(streamFile) / 2, streamFile)) + dspm.channel_count = 2; + else + dspm.channel_count = 1; + dspm.max_channels = 2; + dspm.little_endian = 1; + + dspm.header_offset = 0x00; + dspm.header_spacing = get_streamfile_size(streamFile) / dspm.channel_count; + dspm.start_offset = dspm.header_offset + 0x60; + dspm.interleave = dspm.header_spacing; + + dspm.meta_type = meta_DSP_SWITCH_AUDIO; + return init_vgmstream_dsp_common(streamFile, &dspm); +fail: + return NULL; +} diff --git a/src/vgmstream.c b/src/vgmstream.c index 9a0926bf..832b36b1 100644 --- a/src/vgmstream.c +++ b/src/vgmstream.c @@ -406,6 +406,7 @@ VGMSTREAM * (*init_vgmstream_functions[])(STREAMFILE *streamFile) = { init_vgmstream_ppst, init_vgmstream_opus_ppp, init_vgmstream_ubi_bao_pk, + init_vgmstream_dsp_switch_audio, init_vgmstream_txth, /* should go at the end (lower priority) */ #ifdef VGM_USE_FFMPEG diff --git a/src/vgmstream.h b/src/vgmstream.h index 1c7a7ca7..229174fc 100644 --- a/src/vgmstream.h +++ b/src/vgmstream.h @@ -674,6 +674,7 @@ typedef enum { meta_PPST, /* PPST [Parappa the Rapper (PSP)] */ meta_OPUS_PPP, /* .at9 Opus [Penny-Punching Princess (Switch)] */ meta_UBI_BAO, /* Ubisoft BAO */ + meta_DSP_SWITCH_AUDIO, /* Gal Gun 2 (Switch) */ #ifdef VGM_USE_FFMPEG meta_FFmpeg,