From 0db009b3e6d37bfb73e8904f5ca04608dde035ab Mon Sep 17 00:00:00 2001 From: bxaimc Date: Sun, 10 Dec 2017 20:30:00 -0500 Subject: [PATCH] Add Harmonix Music Systems MOGG Vorbis --- src/formats.c | 2 ++ src/libvgmstream.vcproj | 4 +++ src/libvgmstream.vcxproj | 1 + src/libvgmstream.vcxproj.filters | 3 +++ src/meta/meta.h | 2 ++ src/meta/mogg.c | 42 ++++++++++++++++++++++++++++++++ src/vgmstream.c | 1 + src/vgmstream.h | 1 + 8 files changed, 56 insertions(+) create mode 100644 src/meta/mogg.c diff --git a/src/formats.c b/src/formats.c index 14ff77b1..a8307210 100644 --- a/src/formats.c +++ b/src/formats.c @@ -180,6 +180,7 @@ static const char* extension_list[] = { "mic", "mihb", "mnstr", + "mogg", //"mp4", //common //"mpc", //FFmpeg, not parsed (musepack) //common "mpdsp", @@ -924,6 +925,7 @@ static const meta_info meta_info_list[] = { {meta_EA_SPS, "Electronic Arts SPS header"}, {meta_NGC_VID1, "Neversoft VID1 header"}, {meta_PC_FLX, "Ultima IX .FLX header"}, + {meta_MOGG, "Harmonix Music Systems MOGG Vorbis "}, #ifdef VGM_USE_VORBIS diff --git a/src/libvgmstream.vcproj b/src/libvgmstream.vcproj index b1486969..3b307b75 100644 --- a/src/libvgmstream.vcproj +++ b/src/libvgmstream.vcproj @@ -500,6 +500,10 @@ RelativePath=".\meta\mn_str.c" > + + diff --git a/src/libvgmstream.vcxproj b/src/libvgmstream.vcxproj index 07ab26f1..e4b36c61 100644 --- a/src/libvgmstream.vcxproj +++ b/src/libvgmstream.vcxproj @@ -161,6 +161,7 @@ + diff --git a/src/libvgmstream.vcxproj.filters b/src/libvgmstream.vcxproj.filters index f60439c1..01811bf0 100644 --- a/src/libvgmstream.vcxproj.filters +++ b/src/libvgmstream.vcxproj.filters @@ -1240,5 +1240,8 @@ meta\Source Files + + meta\Source Files + \ No newline at end of file diff --git a/src/meta/meta.h b/src/meta/meta.h index af6a0489..bc0ba6b0 100644 --- a/src/meta/meta.h +++ b/src/meta/meta.h @@ -686,4 +686,6 @@ VGMSTREAM * init_vgmstream_ngc_vid1(STREAMFILE * streamFile); VGMSTREAM * init_vgmstream_flx(STREAMFILE * streamFile); +VGMSTREAM * init_vgmstream_mogg(STREAMFILE * streamFile); + #endif /*_META_H*/ diff --git a/src/meta/mogg.c b/src/meta/mogg.c new file mode 100644 index 00000000..d14e7e1a --- /dev/null +++ b/src/meta/mogg.c @@ -0,0 +1,42 @@ +/* +2017-12-10: Preliminary MOGG Support. As long as the stream is unencrypted, this should be fine. + This will also work on unconventional 5 channel Vorbis streams but some sound cards might not like it. + TODO (Eventually): Add decryption for encrypted MOGG types (Rock Band, etc.) + + -bxaimc +*/ + +#include "meta.h" +#include "../coding/coding.h" + +/* MOGG - Harmonix Music Systems (Guitar Hero)[Unencrypted Type] */ +VGMSTREAM * init_vgmstream_mogg(STREAMFILE *streamFile) { +#ifdef VGM_USE_VORBIS + char filename[PATH_LIMIT]; + off_t start_offset; + + /* check extension, case insensitive */ + streamFile->get_name(streamFile, filename, sizeof(filename)); + if (strcasecmp("mogg", filename_extension(filename))) goto fail; + + { + vgm_vorbis_info_t inf; + VGMSTREAM * result = NULL; + + memset(&inf, 0, sizeof(inf)); + inf.layout_type = layout_ogg_vorbis; + inf.meta_type = meta_MOGG; + + start_offset = read_32bitLE(0x04, streamFile); + result = init_vgmstream_ogg_vorbis_callbacks(streamFile, filename, NULL, start_offset, &inf); + + if (result != NULL) { + return result; + } + } + +fail: + /* clean up anything we may have opened */ +#endif + return NULL; +} \ No newline at end of file diff --git a/src/vgmstream.c b/src/vgmstream.c index 4fa9e678..b5bb594e 100644 --- a/src/vgmstream.c +++ b/src/vgmstream.c @@ -370,6 +370,7 @@ VGMSTREAM * (*init_vgmstream_functions[])(STREAMFILE *streamFile) = { init_vgmstream_ea_sps, init_vgmstream_ngc_vid1, init_vgmstream_flx, + init_vgmstream_mogg, 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 7a722d3a..fdd0318f 100644 --- a/src/vgmstream.h +++ b/src/vgmstream.h @@ -637,6 +637,7 @@ typedef enum { meta_EA_SPS, /* Electronic Arts SPS (Burnout Crash) */ meta_NGC_VID1, /* Neversoft .ogg (Gun GC) */ meta_PC_FLX, /* Ultima IX PC */ + meta_MOGG, /* Harmonix Music Systems MOGG Vorbis */ #ifdef VGM_USE_VORBIS meta_OGG_VORBIS, /* Ogg Vorbis */