Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ build_script:
# - md build-%COMPILER%-%BUILD_TYPE%-%PLATFORM%
# - cd build-%COMPILER%-%BUILD_TYPE%-%PLATFORM%
# - if NOT [%TOOLCHAIN_BIN%]==[] set PATH=%TOOLCHAIN_BIN%;%PATH:C:\Program Files\Git\usr\bin;=%
# - cmake -G "%GENERATOR%" -DCMAKE_BUILD_TYPE=%BUILD_TYPE% -DCMAKE_PREFIX_PATH=%CMAKEPREFIXPATH% -DCMAKE_INSTALL_PREFIX=libADLMIDI -DWITH_OLD_UTILS=ON -DWITH_GENADLDATA=OFF -DlibADLMIDI_STATIC=%BUILD_STATIC% -DlibADLMIDI_SHARED=%BUILD_SHARED% -DWITH_MIDIPLAY=%BUILD_MIDIPLAY% -DWITH_VLC_PLUGIN=%VLC_PLUGIN% -DVLC_PLUGIN_NOINSTALL=ON ..
# - cmake -G "%GENERATOR%" -DCMAKE_BUILD_TYPE=%BUILD_TYPE% -DCMAKE_PREFIX_PATH=%CMAKEPREFIXPATH% -DCMAKE_INSTALL_PREFIX=libADLMIDI -DWITH_OLD_UTILS=ON -DWITH_GENADLDATA=OFF -DlibADLMIDI_STATIC=%BUILD_STATIC% -DlibADLMIDI_SHARED=%BUILD_SHARED% -DWITH_MIDIPLAY=%BUILD_MIDIPLAY% -DUSE_VGM_FILE_DUMPER=ON -DWITH_VLC_PLUGIN=%VLC_PLUGIN% -DVLC_PLUGIN_NOINSTALL=ON ..
# - if [%COMPILER_FAMILY%]==[MinGW] cmake --build . --config %BUILD_TYPE% -- -j 2
# - if [%COMPILER_FAMILY%]==[MinGW] mingw32-make install
# - if [%COMPILER_FAMILY%]==[MSVC] cmake --build . --config %BUILD_TYPE% --target install
Expand Down
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ matrix:

script:
- mkdir build; cd build;
if [ $TRAVIS_OS_NAME == linux ]; then cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=libADLMIDI -DWITH_MIDIPLAY=ON -DWITH_OLD_UTILS=ON -DWITH_GENADLDATA=OFF -DWITH_CPP_EXTRAS=ON -DWITH_ADLMIDI2=ON -DEXAMPLE_SDL2_AUDIO=ON -DWITH_VLC_PLUGIN=ON -DVLC_PLUGIN_NOINSTALL=ON -DlibADLMIDI_SHARED=ON -DlibADLMIDI_STATIC=ON -DWITH_UNIT_TESTS=ON ..; fi;
if [ $TRAVIS_OS_NAME == osx ]; then cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=libADLMIDI -DWITH_MIDIPLAY=OFF -DWITH_OLD_UTILS=ON -DWITH_GENADLDATA=OFF -DWITH_CPP_EXTRAS=ON -DWITH_ADLMIDI2=OFF -DEXAMPLE_SDL2_AUDIO=OFF -DWITH_VLC_PLUGIN=OFF -DVLC_PLUGIN_NOINSTALL=ON -DlibADLMIDI_SHARED=ON -DlibADLMIDI_STATIC=ON -DWITH_UNIT_TESTS=ON ..; fi;
if [ $TRAVIS_OS_NAME == linux ]; then cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=libADLMIDI -DUSE_VGM_FILE_DUMPER=ON -DWITH_MIDIPLAY=ON -DWITH_OLD_UTILS=ON -DWITH_GENADLDATA=OFF -DWITH_CPP_EXTRAS=ON -DWITH_ADLMIDI2=ON -DEXAMPLE_SDL2_AUDIO=ON -DWITH_VLC_PLUGIN=ON -DVLC_PLUGIN_NOINSTALL=ON -DlibADLMIDI_SHARED=ON -DlibADLMIDI_STATIC=ON -DWITH_UNIT_TESTS=ON ..; fi;
if [ $TRAVIS_OS_NAME == osx ]; then cmake -G "Ninja" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=libADLMIDI -DUSE_VGM_FILE_DUMPER=ON -DWITH_MIDIPLAY=OFF -DWITH_OLD_UTILS=ON -DWITH_GENADLDATA=OFF -DWITH_CPP_EXTRAS=ON -DWITH_ADLMIDI2=OFF -DEXAMPLE_SDL2_AUDIO=OFF -DWITH_VLC_PLUGIN=OFF -DVLC_PLUGIN_NOINSTALL=ON -DlibADLMIDI_SHARED=ON -DlibADLMIDI_STATIC=ON -DWITH_UNIT_TESTS=ON ..; fi;
- cmake --build . --config Release

17 changes: 17 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ option(WITH_GENADLDATA "Build and run full rebuild of embedded banks cache"
option(WITH_GENADLDATA_COMMENTS "Enable comments in a generated embedded instruments cache file" OFF)

option(WITH_MIDIPLAY "Build also demo MIDI player" OFF)
option(USE_VGM_FILE_DUMPER "Use VGM File Dumper (required to build the MIDI2VGM tool)" ON)
option(WITH_MIDI2VGM "Build also MIDI to VGM converter tool" OFF)
option(MIDIPLAY_WAVE_ONLY "Build Demo MIDI player without support of real time playing. It will output into WAV only." OFF)
option(WITH_ADLMIDI2 "Build also classic ADLMIDI player [EXPERIMENTAL]" OFF)
option(WITH_VLC_PLUGIN "Build also a plugin for VLC Media Player" OFF)
Expand Down Expand Up @@ -224,6 +226,13 @@ function(handle_options targetLib)
target_compile_definitions(${targetLib} PUBLIC ADLMIDI_DISABLE_JAVA_EMULATOR)
endif()

if(USE_VGM_FILE_DUMPER)
list(APPEND libADLMIDI_SOURCES
${libADLMIDI_SOURCE_DIR}/src/chips/vgm_file_dumper.cpp)
set(HAS_EMULATOR TRUE)
add_definitions(-DADLMIDI_MIDI2VGM)
endif()

if(NOT HAS_EMULATOR)
message(FATAL_ERROR "No emulators enabled! You must enable at least one emulator!")
endif()
Expand Down Expand Up @@ -353,6 +362,13 @@ if(WITH_MIDIPLAY)
add_subdirectory(utils/midiplay)
endif()

if(WITH_MIDI2VGM)
if(NOT USE_VGM_FILE_DUMPER)
message(FATAL_ERROR "To build MIDI to VGM converter, you must enable -DUSE_VGM_FILE_DUMPER=ON flag!")
endif()
add_subdirectory(utils/midi2vgm)
endif()

if(WITH_ADLMIDI2)
add_subdirectory(utils/adlmidi-2)
endif()
Expand Down Expand Up @@ -441,6 +457,7 @@ message("USE_DOSBOX_EMULATOR = ${USE_DOSBOX_EMULATOR}")
message("USE_NUKED_EMULATOR = ${USE_NUKED_EMULATOR}")
message("USE_OPAL_EMULATOR = ${USE_OPAL_EMULATOR}")
message("USE_JAVA_EMULATOR = ${USE_JAVA_EMULATOR}")
message("USE_VGM_FILE_DUMPER = ${USE_VGM_FILE_DUMPER}")

message("===== Utils and extras =====")
message("WITH_GENADLDATA = ${WITH_GENADLDATA}")
Expand Down
1 change: 1 addition & 0 deletions cmake/win-ci/winmm-drivers.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ cmake -G "%GENERATOR%"^
-DlibADLMIDI_SHARED=OFF ^
-DWITH_MIDIPLAY=OFF ^
-DWITH_VLC_PLUGIN=OFF ^
-DUSE_VGM_FILE_DUMPER=OFF ^
-DWITH_WINMMDRV=ON ^
-DWITH_WINMMDRV_PTHREADS=ON ^
-DWITH_WINMMDRV_MINGWEX=ON ^
Expand Down
2 changes: 2 additions & 0 deletions include/adlmidi.h
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,8 @@ enum ADL_Emulator
ADLMIDI_EMU_OPAL,
/*! Java */
ADLMIDI_EMU_JAVA,
/*! VGM file dumper (required for MIDI2VGM) */
ADLMIDI_VGM_DUMPER,
/*! Count instrument on the level */
ADLMIDI_EMU_end
};
Expand Down
7 changes: 7 additions & 0 deletions src/adlmidi_load.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,13 @@ bool MIDIplay::LoadMIDI_post()
//opl.Reset(); // ...twice (just in case someone misprogrammed OPL3 previously)
m_chipChannels.clear();
m_chipChannels.resize(synth.m_numChannels);
#ifdef ADLMIDI_MIDI2VGM
m_sequencerInterface->onloopStart = synth.m_loopStartHook;
m_sequencerInterface->onloopStart_userData = synth.m_loopStartHookData;
m_sequencerInterface->onloopEnd = synth.m_loopEndHook;
m_sequencerInterface->onloopEnd_userData = synth.m_loopEndHookData;
m_sequencer->setLoopHooksOnly(m_sequencerInterface->onloopStart != NULL);
#endif

return true;
}
Expand Down
8 changes: 7 additions & 1 deletion src/adlmidi_midiplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,13 @@ void MIDIplay::applySetup()
synth.reset(m_setup.emulator, m_setup.PCM_RATE, this);
m_chipChannels.clear();
m_chipChannels.resize(synth.m_numChannels);

#if defined(ADLMIDI_MIDI2VGM) && !defined(ADLMIDI_DISABLE_MIDI_SEQUENCER)
m_sequencerInterface->onloopStart = synth.m_loopStartHook;
m_sequencerInterface->onloopStart_userData = synth.m_loopStartHookData;
m_sequencerInterface->onloopEnd = synth.m_loopEndHook;
m_sequencerInterface->onloopEnd_userData = synth.m_loopEndHookData;
m_sequencer->setLoopHooksOnly(m_sequencerInterface->onloopStart != NULL);
#endif
// Reset the arpeggio counter
m_arpeggioCounter = 0;
}
Expand Down
34 changes: 32 additions & 2 deletions src/adlmidi_opl3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ static const unsigned OPLBase = 0x388;
# ifndef ADLMIDI_DISABLE_JAVA_EMULATOR
# include "chips/java_opl3.h"
# endif

// VGM File dumper
# ifdef ADLMIDI_MIDI2VGM
# include "chips/vgm_file_dumper.h"
# endif
#endif

static const unsigned adl_emulatorSupport = 0
Expand All @@ -79,6 +84,9 @@ static const unsigned adl_emulatorSupport = 0
# ifndef ADLMIDI_DISABLE_JAVA_EMULATOR
| (1u << ADLMIDI_EMU_JAVA)
# endif
# ifdef ADLMIDI_MIDI2VGM
| (1u << ADLMIDI_VGM_DUMPER)
# endif
#endif
;

Expand Down Expand Up @@ -1730,11 +1738,21 @@ void OPL3::reset(int emulator, unsigned long PCM_RATE, void *audioTickHandler)
m_insCache.clear();
m_keyBlockFNumCache.clear();
m_regBD.clear();

#ifdef ADLMIDI_MIDI2VGM
if(emulator == ADLMIDI_VGM_DUMPER && (m_numChips > 2))
m_numChips = 2;// VGM Dumper can't work in multichip mode
#endif
#ifndef ADLMIDI_HW_OPL
m_chips.resize(m_numChips, AdlMIDI_SPtr<OPLChipBase>());
#endif

#ifdef ADLMIDI_MIDI2VGM
m_loopStartHook = NULL;
m_loopStartHookData = NULL;
m_loopEndHook = NULL;
m_loopEndHookData = NULL;
#endif

const struct OplTimbre defaultInsCache = { 0x1557403,0x005B381, 0x49,0x80, 0x4, +0 };
m_numChannels = m_numChips * NUM_OF_CHANNELS;
m_insCache.resize(m_numChannels, defaultInsCache);
Expand Down Expand Up @@ -1771,7 +1789,7 @@ void OPL3::reset(int emulator, unsigned long PCM_RATE, void *audioTickHandler)
case ADLMIDI_EMU_NUKED: /* Latest Nuked OPL3 */
chip = new NukedOPL3;
break;
case ADLMIDI_EMU_NUKED_174: /* Old Nuked OPL3 1.4.7 modified and optimized */
case ADLMIDI_EMU_NUKED_174: /* Old Nuked OPL3 1.7.4 modified and optimized */
chip = new NukedOPL3v174;
break;
#endif
Expand All @@ -1790,6 +1808,18 @@ void OPL3::reset(int emulator, unsigned long PCM_RATE, void *audioTickHandler)
chip = new JavaOPL3;
break;
#endif
#ifdef ADLMIDI_MIDI2VGM
case ADLMIDI_VGM_DUMPER:
chip = new VGMFileDumper(i, (i == 0 ? NULL : m_chips[0].get()));
if(i == 0)//Set hooks for first chip only
{
m_loopStartHook = &VGMFileDumper::loopStartHook;
m_loopStartHookData = chip;
m_loopEndHook = &VGMFileDumper::loopEndHook;
m_loopEndHookData = chip;
}
break;
#endif
}
m_chips[i].reset(chip);
chip->setChipId((uint32_t)i);
Expand Down
10 changes: 10 additions & 0 deletions src/adlmidi_opl3.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,16 @@ class OPL3
#ifndef ADLMIDI_HW_OPL
//! Running chip emulators
std::vector<AdlMIDI_SPtr<OPLChipBase > > m_chips;
#ifdef ADLMIDI_MIDI2VGM
//! Loop Start hook
void (*m_loopStartHook)(void*);
//! Loop Start hook data
void *m_loopStartHookData;
//! Loop End hook
void (*m_loopEndHook)(void*);
//! Loop End hook data
void *m_loopEndHookData;
#endif
#endif

private:
Expand Down
Loading