diff --git a/CMakeLists.txt b/CMakeLists.txt index 2decf950..f9f37aee 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,7 +10,11 @@ if(MINGW) message(FATAL_ERROR "Cannot currently build with MinGW") endif() -set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) +set(VGM_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} PARENT_SCOPE) +set(VGM_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR} PARENT_SCOPE) +set(VGM_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) +set(VGM_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) +set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake;${CMAKE_MODULE_PATH}) include(vgmstream) # Options @@ -56,12 +60,12 @@ if(WIN32) # Update the version set(CMAKE_EXECUTABLE_SUFFIX .exe) if(MSVC) - file(TO_NATIVE_PATH "${CMAKE_BINARY_DIR}/version.h" VERSION_H_PATH) - add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/version.h - COMMAND "${CMAKE_SOURCE_DIR}/version.bat" + file(TO_NATIVE_PATH "${VGM_BINARY_DIR}/version.h" VERSION_H_PATH) + add_custom_command(OUTPUT ${VGM_BINARY_DIR}/version.h + COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/version.bat" ARGS ${VERSION_H_PATH} VERSION - DEPENDS ${CMAKE_SOURCE_DIR}/version.bat) - add_custom_target(version_h DEPENDS ${CMAKE_BINARY_DIR}/version.h) + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/version.bat) + add_custom_target(version_h DEPENDS ${VGM_BINARY_DIR}/version.h) else() find_package(Git) if(GIT_FOUND) @@ -171,7 +175,7 @@ if(USE_FDKAAC) endif() if(USE_MAIATRAC3PLUS) if(MAIATRAC3PLUS_PATH) - add_subdirectory(${MAIATRAC3PLUS_PATH}/MaiAT3PlusDecoder ${CMAKE_BINARY_DIR}/maitrac3plus) + add_subdirectory(${MAIATRAC3PLUS_PATH}/MaiAT3PlusDecoder ${CMAKE_CURRENT_BINARY_DIR}/maitrac3plus) else() message(FATAL_ERROR "Path to MAIATRAC3+ must be set. (Use MAIATRAC3PLUS_PATH)") endif() diff --git a/cli/CMakeLists.txt b/cli/CMakeLists.txt index 29ee2d63..c3683096 100644 --- a/cli/CMakeLists.txt +++ b/cli/CMakeLists.txt @@ -17,8 +17,8 @@ if(WIN32) # Make sure that the binary directory is included (for version.h), as well as the getopt library include directory target_include_directories(vgmstream_cli PRIVATE - ${CMAKE_BINARY_DIR} - ${CMAKE_SOURCE_DIR}/ext_libs/Getopt) + ${VGM_BINARY_DIR} + ${VGM_SOURCE_DIR}/ext_libs/Getopt) # Include the version string if(MSVC) @@ -44,7 +44,7 @@ endif() # Install the CLI program install(TARGETS vgmstream_cli - RUNTIME DESTINATION bin) + RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin) # TODO: Make it so vgmstream123 can build with Windows (this probably needs a libao.dll included with vgmstream, though) @@ -70,5 +70,5 @@ if(NOT WIN32) # Install vgmstream123 install(TARGETS vgmstream123 - RUNTIME DESTINATION bin) + RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin) endif() diff --git a/cmake/mp4v2.cmake b/cmake/mp4v2.cmake index 4dd5dddd..29291b89 100644 --- a/cmake/mp4v2.cmake +++ b/cmake/mp4v2.cmake @@ -1,6 +1,6 @@ # qaac doesn't have a Visual Studio project for Windows, so this not only allows things to build for Visual Studio, but also covers other compilers and platforms -configure_file(${QAAC_PATH}/mp4v2/libplatform/config.h.in ${CMAKE_BINARY_DIR}/mp4v2/include/libplatform/config.h COPYONLY) +configure_file(${QAAC_PATH}/mp4v2/libplatform/config.h.in ${VGM_BINARY_DIR}/mp4v2/include/libplatform/config.h COPYONLY) file(GLOB INCLUDE_HEADERS "${QAAC_PATH}/mp4v2/include/mp4v2/*.h") file(GLOB LIBPLATFORM_HEADERS "${QAAC_PATH}/mp4v2/libplatform/*.h") @@ -103,7 +103,7 @@ target_compile_definitions(mp4v2 PRIVATE target_include_directories(mp4v2 PRIVATE ${QAAC_PATH}/mp4v2 ${QAAC_PATH}/mp4v2/include - ${CMAKE_BINARY_DIR}/mp4v2/include) + ${VGM_BINARY_DIR}/mp4v2/include) # Make sure that whatever compiler we use can handle these features target_compile_features(mp4v2 PRIVATE diff --git a/cmake/vgmstream.cmake b/cmake/vgmstream.cmake index b33c3f11..4a0a970b 100644 --- a/cmake/vgmstream.cmake +++ b/cmake/vgmstream.cmake @@ -14,7 +14,8 @@ macro(setup_target TARGET) _WIN32_WINNT=0x501 _CRT_SECURE_NO_WARNINGS) endif() - target_include_directories(${TARGET} PRIVATE ${CMAKE_SOURCE_DIR}/ext_includes) + target_include_directories(${TARGET} PRIVATE ${VGM_SOURCE_DIR}/src) + target_include_directories(${TARGET} PRIVATE ${VGM_SOURCE_DIR}/ext_includes) # Set up position-independent code for all targets set_target_properties(${TARGET} PROPERTIES POSITION_INDEPENDENT_CODE TRUE) @@ -29,7 +30,7 @@ macro(setup_target TARGET) VGM_USE_FDKAAC) target_include_directories(${TARGET} PRIVATE ${QAAC_PATH}/mp4v2/include - ${CMAKE_BINARY_DIR}/mp4v2/include + ${VGM_BINARY_DIR}/mp4v2/include ${FDK_AAC_PATH}/libSYS/include ${FDK_AAC_PATH}/libAACdec/include) if(LINK) @@ -44,7 +45,7 @@ macro(setup_target TARGET) if(WIN32) if(LINK) add_dependencies(${TARGET} libmpg123) - target_link_libraries(${TARGET} ${CMAKE_BINARY_DIR}/ext_libs/libmpg123-0.lib) + target_link_libraries(${TARGET} ${VGM_BINARY_DIR}/ext_libs/libmpg123-0.lib) endif() else() target_include_directories(${TARGET} PRIVATE ${MPG123_INCLUDE_DIR}) @@ -59,7 +60,7 @@ macro(setup_target TARGET) if(WIN32) if(LINK) add_dependencies(${TARGET} libvorbis) - target_link_libraries(${TARGET} ${CMAKE_BINARY_DIR}/ext_libs/libvorbis.lib) + target_link_libraries(${TARGET} ${VGM_BINARY_DIR}/ext_libs/libvorbis.lib) endif() else() target_include_directories(${TARGET} PRIVATE ${VORBISFILE_INCLUDE_DIRS}) @@ -75,9 +76,9 @@ macro(setup_target TARGET) if(LINK) add_dependencies(${TARGET} ffmpeg) target_link_libraries(${TARGET} - ${CMAKE_BINARY_DIR}/ext_libs/avcodec.lib - ${CMAKE_BINARY_DIR}/ext_libs/avformat.lib - ${CMAKE_BINARY_DIR}/ext_libs/avutil.lib) + ${VGM_BINARY_DIR}/ext_libs/avcodec.lib + ${VGM_BINARY_DIR}/ext_libs/avformat.lib + ${VGM_BINARY_DIR}/ext_libs/avutil.lib) endif() else() target_include_directories(${TARGET} PRIVATE ${FFMPEG_INCLUDE_DIRS}) @@ -91,7 +92,7 @@ macro(setup_target TARGET) target_compile_definitions(${TARGET} PRIVATE VGM_USE_G7221) if(LINK) add_dependencies(${TARGET} libg7221_decode) - target_link_libraries(${TARGET} ${CMAKE_BINARY_DIR}/ext_libs/libg7221_decode.lib) + target_link_libraries(${TARGET} ${VGM_BINARY_DIR}/ext_libs/libg7221_decode.lib) endif() endif() @@ -99,7 +100,7 @@ macro(setup_target TARGET) target_compile_definitions(${TARGET} PRIVATE VGM_USE_G719) if(LINK) add_dependencies(${TARGET} libg719_decode) - target_link_libraries(${TARGET} ${CMAKE_BINARY_DIR}/ext_libs/libg719_decode.lib) + target_link_libraries(${TARGET} ${VGM_BINARY_DIR}/ext_libs/libg719_decode.lib) endif() endif() @@ -115,7 +116,7 @@ macro(setup_target TARGET) target_compile_definitions(${TARGET} PRIVATE VGM_USE_ATRAC9) if(LINK) add_dependencies(${TARGET} libatrac9) - target_link_libraries(${TARGET} ${CMAKE_BINARY_DIR}/ext_libs/libatrac9.lib) + target_link_libraries(${TARGET} ${VGM_BINARY_DIR}/ext_libs/libatrac9.lib) endif() endif() @@ -124,8 +125,8 @@ macro(setup_target TARGET) if(LINK) add_dependencies(${TARGET} libcelt) target_link_libraries(${TARGET} - ${CMAKE_BINARY_DIR}/ext_libs/libcelt-0061.lib - ${CMAKE_BINARY_DIR}/ext_libs/libcelt-0110.lib) + ${VGM_BINARY_DIR}/ext_libs/libcelt-0061.lib + ${VGM_BINARY_DIR}/ext_libs/libcelt-0110.lib) endif() endif() endmacro() @@ -133,19 +134,19 @@ endmacro() # Installs the DLLs to the given install prefix macro(install_dlls INSTALL_PREFIX) # Paths to the DLLs - set(MPEG_DLL ${CMAKE_SOURCE_DIR}/ext_libs/libmpg123-0.dll) - set(VORBIS_DLL ${CMAKE_SOURCE_DIR}/ext_libs/libvorbis.dll) - set(G7221_DLL ${CMAKE_SOURCE_DIR}/ext_libs/libg7221_decode.dll) - set(G719_DLL ${CMAKE_SOURCE_DIR}/ext_libs/libg719_decode.dll) + set(MPEG_DLL ${VGM_SOURCE_DIR}/ext_libs/libmpg123-0.dll) + set(VORBIS_DLL ${VGM_SOURCE_DIR}/ext_libs/libvorbis.dll) + set(G7221_DLL ${VGM_SOURCE_DIR}/ext_libs/libg7221_decode.dll) + set(G719_DLL ${VGM_SOURCE_DIR}/ext_libs/libg719_decode.dll) set(FFMPEG_DLL - ${CMAKE_SOURCE_DIR}/ext_libs/avcodec-vgmstream-58.dll - ${CMAKE_SOURCE_DIR}/ext_libs/avformat-vgmstream-58.dll - ${CMAKE_SOURCE_DIR}/ext_libs/avutil-vgmstream-56.dll - ${CMAKE_SOURCE_DIR}/ext_libs/swresample-vgmstream-3.dll) - set(ATRAC9_DLL ${CMAKE_SOURCE_DIR}/ext_libs/libatrac9.dll) + ${VGM_SOURCE_DIR}/ext_libs/avcodec-vgmstream-58.dll + ${VGM_SOURCE_DIR}/ext_libs/avformat-vgmstream-58.dll + ${VGM_SOURCE_DIR}/ext_libs/avutil-vgmstream-56.dll + ${VGM_SOURCE_DIR}/ext_libs/swresample-vgmstream-3.dll) + set(ATRAC9_DLL ${VGM_SOURCE_DIR}/ext_libs/libatrac9.dll) set(CELT_DLL - ${CMAKE_SOURCE_DIR}/ext_libs/libcelt-0061.dll - ${CMAKE_SOURCE_DIR}/ext_libs/libcelt-0110.dll) + ${VGM_SOURCE_DIR}/ext_libs/libcelt-0061.dll + ${VGM_SOURCE_DIR}/ext_libs/libcelt-0110.dll) # List of DLLs to check for install set(DLLS diff --git a/ext_libs/CMakeLists.txt b/ext_libs/CMakeLists.txt index af8c7be5..5d4b1a7d 100644 --- a/ext_libs/CMakeLists.txt +++ b/ext_libs/CMakeLists.txt @@ -7,8 +7,8 @@ if(MSVC) add_custom_target(libmpg123 DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/libmpg123-0.lib SOURCES - ${CMAKE_SOURCE_DIR}/ext_includes/fmt123.h - ${CMAKE_SOURCE_DIR}/ext_includes/mpg123.h) + ${VGM_SOURCE_DIR}/ext_includes/fmt123.h + ${VGM_SOURCE_DIR}/ext_includes/mpg123.h) endif() if(USE_VORBIS) @@ -16,8 +16,8 @@ if(MSVC) COMMAND lib ARGS /def:${CMAKE_CURRENT_SOURCE_DIR}/libvorbis.def /machine:x86 /out:${CMAKE_CURRENT_BINARY_DIR}/libvorbis.lib DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/libvorbis.def) - file(GLOB OGG_HEADERS "${CMAKE_SOURCE_DIR}/ext_includes/ogg/*.h") - file(GLOB VORBIS_HEADERS "${CMAKE_SOURCE_DIR}/ext_includes/vorbis/*h") + file(GLOB OGG_HEADERS "${VGM_SOURCE_DIR}/ext_includes/ogg/*.h") + file(GLOB VORBIS_HEADERS "${VGM_SOURCE_DIR}/ext_includes/vorbis/*h") add_custom_target(libvorbis DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/libvorbis.lib SOURCES @@ -34,7 +34,7 @@ if(MSVC) DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/libg7221_decode.def) add_custom_target(libg7221_decode DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/libg7221_decode.lib - SOURCES ${CMAKE_SOURCE_DIR}/ext_includes/g7221.h) + SOURCES ${VGM_SOURCE_DIR}/ext_includes/g7221.h) endif() if(USE_G719) @@ -44,7 +44,7 @@ if(MSVC) DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/libg719_decode.def) add_custom_target(libg719_decode DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/libg719_decode.lib - SOURCES ${CMAKE_SOURCE_DIR}/ext_includes/g719.h) + SOURCES ${VGM_SOURCE_DIR}/ext_includes/g719.h) endif() if(USE_FFMPEG) @@ -64,10 +64,10 @@ if(MSVC) COMMAND lib ARGS /def:${CMAKE_CURRENT_SOURCE_DIR}/swresample-vgmstream-3.def /machine:x86 /out:${CMAKE_CURRENT_BINARY_DIR}/swresample.lib DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/swresample-vgmstream-3.def) - file(GLOB AVCODEC_HEADERS "${CMAKE_SOURCE_DIR}/ext_includes/libavcodec/*.h") - file(GLOB AVFORMAT_HEADERS "${CMAKE_SOURCE_DIR}/ext_includes/libavformat/*.h") - file(GLOB AVUTIL_HEADERS "${CMAKE_SOURCE_DIR}/ext_includes/libavutil/*.h") - file(GLOB SWRESAMPLE_HEADERS "${CMAKE_SOURCE_DIR}/ext_includes/libswresample/*.h") + file(GLOB AVCODEC_HEADERS "${VGM_SOURCE_DIR}/ext_includes/libavcodec/*.h") + file(GLOB AVFORMAT_HEADERS "${VGM_SOURCE_DIR}/ext_includes/libavformat/*.h") + file(GLOB AVUTIL_HEADERS "${VGM_SOURCE_DIR}/ext_includes/libavutil/*.h") + file(GLOB SWRESAMPLE_HEADERS "${VGM_SOURCE_DIR}/ext_includes/libswresample/*.h") add_custom_target(ffmpeg DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/avcodec.lib @@ -92,7 +92,7 @@ if(MSVC) DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/libatrac9.def) add_custom_target(libatrac9 DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/libatrac9.lib - SOURCES ${CMAKE_SOURCE_DIR}/ext_includes/libatrac9.h) + SOURCES ${VGM_SOURCE_DIR}/ext_includes/libatrac9.h) endif() if(USE_CELT) @@ -104,7 +104,7 @@ if(MSVC) COMMAND lib ARGS /def:${CMAKE_CURRENT_SOURCE_DIR}/libcelt-0110.def /machine:x86 /out:${CMAKE_CURRENT_BINARY_DIR}/libcelt-0110.lib DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/libcelt-0110.def) - file(GLOB CELT_HEADERS "${CMAKE_SOURCE_DIR}/ext_includes/celt/*.h") + file(GLOB CELT_HEADERS "${VGM_SOURCE_DIR}/ext_includes/celt/*.h") add_custom_target(libcelt DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/libcelt-0061.lib diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e4d8dcad..48f39aba 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -5,10 +5,10 @@ file(GLOB LAYOUT_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/layout/*.c") file(GLOB META_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/meta/*.h") file(GLOB META_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/meta/*.c") set(EXT_HEADERS - ${CMAKE_SOURCE_DIR}/ext_includes/clHCA.h - ${CMAKE_SOURCE_DIR}/ext_includes/pstdint.h) + ${VGM_SOURCE_DIR}/ext_includes/clHCA.h + ${VGM_SOURCE_DIR}/ext_includes/pstdint.h) set(EXT_SOURCES - ${CMAKE_SOURCE_DIR}/ext_libs/clHCA.c) + ${VGM_SOURCE_DIR}/ext_libs/clHCA.c) file(GLOB MAIN_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/*.h") file(GLOB MAIN_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/*.c") @@ -41,7 +41,7 @@ setup_target(libvgmstream) # Set up the proper include directories target_include_directories(libvgmstream PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR} + ${VGM_SOURCE_DIR}/ext_includes coding layout meta) diff --git a/src/coding/coding.h b/src/coding/coding.h index 3e9ff7e5..453add12 100644 --- a/src/coding/coding.h +++ b/src/coding/coding.h @@ -20,6 +20,7 @@ void decode_wv6_ima(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspa void decode_alp_ima(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do); void decode_ffta2_ima(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do); void decode_blitz_ima(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do); +void decode_mtf_ima(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do); void decode_ms_ima(VGMSTREAM * vgmstream,VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do,int channel); void decode_ref_ima(VGMSTREAM * vgmstream, VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do,int channel); diff --git a/src/coding/ima_decoder.c b/src/coding/ima_decoder.c index 1c290e4c..23a08792 100644 --- a/src/coding/ima_decoder.c +++ b/src/coding/ima_decoder.c @@ -263,6 +263,26 @@ static void blitz_ima_expand_nibble(VGMSTREAMCHANNEL * stream, off_t byte_offset if (*step_index > 88) *step_index=88; } +static const int CIMAADPCM_INDEX_TABLE[16] = {8, 6, 4, 2, -1, -1, -1, -1, + -1, -1, -1, -1, 2, 4, 6, 8}; + +/* Capcom's MT Framework modified IMA, reverse engineered from the exe */ +static void mtf_ima_expand_nibble(VGMSTREAMCHANNEL * stream, off_t byte_offset, int nibble_shift, int32_t * hist1, int32_t * step_index) { + int sample_nibble, sample_decoded, step, delta; + + sample_nibble = (read_8bit(byte_offset,stream->streamfile) >> nibble_shift) & 0xf; + sample_decoded = *hist1; + step = ADPCMTable[*step_index]; + + delta = step * (2 * sample_nibble - 15); + sample_decoded += delta; + + *hist1 = sample_decoded; + *step_index += CIMAADPCM_INDEX_TABLE[sample_nibble]; + if (*step_index < 0) *step_index=0; + if (*step_index > 88) *step_index=88; +} + /* ************************************ */ /* DVI/IMA */ /* ************************************ */ @@ -298,6 +318,30 @@ void decode_standard_ima(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int chann stream->adpcm_step_index = step_index; } +void decode_mtf_ima(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do) { + int i, sample_count = 0; + int32_t hist1 = stream->adpcm_history1_32; + int step_index = stream->adpcm_step_index; + + /* external interleave */ + + /* no header (external setup), pre-clamp for wrong values */ + if (step_index < 0) step_index=0; + if (step_index > 88) step_index=88; + + /* decode nibbles (layout: varies) */ + for (i = first_sample; i < first_sample + samples_to_do; i++, sample_count += channelspacing) { + off_t byte_offset = stream->offset + i/2; + int nibble_shift = ((i&1) ? 0:4); + + mtf_ima_expand_nibble(stream, byte_offset,nibble_shift, &hist1, &step_index); + outbuf[sample_count] = clamp16(hist1 >> 4); + } + + stream->adpcm_history1_32 = hist1; + stream->adpcm_step_index = step_index; +} + void decode_3ds_ima(VGMSTREAMCHANNEL * stream, sample_t * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do) { int i, sample_count; int32_t hist1 = stream->adpcm_history1_32; diff --git a/src/formats.c b/src/formats.c index 1f24be08..212aa542 100644 --- a/src/formats.c +++ b/src/formats.c @@ -172,6 +172,7 @@ static const char* extension_list[] = { "fsb", "fsv", "fwav", + "fwse", "g1l", "gbts", @@ -692,6 +693,7 @@ static const coding_info coding_info_list[] = { {coding_ALP_IMA, "High Voltage ALP 4-bit IMA ADPCM"}, {coding_FFTA2_IMA, "Final Fantasy Tactics A2 4-bit IMA ADPCM"}, {coding_BLITZ_IMA, "Blitz Games 4-bit IMA ADPCM"}, + {coding_MTF_IMA, "MT Framework 4-bit IMA ADPCM"}, {coding_MS_IMA, "Microsoft 4-bit IMA ADPCM"}, {coding_XBOX_IMA, "XBOX 4-bit IMA ADPCM"}, @@ -1254,6 +1256,7 @@ static const meta_info meta_info_list[] = { {meta_ISB, "Creative ISACT header"}, {meta_XSSB, "Artoon XSSB header"}, {meta_XMA_UE3, "Unreal Engine XMA header"}, + {meta_FWSE, "MT Framework FWSE header"}, {meta_FDA, "Relic FDA header"}, }; diff --git a/src/libvgmstream.vcproj b/src/libvgmstream.vcproj index ae53f10d..39e3c0a0 100644 --- a/src/libvgmstream.vcproj +++ b/src/libvgmstream.vcproj @@ -680,6 +680,10 @@ RelativePath=".\meta\fsb_encrypted.c" > + + diff --git a/src/libvgmstream.vcxproj b/src/libvgmstream.vcxproj index b2898c4f..f67b5cb3 100644 --- a/src/libvgmstream.vcxproj +++ b/src/libvgmstream.vcxproj @@ -168,6 +168,7 @@ + diff --git a/src/libvgmstream.vcxproj.filters b/src/libvgmstream.vcxproj.filters index 508b1a82..eefec7dc 100644 --- a/src/libvgmstream.vcxproj.filters +++ b/src/libvgmstream.vcxproj.filters @@ -436,6 +436,9 @@ meta\Source Files + + meta\Source Files + meta\Source Files diff --git a/src/meta/fwse.c b/src/meta/fwse.c new file mode 100644 index 00000000..496ee48c --- /dev/null +++ b/src/meta/fwse.c @@ -0,0 +1,51 @@ +#include "meta.h" +#include "../coding/coding.h" + +/* FWSE - Capcom's MT Framework V1.x sound file */ +VGMSTREAM *init_vgmstream_fwse(STREAMFILE *streamFile) { + VGMSTREAM *vgmstream = NULL; + uint32_t version, file_size, buffer_offset, + channel_count, sample_count, sample_rate; + + if (!check_extensions(streamFile,"fwse")) + goto fail; + + if ((read_32bitLE(0x00,streamFile)) != 0x45535746) + goto fail; + + version = read_32bitLE(0x04,streamFile); + + if (version != 2) + goto fail; + + file_size = read_32bitLE(0x08,streamFile); + buffer_offset = read_32bitLE(0x0C,streamFile); + channel_count = read_32bitLE(0x10,streamFile); + + if (channel_count > 1) + goto fail; + + sample_count = read_32bitLE(0x14,streamFile); + sample_rate = read_32bitLE(0x18,streamFile); + + /* build the VGMSTREAM */ + vgmstream = allocate_vgmstream(channel_count, 0); + if (!vgmstream) goto fail; + + vgmstream->meta_type = meta_FWSE; + vgmstream->sample_rate = sample_rate; + vgmstream->num_samples = sample_count; + vgmstream->coding_type = coding_MTF_IMA; + vgmstream->layout_type = channel_count == 1 ? layout_none : layout_interleave; + vgmstream->interleave_block_size = 1; + + + if (!vgmstream_open_stream(vgmstream,streamFile,buffer_offset)) + goto fail; + + return vgmstream; + +fail: + close_vgmstream(vgmstream); + return NULL; +} diff --git a/src/meta/meta.h b/src/meta/meta.h index fcf269e2..2c1398f8 100644 --- a/src/meta/meta.h +++ b/src/meta/meta.h @@ -877,6 +877,8 @@ VGMSTREAM* init_vgmstream_xma_ue3(STREAMFILE *sf); VGMSTREAM* init_vgmstream_csb(STREAMFILE *sf); +VGMSTREAM *init_vgmstream_fwse(STREAMFILE *streamFile); + VGMSTREAM* init_vgmstream_fda(STREAMFILE *sf); #endif /*_META_H*/ diff --git a/src/vgmstream.c b/src/vgmstream.c index 3094144b..2cbd7dd3 100644 --- a/src/vgmstream.c +++ b/src/vgmstream.c @@ -486,6 +486,7 @@ VGMSTREAM * (*init_vgmstream_functions[])(STREAMFILE *streamFile) = { init_vgmstream_xssb, init_vgmstream_xma_ue3, init_vgmstream_csb, + init_vgmstream_fwse, init_vgmstream_fda, /* lowest priority metas (should go after all metas, and TXTH should go before raw formats) */ @@ -1174,6 +1175,7 @@ int get_vgmstream_samples_per_frame(VGMSTREAM * vgmstream) { case coding_UBI_IMA: case coding_OKI16: case coding_OKI4S: + case coding_MTF_IMA: return 1; case coding_PCM4: case coding_PCM4_U: @@ -1368,6 +1370,7 @@ int get_vgmstream_frame_size(VGMSTREAM * vgmstream) { case coding_PCFX: case coding_OKI16: case coding_OKI4S: + case coding_MTF_IMA: return 0x01; case coding_MS_IMA: case coding_RAD_IMA: @@ -1840,6 +1843,12 @@ void decode_vgmstream(VGMSTREAM * vgmstream, int samples_written, int samples_to is_stereo, is_high_first); } break; + case coding_MTF_IMA: + for (ch = 0; ch < vgmstream->channels; ch++) { + decode_mtf_ima(&vgmstream->ch[ch],buffer+samples_written*vgmstream->channels+ch, + vgmstream->channels,vgmstream->samples_into_block,samples_to_do); + } + break; case coding_3DS_IMA: for (ch = 0; ch < vgmstream->channels; ch++) { decode_3ds_ima(&vgmstream->ch[ch],buffer+samples_written*vgmstream->channels+ch, diff --git a/src/vgmstream.h b/src/vgmstream.h index 9f26911c..c294e5a5 100644 --- a/src/vgmstream.h +++ b/src/vgmstream.h @@ -143,6 +143,7 @@ typedef enum { coding_AWC_IMA, /* Rockstar AWC IMA ADPCM */ coding_UBI_IMA, /* Ubisoft IMA ADPCM */ coding_H4M_IMA, /* H4M IMA ADPCM (stereo or mono, high nibble first) */ + coding_MTF_IMA, /* Capcom MT Framework IMA ADPCM */ coding_MSADPCM, /* Microsoft ADPCM (stereo/mono) */ coding_MSADPCM_int, /* Microsoft ADPCM (mono) */ @@ -719,6 +720,7 @@ typedef enum { meta_ISB, meta_XSSB, meta_XMA_UE3, + meta_FWSE, meta_FDA, } meta_t; diff --git a/winamp/CMakeLists.txt b/winamp/CMakeLists.txt index 0e301d33..f95e6cc2 100644 --- a/winamp/CMakeLists.txt +++ b/winamp/CMakeLists.txt @@ -29,7 +29,7 @@ target_compile_definitions(in_vgmstream PRIVATE _UNICODE) # Make sure that the binary directory is included (for version.h) -target_include_directories(in_vgmstream PRIVATE ${CMAKE_BINARY_DIR}) +target_include_directories(in_vgmstream PRIVATE ${VGM_BINARY_DIR}) # Include the version string if(MSVC) diff --git a/xmplay/CMakeLists.txt b/xmplay/CMakeLists.txt index 82ebe0d7..7f523fe0 100644 --- a/xmplay/CMakeLists.txt +++ b/xmplay/CMakeLists.txt @@ -15,7 +15,7 @@ set_target_properties(xmp-vgmstream PROPERTIES SUFFIX ".dll") # Make sure that the binary directory is included (for version.h) -target_include_directories(xmp-vgmstream PRIVATE ${CMAKE_BINARY_DIR}) +target_include_directories(xmp-vgmstream PRIVATE ${VGM_BINARY_DIR}) # Include the version string if(MSVC) diff --git a/xmplay/xmp_vgmstream.c b/xmplay/xmp_vgmstream.c index c0b945a7..27e00889 100644 --- a/xmplay/xmp_vgmstream.c +++ b/xmplay/xmp_vgmstream.c @@ -42,7 +42,7 @@ double fade_seconds = 10.0; double fade_delay_seconds = 0.0; double loop_count = 2.0; int disable_subsongs = 1; -bool xmplay_doneloop = 0; +BOOL xmplay_doneloop = 0; /* plugin state */ VGMSTREAM * vgmstream = NULL;