aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.travis.yml5
-rw-r--r--CMakeLists.txt13
-rw-r--r--README.md2
-rw-r--r--cmake/openwattcom-dos/custom-h/mymap.h2
-rw-r--r--cmake/openwattcom-dos/custom-h/myset.h2
-rwxr-xr-xexamples/python-pyaudio/playmidi.py173
-rw-r--r--include/adlmidi.h2
-rw-r--r--include/adlmidi.hpp2
-rw-r--r--src/adldata.hh2
-rw-r--r--src/adlmidi.cpp4
-rw-r--r--src/adlmidi_bankmap.h2
-rw-r--r--src/adlmidi_bankmap.tcc2
-rw-r--r--src/adlmidi_cvt.hpp2
-rw-r--r--src/adlmidi_load.cpp2
-rw-r--r--src/adlmidi_midiplay.cpp2
-rw-r--r--src/adlmidi_midiplay.hpp2
-rw-r--r--src/adlmidi_opl3.cpp2
-rw-r--r--src/adlmidi_opl3.hpp2
-rw-r--r--src/adlmidi_private.cpp2
-rw-r--r--src/adlmidi_private.hpp2
-rw-r--r--src/adlmidi_ptr.hpp2
-rw-r--r--src/adlmidi_sequencer.cpp2
-rw-r--r--src/chips/common/mutex.hpp2
-rw-r--r--src/chips/dosbox_opl3.cpp2
-rw-r--r--src/chips/dosbox_opl3.h2
-rw-r--r--src/chips/java_opl3.cpp2
-rw-r--r--src/chips/java_opl3.h2
-rw-r--r--src/chips/nuked_opl3.cpp2
-rw-r--r--src/chips/nuked_opl3.h2
-rw-r--r--src/chips/nuked_opl3_v174.cpp2
-rw-r--r--src/chips/nuked_opl3_v174.h2
-rw-r--r--src/chips/opal_opl3.cpp2
-rw-r--r--src/chips/opal_opl3.h2
-rw-r--r--src/chips/opl_chip_base.h2
-rw-r--r--src/cvt_mus2mid.hpp2
-rw-r--r--src/cvt_xmi2mid.hpp2
-rw-r--r--src/file_reader.hpp8
-rw-r--r--src/midi_sequencer.h26
-rw-r--r--src/midi_sequencer.hpp12
-rw-r--r--src/midi_sequencer_impl.hpp272
-rw-r--r--src/wopl/wopl_file.c2
-rw-r--r--src/wopl/wopl_file.h2
-rw-r--r--utils/gen_adldata/ini/ini_processing.cpp2
-rw-r--r--utils/gen_adldata/ini/ini_processing.h2
-rw-r--r--utils/gen_adldata/ini/ini_processing_variant.h2
-rw-r--r--utils/midiplay/adlmidiplay.cpp2
-rw-r--r--utils/midiplay/audio.h2
-rw-r--r--utils/midiplay/audio_sdl.c2
-rw-r--r--utils/midiplay/audio_winmm.c2
-rw-r--r--utils/mus2mid/CMakeLists.txt7
-rw-r--r--utils/mus2mid/mus2mid.cpp74
-rwxr-xr-xutils/update-copyright.sh8
-rw-r--r--utils/vlc_codec/libadlmidi.c2
53 files changed, 484 insertions, 202 deletions
diff --git a/.travis.yml b/.travis.yml
index 142ef04..569ba69 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -11,7 +11,6 @@ matrix:
include:
- os: linux
dist: xenial
- sudo: none
compiler: gcc
addons:
apt:
@@ -22,7 +21,7 @@ matrix:
- libvlc-dev
- libvlccore-dev
- os: osx
- osx_image: xcode10.2
+ osx_image: xcode11.3
compiler: clang++
addons:
homebrew:
@@ -34,5 +33,5 @@ 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;
- - cmake --build . --config Release -- -j 2
+ - cmake --build . --config Release
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1dc7a5e..4063b61 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -132,6 +132,7 @@ option(WITH_ADLMIDI2 "Build also classic ADLMIDI player [EXPERIMENTAL]" O
option(WITH_VLC_PLUGIN "Build also a plugin for VLC Media Player" OFF)
option(VLC_PLUGIN_NOINSTALL "Don't install VLC plugin into VLC directory" OFF)
option(WITH_OLD_UTILS "Build also old utilities" OFF)
+option(WITH_MUS2MID "Build a MUS to MIDI converter" OFF)
option(WITH_XMI2MID "Build a XMI to MIDI converter" OFF)
option(EXAMPLE_SDL2_AUDIO "Build also a simple SDL2 demo MIDI player" OFF)
@@ -333,6 +334,10 @@ if(WITH_ADLMIDI2)
add_subdirectory(utils/adlmidi-2)
endif()
+if(WITH_MUS2MID)
+ add_subdirectory(utils/mus2mid)
+endif()
+
if(WITH_XMI2MID)
add_subdirectory(utils/xmi2mid)
endif()
@@ -363,6 +368,13 @@ install(FILES
include/adlmidi.hpp
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
+file(GLOB DOCTXT_FILES
+ "${libADLMIDI_SOURCE_DIR}/LICENSE*.txt"
+ README.md AUTHORS
+)
+install(FILES ${DOCTXT_FILES}
+ DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/doc/libADLMIDI")
+
if(NOT ANDROID)
configure_file(libADLMIDI.pc.in libADLMIDI.pc @ONLY)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libADLMIDI.pc"
@@ -414,5 +426,6 @@ message("MIDIPLAY_WAVE_ONLY = ${MIDIPLAY_WAVE_ONLY}")
message("WITH_ADLMIDI2 = ${WITH_ADLMIDI2}")
message("WITH_VLC_PLUGIN = ${WITH_VLC_PLUGIN}")
message("WITH_OLD_UTILS = ${WITH_OLD_UTILS}")
+message("WITH_MUS2MID = ${WITH_MUS2MID}")
message("WITH_XMI2MID = ${WITH_XMI2MID}")
message("EXAMPLE_SDL2_AUDIO = ${EXAMPLE_SDL2_AUDIO}")
diff --git a/README.md b/README.md
index 521bafa..db07572 100644
--- a/README.md
+++ b/README.md
@@ -3,7 +3,7 @@ libADLMIDI is a free Software MIDI synthesizer library with OPL3 emulation
Original ADLMIDI code: Copyright (c) 2010-2014 Joel Yliluoma <bisqwit@iki.fi>
-ADLMIDI Library API: Copyright (c) 2015-2018 Vitaly Novichkov <admin@wohlnet.ru>
+ADLMIDI Library API: Copyright (c) 2015-2020 Vitaly Novichkov <admin@wohlnet.ru>
Library is based on the ADLMIDI, a MIDI player for Linux and Windows with OPL3 emulation:
diff --git a/cmake/openwattcom-dos/custom-h/mymap.h b/cmake/openwattcom-dos/custom-h/mymap.h
index f233f54..e7f45c7 100644
--- a/cmake/openwattcom-dos/custom-h/mymap.h
+++ b/cmake/openwattcom-dos/custom-h/mymap.h
@@ -1,7 +1,7 @@
/*
PtrList - A custom STD::Vector implementation. Workaround for OpenWatcom's crashing implementation
-Copyright (c) 2015-2019 Vitaly Novichkov <admin@wohlnet.ru>
+Copyright (c) 2015-2020 Vitaly Novichkov <admin@wohlnet.ru>
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the "Software"),
diff --git a/cmake/openwattcom-dos/custom-h/myset.h b/cmake/openwattcom-dos/custom-h/myset.h
index 716f6d2..f391867 100644
--- a/cmake/openwattcom-dos/custom-h/myset.h
+++ b/cmake/openwattcom-dos/custom-h/myset.h
@@ -1,7 +1,7 @@
/*
PtrList - A custom STD::Vector implementation. Workaround for OpenWatcom's crashing implementation
-Copyright (c) 2015-2019 Vitaly Novichkov <admin@wohlnet.ru>
+Copyright (c) 2015-2020 Vitaly Novichkov <admin@wohlnet.ru>
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the "Software"),
diff --git a/examples/python-pyaudio/playmidi.py b/examples/python-pyaudio/playmidi.py
new file mode 100755
index 0000000..f0b8284
--- /dev/null
+++ b/examples/python-pyaudio/playmidi.py
@@ -0,0 +1,173 @@
+#!/usr/bin/python3
+
+import sys
+import time
+import signal
+import getopt
+import pyaudio
+import platform
+
+from ctypes import *
+
+if platform.system() == 'Windows':
+ adl = CDLL("libADLMIDI.dll")
+else:
+ adl = CDLL("libADLMIDI.so")
+
+_FREQUENCY = 44100
+
+playing = True
+
+# Allows to quit by Ctrl+C
+def catch_signal(signum, frame):
+ global playing
+ playing = False
+ print("Caught Ctrl+C!")
+
+
+class MidiPlayer:
+ """A streaming IMF music player."""
+ SAMPLE_SIZE = 2 # 16-bit
+ CHANNELS = 2 # stereo
+ BUFFER_SAMPLE_COUNT = 1024 # Max allowed: 512
+
+ def __init__(self, freq=_FREQUENCY):
+ """Initializes the PyAudio and OPL synth."""
+ self._freq = freq
+ # Prepare PyAudio
+ self._audio = pyaudio.PyAudio()
+ # Prepare buffers.
+ self._data = create_string_buffer(MidiPlayer.BUFFER_SAMPLE_COUNT * MidiPlayer.SAMPLE_SIZE * MidiPlayer.CHANNELS)
+ self._stream = None # Created later.
+ self._opl = adl.adl_init(freq)
+ self._song = None
+
+ def set_bank_no(self, bank_no):
+ if adl.adl_setBank(self._opl, bank_no):
+ print("%s" % c_char_p(adl.adl_errorInfo(self._opl)).value)
+ return False
+ return True
+
+ def set_bank_file(self, bank_file):
+ if adl.adl_openBankFile(self._opl, bank_file.encode()) < 0:
+ print("%s" % c_char_p(adl.adl_errorInfo(self._opl)).value)
+ return False
+ return True
+
+ def set_loop_enabled(self, loop_en):
+ adl.adl_setLoopEnabled(self._opl, 1 if loop_en else 0)
+
+ def _create_stream(self, start=True):
+ """Create a new PyAudio stream."""
+ self._stream = self._audio.open(
+ format=self._audio.get_format_from_width(MidiPlayer.SAMPLE_SIZE),
+ channels=MidiPlayer.CHANNELS,
+ frames_per_buffer=MidiPlayer.BUFFER_SAMPLE_COUNT,
+ rate=self._freq,
+ output=True,
+ start=start, # Don't start playing immediately!
+ stream_callback=self._callback)
+
+ def set_song(self, song):
+ self._song = song
+ if adl.adl_openFile(self._opl, self._song.encode()) < 0:
+ print("%s" % c_char_p(adl.adl_errorInfo(self._opl)).value.decode())
+ return False
+
+ return True
+
+ # noinspection PyUnusedLocal
+ def _callback(self, input_data, frame_count, time_info, status):
+ global playing
+ got = adl.adl_play(self._opl, int(MidiPlayer.BUFFER_SAMPLE_COUNT * 2), cast(self._data, POINTER(c_short)));
+ if got <= 0:
+ playing = False
+ return None, pyaudio.paComplete
+ return self._data, pyaudio.paContinue
+
+ def play(self, repeat=False):
+ global playing
+ """Starts playing the song at the current position."""
+ self.repeat = repeat
+ if self._song is None:
+ playing = False
+ return
+ # If a stream exists and it is not active and not stopped, it needs to be closed and a new one created.
+ if self._stream is not None and not self._stream.is_active() and not self._stream.is_stopped():
+ self._stream.close() # close for good measure.
+ self._stream = None
+
+ # If there's no stream at this point, create one.
+ if self._stream is None:
+ self._create_stream(False)
+ self._stream.start_stream()
+
+ def pause(self):
+ """Stops the PyAudio stream, but does not rewind the playback position."""
+ self._stream.stop_stream()
+
+ def stop(self):
+ """Stops the PyAudio stream and resets the playback position."""
+ self._stream.stop_stream()
+
+ def close(self):
+ """Closes the PyAudio stream and terminates it."""
+ if self._stream is not None:
+ self._stream.stop_stream()
+ self._stream.close()
+ self._stream = None
+ self._audio.terminate()
+ adl.adl_close(self._opl)
+
+
+def usage(arg):
+ print('usage: %s [-b <embedded bank number>|-bf <external bank file>] [-l 0|1] <file>' % arg, file=sys.stderr)
+ sys.exit(2)
+
+if __name__ == '__main__':
+ bank_no = 72
+ bank_file = None
+ enable_loop = False
+ sample_rate = 44100
+
+ opts, args = getopt.getopt(sys.argv[1:], 'b:bg:l:')
+ for o, a in opts:
+ if o == '-b':
+ bank_no = int(a)
+ if o == '-l':
+ enable_loop = int(a) == 1
+ elif o == '-bg':
+ bank_file = a
+
+ if not args:
+ usage(sys.argv[0])
+
+ midi_file = args[0]
+
+ MIDIPlay = MidiPlayer(sample_rate)
+
+ if bank_file:
+ if not MIDIPlay.set_bank_file(bank_file):
+ exit(1)
+ print("Using bank file: %s" % bank_file)
+ else:
+ if not MIDIPlay.set_bank_no(bank_no):
+ exit(1)
+ print("Using embedded bank: %d" % bank_no)
+
+ MIDIPlay.set_loop_enabled(enable_loop)
+
+ if not MIDIPlay.set_song(midi_file):
+ exit(1)
+
+ MIDIPlay.play()
+
+ signal.signal(signal.SIGINT, catch_signal)
+
+ print("Playing MIDI file %s..." % (midi_file))
+ while playing:
+ time.sleep(0.1)
+ MIDIPlay.stop()
+
+ MIDIPlay.close()
+
diff --git a/include/adlmidi.h b/include/adlmidi.h
index b3652e1..4df321d 100644
--- a/include/adlmidi.h
+++ b/include/adlmidi.h
@@ -2,7 +2,7 @@
* libADLMIDI is a free Software MIDI synthesizer library with OPL3 emulation
*
* Original ADLMIDI code: Copyright (c) 2010-2014 Joel Yliluoma <bisqwit@iki.fi>
- * ADLMIDI Library API: Copyright (c) 2015-2019 Vitaly Novichkov <admin@wohlnet.ru>
+ * ADLMIDI Library API: Copyright (c) 2015-2020 Vitaly Novichkov <admin@wohlnet.ru>
*
* Library is based on the ADLMIDI, a MIDI player for Linux and Windows with OPL3 emulation:
* http://iki.fi/bisqwit/source/adlmidi.html
diff --git a/include/adlmidi.hpp b/include/adlmidi.hpp
index 0144fd2..dda9c78 100644
--- a/include/adlmidi.hpp
+++ b/include/adlmidi.hpp
@@ -2,7 +2,7 @@
* libADLMIDI is a free Software MIDI synthesizer library with OPL3 emulation
*
* Original ADLMIDI code: Copyright (c) 2010-2014 Joel Yliluoma <bisqwit@iki.fi>
- * ADLMIDI Library API: Copyright (c) 2015-2019 Vitaly Novichkov <admin@wohlnet.ru>
+ * ADLMIDI Library API: Copyright (c) 2015-2020 Vitaly Novichkov <admin@wohlnet.ru>
*
* Library is based on the ADLMIDI, a MIDI player for Linux and Windows with OPL3 emulation:
* http://iki.fi/bisqwit/source/adlmidi.html
diff --git a/src/adldata.hh b/src/adldata.hh
index 6602e1a..7e6e6e6 100644
--- a/src/adldata.hh
+++ b/src/adldata.hh
@@ -2,7 +2,7 @@
* libADLMIDI is a free Software MIDI synthesizer library with OPL3 emulation
*
* Original ADLMIDI code: Copyright (c) 2010-2014 Joel Yliluoma <bisqwit@iki.fi>
- * ADLMIDI Library API: Copyright (c) 2015-2019 Vitaly Novichkov <admin@wohlnet.ru>
+ * ADLMIDI Library API: Copyright (c) 2015-2020 Vitaly Novichkov <admin@wohlnet.ru>
*
* Library is based on the ADLMIDI, a MIDI player for Linux and Windows with OPL3 emulation:
* http://iki.fi/bisqwit/source/adlmidi.html
diff --git a/src/adlmidi.cpp b/src/adlmidi.cpp
index 3274716..88dae70 100644
--- a/src/adlmidi.cpp
+++ b/src/adlmidi.cpp
@@ -2,7 +2,7 @@
* libADLMIDI is a free Software MIDI synthesizer library with OPL3 emulation
*
* Original ADLMIDI code: Copyright (c) 2010-2014 Joel Yliluoma <bisqwit@iki.fi>
- * ADLMIDI Library API: Copyright (c) 2015-2019 Vitaly Novichkov <admin@wohlnet.ru>
+ * ADLMIDI Library API: Copyright (c) 2015-2020 Vitaly Novichkov <admin@wohlnet.ru>
*
* Library is based on the ADLMIDI, a MIDI player for Linux and Windows with OPL3 emulation:
* http://iki.fi/bisqwit/source/adlmidi.html
@@ -278,7 +278,7 @@ ADLMIDI_EXPORT int adl_getBank(ADL_MIDIPlayer *device, const ADL_BankId *idp, in
value.second.ins[i].flags = adlinsdata::Flag_NoSound;
std::pair<Synth::BankMap::iterator, bool> ir;
- if(flags & ADLMIDI_Bank_CreateRt)
+ if((flags & ADLMIDI_Bank_CreateRt) == ADLMIDI_Bank_CreateRt)
{
ir = map.insert(value, Synth::BankMap::do_not_expand_t());
if(ir.first == map.end())
diff --git a/src/adlmidi_bankmap.h b/src/adlmidi_bankmap.h
index c4402e9..eb67f6f 100644
--- a/src/adlmidi_bankmap.h
+++ b/src/adlmidi_bankmap.h
@@ -2,7 +2,7 @@
* libADLMIDI is a free Software MIDI synthesizer library with OPL3 emulation
*
* Original ADLMIDI code: Copyright (c) 2010-2014 Joel Yliluoma <bisqwit@iki.fi>
- * ADLMIDI Library API: Copyright (c) 2015-2019 Vitaly Novichkov <admin@wohlnet.ru>
+ * ADLMIDI Library API: Copyright (c) 2015-2020 Vitaly Novichkov <admin@wohlnet.ru>
*
* Library is based on the ADLMIDI, a MIDI player for Linux and Windows with OPL3 emulation:
* http://iki.fi/bisqwit/source/adlmidi.html
diff --git a/src/adlmidi_bankmap.tcc b/src/adlmidi_bankmap.tcc
index 90d8894..30856a1 100644
--- a/src/adlmidi_bankmap.tcc
+++ b/src/adlmidi_bankmap.tcc
@@ -2,7 +2,7 @@
* libADLMIDI is a free MIDI to WAV conversion library with OPL3 emulation
*
* Original ADLMIDI code: Copyright (c) 2010-2014 Joel Yliluoma <bisqwit@iki.fi>
- * ADLMIDI Library API: Copyright (c) 2015-2018 Vitaly Novichkov <admin@wohlnet.ru>
+ * ADLMIDI Library API: Copyright (c) 2015-2020 Vitaly Novichkov <admin@wohlnet.ru>
*
* Library is based on the ADLMIDI, a MIDI player for Linux and Windows with OPL3 emulation:
* http://iki.fi/bisqwit/source/adlmidi.html
diff --git a/src/adlmidi_cvt.hpp b/src/adlmidi_cvt.hpp
index 68088e5..cb16eb0 100644
--- a/src/adlmidi_cvt.hpp
+++ b/src/adlmidi_cvt.hpp
@@ -2,7 +2,7 @@
* libADLMIDI is a free Software MIDI synthesizer library with OPL3 emulation
*
* Original ADLMIDI code: Copyright (c) 2010-2014 Joel Yliluoma <bisqwit@iki.fi>
- * ADLMIDI Library API: Copyright (c) 2015-2019 Vitaly Novichkov <admin@wohlnet.ru>
+ * ADLMIDI Library API: Copyright (c) 2015-2020 Vitaly Novichkov <admin@wohlnet.ru>
*
* Library is based on the ADLMIDI, a MIDI player for Linux and Windows with OPL3 emulation:
* http://iki.fi/bisqwit/source/adlmidi.html
diff --git a/src/adlmidi_load.cpp b/src/adlmidi_load.cpp
index 57ca035..3e790db 100644
--- a/src/adlmidi_load.cpp
+++ b/src/adlmidi_load.cpp
@@ -2,7 +2,7 @@
* libADLMIDI is a free Software MIDI synthesizer library with OPL3 emulation
*
* Original ADLMIDI code: Copyright (c) 2010-2014 Joel Yliluoma <bisqwit@iki.fi>
- * ADLMIDI Library API: Copyright (c) 2015-2019 Vitaly Novichkov <admin@wohlnet.ru>
+ * ADLMIDI Library API: Copyright (c) 2015-2020 Vitaly Novichkov <admin@wohlnet.ru>
*
* Library is based on the ADLMIDI, a MIDI player for Linux and Windows with OPL3 emulation:
* http://iki.fi/bisqwit/source/adlmidi.html
diff --git a/src/adlmidi_midiplay.cpp b/src/adlmidi_midiplay.cpp
index 039b1a9..e931c1e 100644
--- a/src/adlmidi_midiplay.cpp
+++ b/src/adlmidi_midiplay.cpp
@@ -2,7 +2,7 @@
* libADLMIDI is a free Software MIDI synthesizer library with OPL3 emulation
*
* Original ADLMIDI code: Copyright (c) 2010-2014 Joel Yliluoma <bisqwit@iki.fi>
- * ADLMIDI Library API: Copyright (c) 2015-2019 Vitaly Novichkov <admin@wohlnet.ru>
+ * ADLMIDI Library API: Copyright (c) 2015-2020 Vitaly Novichkov <admin@wohlnet.ru>
*
* Library is based on the ADLMIDI, a MIDI player for Linux and Windows with OPL3 emulation:
* http://iki.fi/bisqwit/source/adlmidi.html
diff --git a/src/adlmidi_midiplay.hpp b/src/adlmidi_midiplay.hpp
index 1067252..9cf35b1 100644
--- a/src/adlmidi_midiplay.hpp
+++ b/src/adlmidi_midiplay.hpp
@@ -2,7 +2,7 @@
* libADLMIDI is a free Software MIDI synthesizer library with OPL3 emulation
*
* Original ADLMIDI code: Copyright (c) 2010-2014 Joel Yliluoma <bisqwit@iki.fi>
- * ADLMIDI Library API: Copyright (c) 2015-2019 Vitaly Novichkov <admin@wohlnet.ru>
+ * ADLMIDI Library API: Copyright (c) 2015-2020 Vitaly Novichkov <admin@wohlnet.ru>
*
* Library is based on the ADLMIDI, a MIDI player for Linux and Windows with OPL3 emulation:
* http://iki.fi/bisqwit/source/adlmidi.html
diff --git a/src/adlmidi_opl3.cpp b/src/adlmidi_opl3.cpp
index d37a9aa..a5d8f74 100644
--- a/src/adlmidi_opl3.cpp
+++ b/src/adlmidi_opl3.cpp
@@ -2,7 +2,7 @@
* libADLMIDI is a free Software MIDI synthesizer library with OPL3 emulation
*
* Original ADLMIDI code: Copyright (c) 2010-2014 Joel Yliluoma <bisqwit@iki.fi>
- * ADLMIDI Library API: Copyright (c) 2015-2019 Vitaly Novichkov <admin@wohlnet.ru>
+ * ADLMIDI Library API: Copyright (c) 2015-2020 Vitaly Novichkov <admin@wohlnet.ru>
*
* Library is based on the ADLMIDI, a MIDI player for Linux and Windows with OPL3 emulation:
* http://iki.fi/bisqwit/source/adlmidi.html
diff --git a/src/adlmidi_opl3.hpp b/src/adlmidi_opl3.hpp
index a3e237a..b97b5d3 100644
--- a/src/adlmidi_opl3.hpp
+++ b/src/adlmidi_opl3.hpp
@@ -2,7 +2,7 @@
* libADLMIDI is a free Software MIDI synthesizer library with OPL3 emulation
*
* Original ADLMIDI code: Copyright (c) 2010-2014 Joel Yliluoma <bisqwit@iki.fi>
- * ADLMIDI Library API: Copyright (c) 2015-2019 Vitaly Novichkov <admin@wohlnet.ru>
+ * ADLMIDI Library API: Copyright (c) 2015-2020 Vitaly Novichkov <admin@wohlnet.ru>
*
* Library is based on the ADLMIDI, a MIDI player for Linux and Windows with OPL3 emulation:
* http://iki.fi/bisqwit/source/adlmidi.html
diff --git a/src/adlmidi_private.cpp b/src/adlmidi_private.cpp
index 7905ec3..b2b5bdd 100644
--- a/src/adlmidi_private.cpp
+++ b/src/adlmidi_private.cpp
@@ -2,7 +2,7 @@
* libADLMIDI is a free Software MIDI synthesizer library with OPL3 emulation
*
* Original ADLMIDI code: Copyright (c) 2010-2014 Joel Yliluoma <bisqwit@iki.fi>
- * ADLMIDI Library API: Copyright (c) 2015-2019 Vitaly Novichkov <admin@wohlnet.ru>
+ * ADLMIDI Library API: Copyright (c) 2015-2020 Vitaly Novichkov <admin@wohlnet.ru>
*
* Library is based on the ADLMIDI, a MIDI player for Linux and Windows with OPL3 emulation:
* http://iki.fi/bisqwit/source/adlmidi.html
diff --git a/src/adlmidi_private.hpp b/src/adlmidi_private.hpp
index 79a9313..887fc4d 100644
--- a/src/adlmidi_private.hpp
+++ b/src/adlmidi_private.hpp
@@ -2,7 +2,7 @@
* libADLMIDI is a free Software MIDI synthesizer library with OPL3 emulation
*
* Original ADLMIDI code: Copyright (c) 2010-2014 Joel Yliluoma <bisqwit@iki.fi>
- * ADLMIDI Library API: Copyright (c) 2015-2019 Vitaly Novichkov <admin@wohlnet.ru>
+ * ADLMIDI Library API: Copyright (c) 2015-2020 Vitaly Novichkov <admin@wohlnet.ru>
*
* Library is based on the ADLMIDI, a MIDI player for Linux and Windows with OPL3 emulation:
* http://iki.fi/bisqwit/source/adlmidi.html
diff --git a/src/adlmidi_ptr.hpp b/src/adlmidi_ptr.hpp
index 7def439..e9648b4 100644
--- a/src/adlmidi_ptr.hpp
+++ b/src/adlmidi_ptr.hpp
@@ -2,7 +2,7 @@
* libADLMIDI is a free Software MIDI synthesizer library with OPL3 emulation
*
* Original ADLMIDI code: Copyright (c) 2010-2014 Joel Yliluoma <bisqwit@iki.fi>
- * ADLMIDI Library API: Copyright (c) 2015-2019 Vitaly Novichkov <admin@wohlnet.ru>
+ * ADLMIDI Library API: Copyright (c) 2015-2020 Vitaly Novichkov <admin@wohlnet.ru>
*
* Library is based on the ADLMIDI, a MIDI player for Linux and Windows with OPL3 emulation:
* http://iki.fi/bisqwit/source/adlmidi.html
diff --git a/src/adlmidi_sequencer.cpp b/src/adlmidi_sequencer.cpp
index d78815f..e6de2b3 100644
--- a/src/adlmidi_sequencer.cpp
+++ b/src/adlmidi_sequencer.cpp
@@ -2,7 +2,7 @@
* libADLMIDI is a free Software MIDI synthesizer library with OPL3 emulation
*
* Original ADLMIDI code: Copyright (c) 2010-2014 Joel Yliluoma <bisqwit@iki.fi>
- * ADLMIDI Library API: Copyright (c) 2015-2019 Vitaly Novichkov <admin@wohlnet.ru>
+ * ADLMIDI Library API: Copyright (c) 2015-2020 Vitaly Novichkov <admin@wohlnet.ru>
*
* Library is based on the ADLMIDI, a MIDI player for Linux and Windows with OPL3 emulation:
* http://iki.fi/bisqwit/source/adlmidi.html
diff --git a/src/chips/common/mutex.hpp b/src/chips/common/mutex.hpp
index 53d7b72..60be9ba 100644
--- a/src/chips/common/mutex.hpp
+++ b/src/chips/common/mutex.hpp
@@ -2,7 +2,7 @@
* libADLMIDI is a free Software MIDI synthesizer library with OPL3 emulation
*
* Original ADLMIDI code: Copyright (c) 2010-2014 Joel Yliluoma <bisqwit@iki.fi>
- * ADLMIDI Library API: Copyright (c) 2015-2019 Vitaly Novichkov <admin@wohlnet.ru>
+ * ADLMIDI Library API: Copyright (c) 2015-2020 Vitaly Novichkov <admin@wohlnet.ru>
*
* Library is based on the ADLMIDI, a MIDI player for Linux and Windows with OPL3 emulation:
* http://iki.fi/bisqwit/source/adlmidi.html
diff --git a/src/chips/dosbox_opl3.cpp b/src/chips/dosbox_opl3.cpp
index fa30e68..a3d5351 100644
--- a/src/chips/dosbox_opl3.cpp
+++ b/src/chips/dosbox_opl3.cpp
@@ -1,7 +1,7 @@
/*
* Interfaces over Yamaha OPL3 (YMF262) chip emulators
*
- * Copyright (c) 2017-2019 Vitaly Novichkov (Wohlstand)
+ * Copyright (c) 2017-2020 Vitaly Novichkov (Wohlstand)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
diff --git a/src/chips/dosbox_opl3.h b/src/chips/dosbox_opl3.h
index 9f88b95..ca3269c 100644
--- a/src/chips/dosbox_opl3.h
+++ b/src/chips/dosbox_opl3.h
@@ -1,7 +1,7 @@
/*
* Interfaces over Yamaha OPL3 (YMF262) chip emulators
*
- * Copyright (c) 2017-2019 Vitaly Novichkov (Wohlstand)
+ * Copyright (c) 2017-2020 Vitaly Novichkov (Wohlstand)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
diff --git a/src/chips/java_opl3.cpp b/src/chips/java_opl3.cpp
index e29c6d0..ec8c6c7 100644
--- a/src/chips/java_opl3.cpp
+++ b/src/chips/java_opl3.cpp
@@ -1,7 +1,7 @@
/*
* Interfaces over Yamaha OPL3 (YMF262) chip emulators
*
- * Copyright (c) 2017-2019 Vitaly Novichkov (Wohlstand)
+ * Copyright (c) 2017-2020 Vitaly Novichkov (Wohlstand)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
diff --git a/src/chips/java_opl3.h b/src/chips/java_opl3.h
index 51b5be2..edadd88 100644
--- a/src/chips/java_opl3.h
+++ b/src/chips/java_opl3.h
@@ -1,7 +1,7 @@
/*
* Interfaces over Yamaha OPL3 (YMF262) chip emulators
*
- * Copyright (c) 2017-2019 Vitaly Novichkov (Wohlstand)
+ * Copyright (c) 2017-2020 Vitaly Novichkov (Wohlstand)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
diff --git a/src/chips/nuked_opl3.cpp b/src/chips/nuked_opl3.cpp
index 58b3890..ad379eb 100644
--- a/src/chips/nuked_opl3.cpp
+++ b/src/chips/nuked_opl3.cpp
@@ -1,7 +1,7 @@
/*
* Interfaces over Yamaha OPL3 (YMF262) chip emulators
*
- * Copyright (c) 2017-2019 Vitaly Novichkov (Wohlstand)
+ * Copyright (c) 2017-2020 Vitaly Novichkov (Wohlstand)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
diff --git a/src/chips/nuked_opl3.h b/src/chips/nuked_opl3.h
index 838631d..d9c0e76 100644
--- a/src/chips/nuked_opl3.h
+++ b/src/chips/nuked_opl3.h
@@ -1,7 +1,7 @@
/*
* Interfaces over Yamaha OPL3 (YMF262) chip emulators
*
- * Copyright (c) 2017-2019 Vitaly Novichkov (Wohlstand)
+ * Copyright (c) 2017-2020 Vitaly Novichkov (Wohlstand)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
diff --git a/src/chips/nuked_opl3_v174.cpp b/src/chips/nuked_opl3_v174.cpp
index d2f0fe9..a15e1ef 100644
--- a/src/chips/nuked_opl3_v174.cpp
+++ b/src/chips/nuked_opl3_v174.cpp
@@ -1,7 +1,7 @@
/*
* Interfaces over Yamaha OPL3 (YMF262) chip emulators
*
- * Copyright (c) 2017-2019 Vitaly Novichkov (Wohlstand)
+ * Copyright (c) 2017-2020 Vitaly Novichkov (Wohlstand)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
diff --git a/src/chips/nuked_opl3_v174.h b/src/chips/nuked_opl3_v174.h
index 9dcfe8b..bba7afd 100644
--- a/src/chips/nuked_opl3_v174.h
+++ b/src/chips/nuked_opl3_v174.h
@@ -1,7 +1,7 @@
/*
* Interfaces over Yamaha OPL3 (YMF262) chip emulators
*
- * Copyright (c) 2017-2019 Vitaly Novichkov (Wohlstand)
+ * Copyright (c) 2017-2020 Vitaly Novichkov (Wohlstand)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
diff --git a/src/chips/opal_opl3.cpp b/src/chips/opal_opl3.cpp
index 4a17c5c..3c1cbb7 100644
--- a/src/chips/opal_opl3.cpp
+++ b/src/chips/opal_opl3.cpp
@@ -1,7 +1,7 @@
/*
* Interfaces over Yamaha OPL3 (YMF262) chip emulators
*
- * Copyright (c) 2017-2019 Vitaly Novichkov (Wohlstand)
+ * Copyright (c) 2017-2020 Vitaly Novichkov (Wohlstand)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
diff --git a/src/chips/opal_opl3.h b/src/chips/opal_opl3.h
index 98d4262..ca14f3a 100644
--- a/src/chips/opal_opl3.h
+++ b/src/chips/opal_opl3.h
@@ -1,7 +1,7 @@
/*
* Interfaces over Yamaha OPL3 (YMF262) chip emulators
*
- * Copyright (c) 2017-2019 Vitaly Novichkov (Wohlstand)
+ * Copyright (c) 2017-2020 Vitaly Novichkov (Wohlstand)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
diff --git a/src/chips/opl_chip_base.h b/src/chips/opl_chip_base.h
index 2dbf726..006e222 100644
--- a/src/chips/opl_chip_base.h
+++ b/src/chips/opl_chip_base.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2019 Vitaly Novichkov (Wohlstand)
+ * Copyright (c) 2017-2020 Vitaly Novichkov (Wohlstand)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
diff --git a/src/cvt_mus2mid.hpp b/src/cvt_mus2mid.hpp
index 7aa355f..4b07b0d 100644
--- a/src/cvt_mus2mid.hpp
+++ b/src/cvt_mus2mid.hpp
@@ -3,7 +3,7 @@
*
* Copyright (C) 2014 Bret Curtis
* Copyright (C) WildMIDI Developers 2015-2016
- * ADLMIDI Library API: Copyright (c) 2015-2019 Vitaly Novichkov <admin@wohlnet.ru>
+ * ADLMIDI Library API: Copyright (c) 2015-2020 Vitaly Novichkov <admin@wohlnet.ru>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
diff --git a/src/cvt_xmi2mid.hpp b/src/cvt_xmi2mid.hpp
index 8f21ac8..d852ca9 100644
--- a/src/cvt_xmi2mid.hpp
+++ b/src/cvt_xmi2mid.hpp
@@ -4,7 +4,7 @@
* Copyright (C) 2001 Ryan Nunn
* Copyright (C) 2014 Bret Curtis
* Copyright (C) WildMIDI Developers 2015-2016
- * Copyright (c) 2015-2019 Vitaly Novichkov <admin@wohlnet.ru>
+ * Copyright (c) 2015-2020 Vitaly Novichkov <admin@wohlnet.ru>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
diff --git a/src/file_reader.hpp b/src/file_reader.hpp
index c044e90..291850c 100644
--- a/src/file_reader.hpp
+++ b/src/file_reader.hpp
@@ -1,7 +1,7 @@
/*
* FileAndMemoryReader - a tiny helper to utify file reading from a disk and memory block
*
- * Copyright (c) 2015-2019 Vitaly Novichkov <admin@wohlnet.ru>
+ * Copyright (c) 2015-2020 Vitaly Novichkov <admin@wohlnet.ru>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
@@ -110,15 +110,15 @@ public:
/**
* @brief Open file from memory block
* @param mem Pointer to the memory block
- * @param lenght Size of given block
+ * @param length Size of given block
*/
- void openData(const void *mem, size_t lenght)
+ void openData(const void *mem, size_t length)
{
if(m_fp)
this->close();//Close previously opened file first!
m_fp = NULL;
m_mp = mem;
- m_mp_size = lenght;
+ m_mp_size = length;
m_mp_tell = 0;
}
diff --git a/src/midi_sequencer.h b/src/midi_sequencer.h
index 4c6693f..b9b8982 100644
--- a/src/midi_sequencer.h
+++ b/src/midi_sequencer.h
@@ -1,7 +1,7 @@
/*
* BW_Midi_Sequencer - MIDI Sequencer for C++
*
- * Copyright (c) 2015-2019 Vitaly Novichkov <admin@wohlnet.ru>
+ * Copyright (c) 2015-2020 Vitaly Novichkov <admin@wohlnet.ru>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
@@ -23,8 +23,8 @@
*/
#pragma once
-#ifndef BISQUIT_AND_WOHLSTANDS_MIDI_SEQUENCER_HHHH
-#define BISQUIT_AND_WOHLSTANDS_MIDI_SEQUENCER_HHHH
+#ifndef BW_MIDI_SEQUENCER_HHHH
+#define BW_MIDI_SEQUENCER_HHHH
#ifdef __cplusplus
extern "C" {
@@ -52,10 +52,10 @@ typedef struct BW_MidiRtInterface
/*! User data which will be passed through On-PCM-render hook */
void *onPcmRender_userData;
- //! Sample rate
+ /*! Sample rate */
uint32_t pcmSampleRate;
- //! Size of one sample in bytes
+ /*! Size of one sample in bytes */
uint32_t pcmFrameSize;
/*! Library internal debug messages */
@@ -97,6 +97,11 @@ typedef struct BW_MidiRtInterface
/*! Note-Off MIDI event hook */
RtNoteOff rt_noteOff;
+ /*! Note-Off MIDI event with a velocity */
+ typedef void (*RtNoteOffVel)(void *userdata, uint8_t channel, uint8_t note, uint8_t velocity);
+ /*! Note-Off MIDI event hook with a velocity */
+ RtNoteOffVel rt_noteOffVel;
+
/*! Note aftertouch MIDI event */
typedef void (*RtNoteAfterTouch)(void *userdata, uint8_t channel, uint8_t note, uint8_t atVal);
/*! Note aftertouch MIDI event hook */
@@ -108,9 +113,9 @@ typedef struct BW_MidiRtInterface
RtChannelAfterTouch rt_channelAfterTouch;
/*! Controller change MIDI event */
- typedef void (*RtControlerChange)(void *userdata, uint8_t channel, uint8_t type, uint8_t value);
+ typedef void (*RtControllerChange)(void *userdata, uint8_t channel, uint8_t type, uint8_t value);
/*! Controller change MIDI event hook */
- RtControlerChange rt_controllerChange;
+ RtControllerChange rt_controllerChange;
/*! Patch change MIDI event */
typedef void (*RtPatchChange)(void *userdata, uint8_t channel, uint8_t patch);
@@ -132,6 +137,11 @@ typedef struct BW_MidiRtInterface
* Optional events *
*******************/
+ /*! Meta event hook */
+ typedef void (*MetaEventHook)(void *userdata, uint8_t type, const uint8_t *data, size_t len);
+ /*! Meta event hook which catches all meta events */
+ MetaEventHook rt_metaEvent;
+
/*! Device Switch MIDI event */
typedef void (*RtDeviceSwitch)(void *userdata, size_t track, const char *data, size_t length);
/*! Device Switch MIDI event hook */
@@ -158,4 +168,4 @@ typedef struct BW_MidiRtInterface
}
#endif
-#endif /* BISQUIT_AND_WOHLSTANDS_MIDI_SEQUENCER_HHHH */
+#endif /* BW_MIDI_SEQUENCER_HHHH */
diff --git a/src/midi_sequencer.hpp b/src/midi_sequencer.hpp
index 6832492..7ff864c 100644
--- a/src/midi_sequencer.hpp
+++ b/src/midi_sequencer.hpp
@@ -1,7 +1,7 @@
/*
* BW_Midi_Sequencer - MIDI Sequencer for C++
*
- * Copyright (c) 2015-2019 Vitaly Novichkov <admin@wohlnet.ru>
+ * Copyright (c) 2015-2020 Vitaly Novichkov <admin@wohlnet.ru>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
@@ -23,8 +23,8 @@
*/
#pragma once
-#ifndef BISQUIT_AND_WOHLSTANDS_MIDI_SEQUENCER_HHHHPPP
-#define BISQUIT_AND_WOHLSTANDS_MIDI_SEQUENCER_HHHHPPP
+#ifndef BW_MIDI_SEQUENCER_HHHHPPP
+#define BW_MIDI_SEQUENCER_HHHHPPP
#include <list>
#include <vector>
@@ -454,7 +454,7 @@ private:
{
if(caughtStackEnd && (stackLevel >= 0) && (stackLevel < static_cast<int>(stack.size())))
{
- const LoopStackEntry &e = stack[stackLevel];
+ const LoopStackEntry &e = stack[static_cast<size_t>(stackLevel)];
if(e.infinity || (!e.infinity && e.loops > 0))
return true;
}
@@ -474,7 +474,7 @@ private:
LoopStackEntry &getCurStack()
{
if((stackLevel >= 0) && (stackLevel < static_cast<int>(stack.size())))
- return stack[stackLevel];
+ return stack[static_cast<size_t>(stackLevel)];
if(stack.empty())
{
LoopStackEntry d;
@@ -792,4 +792,4 @@ private:
};
-#endif /* BISQUIT_AND_WOHLSTANDS_MIDI_SEQUENCER_HHHHPPP */
+#endif /* BW_MIDI_SEQUENCER_HHHHPPP */
diff --git a/src/midi_sequencer_impl.hpp b/src/midi_sequencer_impl.hpp
index 02a4156..f0ba839 100644
--- a/src/midi_sequencer_impl.hpp
+++ b/src/midi_sequencer_impl.hpp
@@ -1,7 +1,7 @@
/*
* BW_Midi_Sequencer - MIDI Sequencer for C++
*
- * Copyright (c) 2015-2019 Vitaly Novichkov <admin@wohlnet.ru>
+ * Copyright (c) 2015-2020 Vitaly Novichkov <admin@wohlnet.ru>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
@@ -80,11 +80,11 @@ __inline int c99_snprintf(char *outBuf, size_t size, const char *format, ...)
#ifndef BWMIDI_DISABLE_MUS_SUPPORT
#include "cvt_mus2mid.hpp"
-#endif//MUS
+#endif // MUS
#ifndef BWMIDI_DISABLE_XMI_SUPPORT
#include "cvt_xmi2mid.hpp"
-#endif//XMI
+#endif // XMI
/**
* @brief Utility function to read Big-Endian integer from raw binary data
@@ -244,13 +244,13 @@ void BW_MidiSequencer::MidiTrackRow::sortEvents(bool *noteStates)
int noteOffsOnSameNote = 0;
for(EvtArr::iterator j = noteOffs.begin(); j != noteOffs.end();)
{
- //If note was off, and note-off on same row with note-on - move it down!
+ // If note was off, and note-off on same row with note-on - move it down!
if(
((*j).channel == e.channel) &&
((*j).data[0] == e.data[0])
)
{
- //If note is already off OR more than one note-off on same row and same note
+ // If note is already off OR more than one note-off on same row and same note
if(!wasOn || (noteOffsOnSameNote != 0))
{
anyOther.push_back(*j);
@@ -260,9 +260,9 @@ void BW_MidiSequencer::MidiTrackRow::sortEvents(bool *noteStates)
}
else
{
- //When same row has many note-offs on same row
- //that means a zero-length note follows previous note
- //it must be shuted down
+ // When same row has many note-offs on same row
+ // that means a zero-length note follows previous note
+ // it must be shuted down
noteOffsOnSameNote++;
}
}
@@ -271,7 +271,7 @@ void BW_MidiSequencer::MidiTrackRow::sortEvents(bool *noteStates)
}
}
- //Mark other notes as released
+ // Mark other notes as released
for(EvtArr::iterator j = noteOffs.begin(); j != noteOffs.end(); j++)
{
size_t note_i = static_cast<size_t>(j->channel * 255) + (j->data[0] & 0x7F);
@@ -326,21 +326,21 @@ void BW_MidiSequencer::setInterface(const BW_MidiRtInterface *intrf)
// Interface must NOT be NULL
assert(intrf);
- //Note ON hook is REQUIRED
+ // Note ON hook is REQUIRED
assert(intrf->rt_noteOn);
- //Note OFF hook is REQUIRED
- assert(intrf->rt_noteOff);
- //Note Aftertouch hook is REQUIRED
+ // Note OFF hook is REQUIRED
+ assert(intrf->rt_noteOff || intrf->rt_noteOffVel);
+ // Note Aftertouch hook is REQUIRED
assert(intrf->rt_noteAfterTouch);
- //Channel Aftertouch hook is REQUIRED
+ // Channel Aftertouch hook is REQUIRED
assert(intrf->rt_channelAfterTouch);
- //Controller change hook is REQUIRED
+ // Controller change hook is REQUIRED
assert(intrf->rt_controllerChange);
- //Patch change hook is REQUIRED
+ // Patch change hook is REQUIRED
assert(intrf->rt_patchChange);
- //Pitch bend hook is REQUIRED
+ // Pitch bend hook is REQUIRED
assert(intrf->rt_pitchBend);
- //System Exclusive hook is REQUIRED
+ // System Exclusive hook is REQUIRED
assert(intrf->rt_systemExclusive);
if(intrf->pcmSampleRate != 0 && intrf->pcmFrameSize != 0)
@@ -368,7 +368,7 @@ int BW_MidiSequencer::playStream(uint8_t *stream, size_t length)
const double leftDelay = left / double(m_time.sampleRate);
const double maxDelay = m_time.timeRest < leftDelay ? m_time.timeRest : leftDelay;
if((positionAtEnd()) && (m_time.delay <= 0.0))
- break;//Stop to fetch samples at reaching the song end with disabled loop
+ break; // Stop to fetch samples at reaching the song end with disabled loop
m_time.timeRest -= maxDelay;
periodSize = static_cast<size_t>(static_cast<double>(m_time.sampleRate) * maxDelay);
@@ -550,7 +550,7 @@ bool BW_MidiSequencer::buildSmfTrackData(const std::vector<std::vector<uint8_t>
const uint8_t *trackPtr = trackData[tk].data();
std::memset(noteStates, 0, sizeof(noteStates));
- //Time delay that follows the first event in the track
+ // Time delay that follows the first event in the track
{
MidiTrackRow evtPos;
if(m_format == Format_RSXX)
@@ -565,7 +565,7 @@ bool BW_MidiSequencer::buildSmfTrackData(const std::vector<std::vector<uint8_t>
return false;
}
- //HACK: Begin every track with "Reset all controllers" event to avoid controllers state break came from end of song
+ // HACK: Begin every track with "Reset all controllers" event to avoid controllers state break came from end of song
for(uint8_t chan = 0; chan < 16; chan++)
{
MidiEvent resetEvent;
@@ -615,7 +615,7 @@ bool BW_MidiSequencer::buildSmfTrackData(const std::vector<std::vector<uint8_t>
gotGlobalLoopStart = true;
loopStartTicks = abs_position;
}
- //In this row we got loop event, register this!
+ // In this row we got loop event, register this!
gotLoopEventInThisRow = true;
}
else if(!m_loop.invalidLoop && (event.subtype == MidiEvent::ST_LOOPEND))
@@ -693,7 +693,7 @@ bool BW_MidiSequencer::buildSmfTrackData(const std::vector<std::vector<uint8_t>
}
}
- if(event.subtype != MidiEvent::ST_ENDTRACK)//Don't try to read delta after EndOfTrack event!
+ if(event.subtype != MidiEvent::ST_ENDTRACK) // Don't try to read delta after EndOfTrack event!
{
evtPos.delay = readVarLenEx(&trackPtr, end, ok);
if(!ok)
@@ -731,7 +731,7 @@ bool BW_MidiSequencer::buildSmfTrackData(const std::vector<std::vector<uint8_t>
if(ticksSongLength < abs_position)
ticksSongLength = abs_position;
- //Set the chain of events begin
+ // Set the chain of events begin
if(m_trackData[tk].size() > 0)
m_currentPosition.track[tk].pos = m_trackData[tk].begin();
}
@@ -742,7 +742,7 @@ bool BW_MidiSequencer::buildSmfTrackData(const std::vector<std::vector<uint8_t>
loopEndTicks = ticksSongLength;
}
- //loopStart must be located before loopEnd!
+ // loopStart must be located before loopEnd!
if(loopStartTicks >= loopEndTicks)
{
m_loop.invalidLoop = true;
@@ -766,7 +766,7 @@ void BW_MidiSequencer::buildTimeLine(const std::vector<MidiEvent> &tempos,
{
const size_t trackCount = m_trackData.size();
/********************************************************************************/
- //Calculate time basing on collected tempo events
+ // Calculate time basing on collected tempo events
/********************************************************************************/
for(size_t tk = 0; tk < trackCount; ++tk)
{
@@ -790,21 +790,21 @@ void BW_MidiSequencer::buildTimeLine(const std::vector<MidiEvent> &tempos,
bool tempoChanged = false;
#endif
MidiTrackRow &pos = *it;
- if((posPrev != &pos) && //Skip first event
- (!tempos.empty()) && //Only when in-track tempo events are available
+ if((posPrev != &pos) && // Skip first event
+ (!tempos.empty()) && // Only when in-track tempo events are available
(tempo_change_index < tempos.size())
)
{
// If tempo event is going between of current and previous event
if(tempos[tempo_change_index].absPosition <= pos.absPos)
{
- //Stop points: begin point and tempo change points are before end point
+ // Stop points: begin point and tempo change points are before end point
std::vector<TempoChangePoint> points;
fraction<uint64_t> t;
TempoChangePoint firstPoint = {posPrev->absPos, currentTempo};
points.push_back(firstPoint);
- //Collect tempo change points between previous and current events
+ // Collect tempo change points between previous and current events
do
{
TempoChangePoint tempoMarker;
@@ -826,25 +826,25 @@ void BW_MidiSequencer::buildTimeLine(const std::vector<MidiEvent> &tempos,
/* If one or more tempo events are appears between of two events,
* calculate delays between each tempo point, begin and end */
uint64_t midDelay = 0;
- //Delay between points
+ // Delay between points
midDelay = points[j].absPos - points[i].absPos;
- //Time delay between points
+ // Time delay between points
t = midDelay * currentTempo;
posPrev->timeDelay += t.value();
- //Apply next tempo
+ // Apply next tempo
currentTempo = points[j].tempo;
#ifdef DEBUG_TIME_CALCULATION
tempoChanged = true;
#endif
}
- //Then calculate time between last tempo change point and end point
+ // Then calculate time between last tempo change point and end point
TempoChangePoint tailTempo = points.back();
uint64_t postDelay = pos.absPos - tailTempo.absPos;
t = postDelay * currentTempo;
posPrev->timeDelay += t.value();
- //Store Common time delay
+ // Store Common time delay
posPrev->time = time;
time += posPrev->timeDelay;
}
@@ -855,7 +855,7 @@ void BW_MidiSequencer::buildTimeLine(const std::vector<MidiEvent> &tempos,
pos.time = time;
time += pos.timeDelay;
- //Capture markers after time value calculation
+ // Capture markers after time value calculation
for(size_t i = 0; i < pos.events.size(); i++)
{
MidiEvent &e = pos.events[i];
@@ -869,7 +869,7 @@ void BW_MidiSequencer::buildTimeLine(const std::vector<MidiEvent> &tempos,
}
}
- //Capture loop points time positions
+ // Capture loop points time positions
if(!m_loop.invalidLoop)
{
// Set loop points times
@@ -893,19 +893,19 @@ void BW_MidiSequencer::buildTimeLine(const std::vector<MidiEvent> &tempos,
}
m_fullSongTimeLength += m_postSongWaitDelay;
- //Set begin of the music
+ // Set begin of the music
m_trackBeginPosition = m_currentPosition;
- //Initial loop position will begin at begin of track until passing of the loop point
+ // Initial loop position will begin at begin of track until passing of the loop point
m_loopBeginPosition = m_currentPosition;
- //Set lowest level of the loop stack
+ // Set lowest level of the loop stack
m_loop.stackLevel = -1;
/********************************************************************************/
- //Resolve "hell of all times" of too short drum notes:
- //move too short percussion note-offs far far away as possible
+ // Resolve "hell of all times" of too short drum notes:
+ // move too short percussion note-offs far far away as possible
/********************************************************************************/
-#if 0 //Use this to record WAVEs for comparison before/after implementing of this
- if(m_format == Format_MIDI)//Percussion fix is needed for MIDI only, not for IMF/RSXX or CMF
+#if 0 // Use this to record WAVEs for comparison before/after implementing of this
+ if(m_format == Format_MIDI) // Percussion fix is needed for MIDI only, not for IMF/RSXX or CMF
{
//! Minimal real time in seconds
#define DRUM_NOTE_MIN_TIME 0.03
@@ -926,7 +926,7 @@ void BW_MidiSequencer::buildTimeLine(const std::vector<MidiEvent> &tempos,
std::memset(banks, 0, sizeof(banks));
MidiTrackQueue &track = m_trackData[tk];
if(track.empty())
- continue;//Empty track is useless!
+ continue; // Empty track is useless!
for(MidiTrackQueue::iterator it = track.begin(); it != track.end(); it++)
{
@@ -956,8 +956,8 @@ void BW_MidiSequencer::buildTimeLine(const std::vector<MidiEvent> &tempos,
}
bool percussion = (et->channel == 9) ||
- banks[et->channel] == 0x7E00 || //XG SFX1/SFX2 channel (16128 signed decimal)
- banks[et->channel] == 0x7F00; //XG Percussion channel (16256 signed decimal)
+ banks[et->channel] == 0x7E00 || // XG SFX1/SFX2 channel (16128 signed decimal)
+ banks[et->channel] == 0x7F00; // XG Percussion channel (16256 signed decimal)
if(!percussion)
continue;
@@ -976,7 +976,7 @@ void BW_MidiSequencer::buildTimeLine(const std::vector<MidiEvent> &tempos,
if(ns.isOn)
{
ns.isOn = false;
- if(ns.delayTicks < DRUM_NOTE_MIN_TICKS || ns.delay < DRUM_NOTE_MIN_TIME)//If note is too short
+ if(ns.delayTicks < DRUM_NOTE_MIN_TICKS || ns.delay < DRUM_NOTE_MIN_TIME) // If note is too short
{
//Move it into next event position if that possible
for(MidiTrackQueue::iterator itNext = it;
@@ -986,9 +986,9 @@ void BW_MidiSequencer::buildTimeLine(const std::vector<MidiEvent> &tempos,
MidiTrackRow &posN = *itNext;
if(ns.delayTicks > DRUM_NOTE_MIN_TICKS && ns.delay > DRUM_NOTE_MIN_TIME)
{
- //Put note-off into begin of next event list
+ // Put note-off into begin of next event list
posN.events.insert(posN.events.begin(), pos.events[(size_t)e]);
- //Renive this event from a current row
+ // Renive this event from a current row
pos.events.erase(pos.events.begin() + (int)e);
e--;
break;
@@ -1025,14 +1025,14 @@ void BW_MidiSequencer::buildTimeLine(const std::vector<MidiEvent> &tempos,
bool BW_MidiSequencer::processEvents(bool isSeek)
{
if(m_currentPosition.track.size() == 0)
- m_atEnd = true;//No MIDI track data to play
+ m_atEnd = true; // No MIDI track data to play
if(m_atEnd)
- return false;//No more events in the queue
+ return false; // No more events in the queue
m_loop.caughtEnd = false;
- const size_t TrackCount = m_currentPosition.track.size();
+ const size_t trackCount = m_currentPosition.track.size();
const Position rowBeginPosition(m_currentPosition);
- bool doLoopJump = false;
+ bool doLoopJump = false;
unsigned caughLoopStart = 0;
unsigned caughLoopStackStart = 0;
unsigned caughLoopStackEnds = 0;
@@ -1043,12 +1043,12 @@ bool BW_MidiSequencer::processEvents(bool isSeek)
double maxTime = 0.0;
#endif
- for(size_t tk = 0; tk < TrackCount; ++tk)
+ for(size_t tk = 0; tk < trackCount; ++tk)
{
Position::TrackInfo &track = m_currentPosition.track[tk];
if((track.lastHandledEvent >= 0) && (track.delay <= 0))
{
- //Check is an end of track has been reached
+ // Check is an end of track has been reached
if(track.pos == m_trackData[tk].end())
{
track.lastHandledEvent = -1;
@@ -1069,7 +1069,7 @@ bool BW_MidiSequencer::processEvents(bool isSeek)
if(m_loop.caughtStart)
{
- if(m_interface->onloopStart)//Loop Start hook
+ if(m_interface->onloopStart) // Loop Start hook
m_interface->onloopStart(m_interface->onloopStart_userData);
caughLoopStart++;
@@ -1078,7 +1078,7 @@ bool BW_MidiSequencer::processEvents(bool isSeek)
if(m_loop.caughtStackStart)
{
- if(m_interface->onloopStart && (m_loopStartTime >= track.pos->time))//Loop Start hook
+ if(m_interface->onloopStart && (m_loopStartTime >= track.pos->time)) // Loop Start hook
m_interface->onloopStart(m_interface->onloopStart_userData);
caughLoopStackStart++;
@@ -1100,7 +1100,7 @@ bool BW_MidiSequencer::processEvents(bool isSeek)
caughLoopStackEndsTime = track.pos->time;
}
doLoopJump = true;
- break;//Stop event handling on catching loopEnd event!
+ break; // Stop event handling on catching loopEnd event!
}
}
@@ -1126,32 +1126,31 @@ bool BW_MidiSequencer::processEvents(bool isSeek)
std::fflush(stdout);
#endif
- // Find shortest delay from all track
- uint64_t shortest = 0;
- bool shortest_no = true;
+ // Find a shortest delay from all track
+ uint64_t shortestDelay = 0;
+ bool shortestDelayNotFound = true;
- for(size_t tk = 0; tk < TrackCount; ++tk)
+ for(size_t tk = 0; tk < trackCount; ++tk)
{
Position::TrackInfo &track = m_currentPosition.track[tk];
- if((track.lastHandledEvent >= 0) && (shortest_no || track.delay < shortest))
+ if((track.lastHandledEvent >= 0) && (shortestDelayNotFound || track.delay < shortestDelay))
{
- shortest = track.delay;
- shortest_no = false;
+ shortestDelay = track.delay;
+ shortestDelayNotFound = false;
}
}
// Schedule the next playevent to be processed after that delay
- for(size_t tk = 0; tk < TrackCount; ++tk)
- m_currentPosition.track[tk].delay -= shortest;
+ for(size_t tk = 0; tk < trackCount; ++tk)
+ m_currentPosition.track[tk].delay -= shortestDelay;
- fraction<uint64_t> t = shortest * m_tempo;
+ fraction<uint64_t> t = shortestDelay * m_tempo;
#ifdef ENABLE_BEGIN_SILENCE_SKIPPING
if(m_currentPosition.began)
#endif
m_currentPosition.wait += t.value();
- //if(shortest > 0) UI.PrintLn("Delay %ld (%g)", shortest, (double)t.valuel());
if(caughLoopStart > 0)
m_loopBeginPosition = rowBeginPosition;
@@ -1187,13 +1186,13 @@ bool BW_MidiSequencer::processEvents(bool isSeek)
LoopStackEntry &s = m_loop.getCurStack();
if(s.infinity)
{
- if(m_interface->onloopEnd && (m_loopEndTime >= caughLoopStackEndsTime))//Loop End hook
+ if(m_interface->onloopEnd && (m_loopEndTime >= caughLoopStackEndsTime)) // Loop End hook
{
m_interface->onloopEnd(m_interface->onloopEnd_userData);
- if(m_loopHooksOnly)//Stop song on reaching loop end
+ if(m_loopHooksOnly) // Stop song on reaching loop end
{
- m_atEnd = true; //Don't handle events anymore
- m_currentPosition.wait += m_postSongWaitDelay;//One second delay until stop playing
+ m_atEnd = true; // Don't handle events anymore
+ m_currentPosition.wait += m_postSongWaitDelay; // One second delay until stop playing
}
}
m_currentPosition = s.startPosition;
@@ -1227,25 +1226,25 @@ bool BW_MidiSequencer::processEvents(bool isSeek)
return true;
}
- if(shortest_no || m_loop.caughtEnd)
+ if(shortestDelayNotFound || m_loop.caughtEnd)
{
- if(m_interface->onloopEnd)//Loop End hook
+ if(m_interface->onloopEnd) // Loop End hook
m_interface->onloopEnd(m_interface->onloopEnd_userData);
- //Loop if song end or loop end point has reached
+ // Loop if song end or loop end point has reached
m_loop.caughtEnd = false;
- shortest = 0;
+ shortestDelay = 0;
if(!m_loopEnabled || m_loopHooksOnly)
{
- m_atEnd = true; //Don't handle events anymore
- m_currentPosition.wait += m_postSongWaitDelay;//One second delay until stop playing
- return true;//We have caugh end here!
+ m_atEnd = true; // Don't handle events anymore
+ m_currentPosition.wait += m_postSongWaitDelay; // One second delay until stop playing
+ return true; // We have caugh end here!
}
m_currentPosition = m_loopBeginPosition;
}
- return true;//Has events in queue
+ return true; // Has events in queue
}
BW_MidiSequencer::MidiEvent BW_MidiSequencer::parseEvent(const uint8_t **pptr, const uint8_t *end, int &status)
@@ -1255,7 +1254,7 @@ BW_MidiSequencer::MidiEvent BW_MidiSequencer::parseEvent(const uint8_t **pptr, c
if(ptr + 1 > end)
{
- //When track doesn't ends on the middle of event data, it's must be fine
+ // When track doesn't ends on the middle of event data, it's must be fine
evt.type = MidiEvent::T_SPECIAL;
evt.subtype = MidiEvent::ST_ENDTRACK;
return evt;
@@ -1264,7 +1263,7 @@ BW_MidiSequencer::MidiEvent BW_MidiSequencer::parseEvent(const uint8_t **pptr, c
unsigned char byte = *(ptr++);
bool ok = false;
- if(byte == MidiEvent::T_SYSEX || byte == MidiEvent::T_SYSEX2)// Ignore SysEx
+ if(byte == MidiEvent::T_SYSEX || byte == MidiEvent::T_SYSEX2) // Ignore SysEx
{
uint64_t length = readVarLenEx(pptr, end, ok);
if(!ok || (ptr + length > end))
@@ -1292,7 +1291,7 @@ BW_MidiSequencer::MidiEvent BW_MidiSequencer::parseEvent(const uint8_t **pptr, c
evt.isValid = 0;
return evt;
}
- std::string data(length ? (const char *)ptr : 0, (size_t)length);
+ std::string data(length ? (const char *)ptr : NULL, (size_t)length);
ptr += (size_t)length;
evt.type = byte;
@@ -1354,7 +1353,7 @@ BW_MidiSequencer::MidiEvent BW_MidiSequencer::parseEvent(const uint8_t **pptr, c
}
else if(evt.subtype == MidiEvent::ST_MARKER)
{
- //To lower
+ // To lower
for(size_t i = 0; i < data.size(); i++)
{
if(data[i] <= 'Z' && data[i] >= 'A')
@@ -1363,17 +1362,17 @@ BW_MidiSequencer::MidiEvent BW_MidiSequencer::parseEvent(const uint8_t **pptr, c
if(data == "loopstart")
{
- //Return a custom Loop Start event instead of Marker
+ // Return a custom Loop Start event instead of Marker
evt.subtype = MidiEvent::ST_LOOPSTART;
- evt.data.clear();//Data is not needed
+ evt.data.clear(); // Data is not needed
return evt;
}
if(data == "loopend")
{
- //Return a custom Loop End event instead of Marker
+ // Return a custom Loop End event instead of Marker
evt.subtype = MidiEvent::ST_LOOPEND;
- evt.data.clear();//Data is not needed
+ evt.data.clear(); // Data is not needed
return evt;
}
@@ -1419,7 +1418,7 @@ BW_MidiSequencer::MidiEvent BW_MidiSequencer::parseEvent(const uint8_t **pptr, c
}
if(evtype == MidiEvent::ST_ENDTRACK)
- status = -1;//Finalize track
+ status = -1; // Finalize track
return evt;
}
@@ -1431,7 +1430,7 @@ BW_MidiSequencer::MidiEvent BW_MidiSequencer::parseEvent(const uint8_t **pptr, c
ptr--;
}
- //Sys Com Song Select(Song #) [0-127]
+ // Sys Com Song Select(Song #) [0-127]
if(byte == MidiEvent::T_SYSCOMSNGSEL)
{
if(ptr + 1 > end)
@@ -1445,7 +1444,7 @@ BW_MidiSequencer::MidiEvent BW_MidiSequencer::parseEvent(const uint8_t **pptr, c
return evt;
}
- //Sys Com Song Position Pntr [LSB, MSB]
+ // Sys Com Song Position Pntr [LSB, MSB]
if(byte == MidiEvent::T_SYSCOMSPOSPTR)
{
if(ptr + 2 > end)
@@ -1467,7 +1466,7 @@ BW_MidiSequencer::MidiEvent BW_MidiSequencer::parseEvent(const uint8_t **pptr, c
switch(evType)
{
- case MidiEvent::T_NOTEOFF://2 byte length
+ case MidiEvent::T_NOTEOFF: // 2 byte length
case MidiEvent::T_NOTEON:
case MidiEvent::T_NOTETOUCH:
case MidiEvent::T_CTRLCHANGE:
@@ -1489,7 +1488,7 @@ BW_MidiSequencer::MidiEvent BW_MidiSequencer::parseEvent(const uint8_t **pptr, c
else
if(evType == MidiEvent::T_CTRLCHANGE)
{
- //111'th loopStart controller (RPG Maker and others)
+ // 111'th loopStart controller (RPG Maker and others)
if(m_format == Format_MIDI)
{
switch(evt.data[0])
@@ -1497,7 +1496,7 @@ BW_MidiSequencer::MidiEvent BW_MidiSequencer::parseEvent(const uint8_t **pptr, c
case 110:
if(m_loopFormat == Loop_Default)
{
- //Change event type to custom Loop Start event and clear data
+ // Change event type to custom Loop Start event and clear data
evt.type = MidiEvent::T_SPECIAL;
evt.subtype = MidiEvent::ST_LOOPSTART;
evt.data.clear();
@@ -1513,7 +1512,7 @@ BW_MidiSequencer::MidiEvent BW_MidiSequencer::parseEvent(const uint8_t **pptr, c
case 111:
if(m_loopFormat == Loop_HMI)
{
- //Change event type to custom Loop End event and clear data
+ // Change event type to custom Loop End event and clear data
evt.type = MidiEvent::T_SPECIAL;
evt.subtype = MidiEvent::ST_LOOPEND;
evt.data.clear();
@@ -1530,7 +1529,7 @@ BW_MidiSequencer::MidiEvent BW_MidiSequencer::parseEvent(const uint8_t **pptr, c
case 113:
if(m_loopFormat == Loop_EMIDI)
{
- //EMIDI does using of CC113 with same purpose as CC7
+ // EMIDI does using of CC113 with same purpose as CC7
evt.data[0] = 7;
}
break;
@@ -1629,7 +1628,7 @@ BW_MidiSequencer::MidiEvent BW_MidiSequencer::parseEvent(const uint8_t **pptr, c
}
return evt;
- case MidiEvent::T_PATCHCHANGE://1 byte length
+ case MidiEvent::T_PATCHCHANGE: // 1 byte length
case MidiEvent::T_CHANAFTTOUCH:
if(ptr + 1 > end)
{
@@ -1671,14 +1670,6 @@ void BW_MidiSequencer::handleEvent(size_t track, const BW_MidiSequencer::MidiEve
if(evt.type == MidiEvent::T_SYSEX || evt.type == MidiEvent::T_SYSEX2) // Ignore SysEx
{
- //std::string data( length?(const char*) &TrackData[track][CurrentPosition.track[track].ptr]:0, length );
- //UI.PrintLn("SysEx %02X: %u bytes", byte, length/*, data.c_str()*/);
-#if 0
- std::fputs("SysEx:", stderr);
- for(size_t i = 0; i < evt.data.size(); ++i)
- std::fprintf(stderr, " %02X", evt.data[i]);
- std::fputc('\n', stderr);
-#endif
m_interface->rt_systemExclusive(m_interface->rtUserData, evt.data.data(), evt.data.size());
return;
}
@@ -1690,21 +1681,24 @@ void BW_MidiSequencer::handleEvent(size_t track, const BW_MidiSequencer::MidiEve
uint64_t length = static_cast<uint64_t>(evt.data.size());
const char *data(length ? reinterpret_cast<const char *>(evt.data.data()) : "");
- if(evtype == MidiEvent::ST_ENDTRACK)//End Of Track
+ if(m_interface->rt_metaEvent) // Meta event hook
+ m_interface->rt_metaEvent(m_interface->rtUserData, evtype, reinterpret_cast<const uint8_t*>(data), size_t(length));
+
+ if(evtype == MidiEvent::ST_ENDTRACK) // End Of Track
{
status = -1;
return;
}
- if(evtype == MidiEvent::ST_TEMPOCHANGE)//Tempo change
+ if(evtype == MidiEvent::ST_TEMPOCHANGE) // Tempo change
{
m_tempo = m_invDeltaTicks * fraction<uint64_t>(readBEint(evt.data.data(), evt.data.size()));
return;
}
- if(evtype == MidiEvent::ST_MARKER)//Meta event
+ if(evtype == MidiEvent::ST_MARKER) // Meta event
{
- //Do nothing! :-P
+ // Do nothing! :-P
return;
}
@@ -1717,7 +1711,7 @@ void BW_MidiSequencer::handleEvent(size_t track, const BW_MidiSequencer::MidiEve
return;
}
- //Turn on Loop handling when loop is enabled
+ // Turn on Loop handling when loop is enabled
if(m_loopEnabled && !m_loop.invalidLoop)
{
if(evtype == MidiEvent::ST_LOOPSTART) // Special non-spec MIDI loop Start point
@@ -1794,7 +1788,11 @@ void BW_MidiSequencer::handleEvent(size_t track, const BW_MidiSequencer::MidiEve
case MidiEvent::T_NOTEOFF: // Note off
{
uint8_t note = evt.data[0];
- m_interface->rt_noteOff(m_interface->rtUserData, static_cast<uint8_t>(midCh), note);
+ uint8_t vol = evt.data[1];
+ if(m_interface->rt_noteOff)
+ m_interface->rt_noteOff(m_interface->rtUserData, static_cast<uint8_t>(midCh), note);
+ if(m_interface->rt_noteOffVel)
+ m_interface->rt_noteOffVel(m_interface->rtUserData, static_cast<uint8_t>(midCh), note, vol);
break;
}
@@ -1850,7 +1848,7 @@ void BW_MidiSequencer::handleEvent(size_t track, const BW_MidiSequencer::MidiEve
double BW_MidiSequencer::Tick(double s, double granularity)
{
- assert(m_interface);// MIDI output interface must be defined!
+ assert(m_interface); // MIDI output interface must be defined!
s *= m_tempoMultiplier;
#ifdef ENABLE_BEGIN_SILENCE_SKIPPING
@@ -1859,7 +1857,7 @@ double BW_MidiSequencer::Tick(double s, double granularity)
m_currentPosition.wait -= s;
m_currentPosition.absTimePosition += s;
- int antiFreezeCounter = 10000;//Limit 10000 loops to avoid freezing
+ int antiFreezeCounter = 10000; // Limit 10000 loops to avoid freezing
while((m_currentPosition.wait <= granularity * 0.5) && (antiFreezeCounter > 0))
{
if(!processEvents())
@@ -1869,10 +1867,10 @@ double BW_MidiSequencer::Tick(double s, double granularity)
}
if(antiFreezeCounter <= 0)
- m_currentPosition.wait += 1.0;/* Add extra 1 second when over 10000 events
- with zero delay are been detected */
+ m_currentPosition.wait += 1.0; /* Add extra 1 second when over 10000 events
+ with zero delay are been detected */
- if(m_currentPosition.wait < 0.0)//Avoid negative delay value!
+ if(m_currentPosition.wait < 0.0) // Avoid negative delay value!
return 0.0;
return m_currentPosition.wait;
@@ -1882,9 +1880,9 @@ double BW_MidiSequencer::Tick(double s, double granularity)
double BW_MidiSequencer::seek(double seconds, const double granularity)
{
if(seconds < 0.0)
- return 0.0;//Seeking negative position is forbidden! :-P
+ return 0.0; // Seeking negative position is forbidden! :-P
const double granualityHalf = granularity * 0.5,
- s = seconds;//m_setup.delay < m_setup.maxdelay ? m_setup.delay : m_setup.maxdelay;
+ s = seconds; // m_setup.delay < m_setup.maxdelay ? m_setup.delay : m_setup.maxdelay;
/* Attempt to go away out of song end must rewind position to begin */
if(seconds > m_fullSongTimeLength)
@@ -1919,14 +1917,14 @@ double BW_MidiSequencer::seek(double seconds, const double granularity)
{
m_currentPosition.wait -= s;
m_currentPosition.absTimePosition += s;
- int antiFreezeCounter = 10000;//Limit 10000 loops to avoid freezing
+ int antiFreezeCounter = 10000; // Limit 10000 loops to avoid freezing
double dstWait = m_currentPosition.wait + granualityHalf;
while((m_currentPosition.wait <= granualityHalf)/*&& (antiFreezeCounter > 0)*/)
{
- //std::fprintf(stderr, "wait = %g...\n", CurrentPosition.wait);
+ // std::fprintf(stderr, "wait = %g...\n", CurrentPosition.wait);
if(!processEvents(true))
break;
- //Avoid freeze because of no waiting increasing in more than 10000 cycles
+ // Avoid freeze because of no waiting increasing in more than 10000 cycles
if(m_currentPosition.wait <= dstWait)
antiFreezeCounter--;
else
@@ -1937,7 +1935,7 @@ double BW_MidiSequencer::seek(double seconds, const double granularity)
}
if(antiFreezeCounter <= 0)
m_currentPosition.wait += 1.0;/* Add extra 1 second when over 10000 events
- with zero delay are been detected */
+ with zero delay are been detected */
}
if(m_currentPosition.wait < 0.0)
@@ -2087,7 +2085,7 @@ bool BW_MidiSequencer::loadMIDI(FileAndMemReader &fr)
BW_MidiSequencer_UNUSED(fsize);
m_parsingErrorsString.clear();
- assert(m_interface);// MIDI output interface must be defined!
+ assert(m_interface); // MIDI output interface must be defined!
if(!fr.isValid())
{
@@ -2260,7 +2258,7 @@ bool BW_MidiSequencer::parseIMF(FileAndMemReader &fr)
bool BW_MidiSequencer::parseRSXX(FileAndMemReader &fr)
{
- const size_t headerSize = 4 + 4 + 2 + 2 + 2; // 14
+ const size_t headerSize = 14;
char headerBuf[headerSize] = "";
size_t fsize = 0;
size_t deltaTicks = 192, trackCount = 1;
@@ -2347,7 +2345,7 @@ bool BW_MidiSequencer::parseRSXX(FileAndMemReader &fr)
bool BW_MidiSequencer::parseCMF(FileAndMemReader &fr)
{
- const size_t headerSize = 4 + 4 + 2 + 2 + 2; // 14
+ const size_t headerSize = 14;
char headerBuf[headerSize] = "";
size_t fsize = 0;
size_t deltaTicks = 192, trackCount = 1;
@@ -2461,7 +2459,7 @@ bool BW_MidiSequencer::parseCMF(FileAndMemReader &fr)
bool BW_MidiSequencer::parseGMF(FileAndMemReader &fr)
{
- const size_t headerSize = 4 + 4 + 2 + 2 + 2; // 14
+ const size_t headerSize = 14;
char headerBuf[headerSize] = "";
size_t fsize = 0;
size_t deltaTicks = 192, trackCount = 1;
@@ -2532,7 +2530,7 @@ bool BW_MidiSequencer::parseGMF(FileAndMemReader &fr)
bool BW_MidiSequencer::parseSMF(FileAndMemReader &fr)
{
- const size_t headerSize = 4 + 4 + 2 + 2 + 2; // 14
+ const size_t headerSize = 14; // 4 + 4 + 2 + 2 + 2
char headerBuf[headerSize] = "";
size_t fsize = 0;
size_t deltaTicks = 192, TrackCount = 1;
@@ -2640,7 +2638,7 @@ bool BW_MidiSequencer::parseRMI(FileAndMemReader &fr)
#ifndef BWMIDI_DISABLE_MUS_SUPPORT
bool BW_MidiSequencer::parseMUS(FileAndMemReader &fr)
{
- const size_t headerSize = 4 + 4 + 2 + 2 + 2; // 14
+ const size_t headerSize = 14;
char headerBuf[headerSize] = "";
size_t fsize = 0;
BufferGuard<uint8_t> cvt_buf;
@@ -2674,7 +2672,7 @@ bool BW_MidiSequencer::parseMUS(FileAndMemReader &fr)
return false;
}
- //Close source stream
+ // Close source stream
fr.close();
uint8_t *mid = NULL;
@@ -2691,17 +2689,17 @@ bool BW_MidiSequencer::parseMUS(FileAndMemReader &fr)
}
cvt_buf.set(mid);
- //Open converted MIDI file
+ // Open converted MIDI file
fr.openData(mid, static_cast<size_t>(mid_len));
return parseSMF(fr);
}
-#endif //BWMIDI_DISABLE_MUS_SUPPORT
+#endif // BWMIDI_DISABLE_MUS_SUPPORT
#ifndef BWMIDI_DISABLE_XMI_SUPPORT
bool BW_MidiSequencer::parseXMI(FileAndMemReader &fr)
{
- const size_t headerSize = 4 + 4 + 2 + 2 + 2; // 14
+ const size_t headerSize = 14;
char headerBuf[headerSize] = "";
size_t fsize = 0;
BufferGuard<uint8_t> cvt_buf;
@@ -2741,7 +2739,7 @@ bool BW_MidiSequencer::parseXMI(FileAndMemReader &fr)
return false;
}
- //Close source stream
+ // Close source stream
fr.close();
uint8_t *mid = NULL;
@@ -2757,9 +2755,9 @@ bool BW_MidiSequencer::parseXMI(FileAndMemReader &fr)
}
cvt_buf.set(mid);
- //Open converted MIDI file
+ // Open converted MIDI file
fr.openData(mid, static_cast<size_t>(mid_len));
- //Set format as XMIDI
+ // Set format as XMIDI
m_format = Format_XMIDI;
return parseSMF(fr);
diff --git a/src/wopl/wopl_file.c b/src/wopl/wopl_file.c
index 9903e72..b712020 100644
--- a/src/wopl/wopl_file.c
+++ b/src/wopl/wopl_file.c
@@ -1,7 +1,7 @@
/*
* Wohlstand's OPL3 Bank File - a bank format to store OPL3 timbre data and setup
*
- * Copyright (c) 2015-2019 Vitaly Novichkov <admin@wohlnet.ru>
+ * Copyright (c) 2015-2020 Vitaly Novichkov <admin@wohlnet.ru>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
diff --git a/src/wopl/wopl_file.h b/src/wopl/wopl_file.h
index 5333b75..864d333 100644
--- a/src/wopl/wopl_file.h
+++ b/src/wopl/wopl_file.h
@@ -1,7 +1,7 @@
/*
* Wohlstand's OPL3 Bank File - a bank format to store OPL3 timbre data and setup
*
- * Copyright (c) 2015-2019 Vitaly Novichkov <admin@wohlnet.ru>
+ * Copyright (c) 2015-2020 Vitaly Novichkov <admin@wohlnet.ru>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
diff --git a/utils/gen_adldata/ini/ini_processing.cpp b/utils/gen_adldata/ini/ini_processing.cpp
index d43fb47..4336170 100644
--- a/utils/gen_adldata/ini/ini_processing.cpp
+++ b/utils/gen_adldata/ini/ini_processing.cpp
@@ -1,7 +1,7 @@
/*
* INI Processor - a small library which allows you parsing INI-files
*
- * Copyright (c) 2015-2019 Vitaly Novichkov <admin@wohlnet.ru>
+ * Copyright (c) 2015-2020 Vitaly Novichkov <admin@wohlnet.ru>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
diff --git a/utils/gen_adldata/ini/ini_processing.h b/utils/gen_adldata/ini/ini_processing.h
index c51f586..bd15e17 100644
--- a/utils/gen_adldata/ini/ini_processing.h
+++ b/utils/gen_adldata/ini/ini_processing.h
@@ -1,7 +1,7 @@
/*
* INI Processor - a small library which allows you parsing INI-files
*
- * Copyright (c) 2015-2019 Vitaly Novichkov <admin@wohlnet.ru>
+ * Copyright (c) 2015-2020 Vitaly Novichkov <admin@wohlnet.ru>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
diff --git a/utils/gen_adldata/ini/ini_processing_variant.h b/utils/gen_adldata/ini/ini_processing_variant.h
index b89be8b..289ec66 100644
--- a/utils/gen_adldata/ini/ini_processing_variant.h
+++ b/utils/gen_adldata/ini/ini_processing_variant.h
@@ -1,7 +1,7 @@
/*
* INI Processor - a small library which allows you parsing INI-files
*
- * Copyright (c) 2015-2019 Vitaly Novichkov <admin@wohlnet.ru>
+ * Copyright (c) 2015-2020 Vitaly Novichkov <admin@wohlnet.ru>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
diff --git a/utils/midiplay/adlmidiplay.cpp b/utils/midiplay/adlmidiplay.cpp
index bbf1dbf..0cb314e 100644
--- a/utils/midiplay/adlmidiplay.cpp
+++ b/utils/midiplay/adlmidiplay.cpp
@@ -3,7 +3,7 @@
* a Software MIDI synthesizer library with OPL3 emulation
*
* Original ADLMIDI code: Copyright (c) 2010-2014 Joel Yliluoma <bisqwit@iki.fi>
- * ADLMIDI Library API: Copyright (c) 2015-2019 Vitaly Novichkov <admin@wohlnet.ru>
+ * ADLMIDI Library API: Copyright (c) 2015-2020 Vitaly Novichkov <admin@wohlnet.ru>
*
* Library is based on the ADLMIDI, a MIDI player for Linux and Windows with OPL3 emulation:
* http://iki.fi/bisqwit/source/adlmidi.html
diff --git a/utils/midiplay/audio.h b/utils/midiplay/audio.h
index 9e6c2b2..567465a 100644
--- a/utils/midiplay/audio.h
+++ b/utils/midiplay/audio.h
@@ -3,7 +3,7 @@
* a Software MIDI synthesizer library with OPL3 emulation
*
* Original ADLMIDI code: Copyright (c) 2010-2014 Joel Yliluoma <bisqwit@iki.fi>
- * ADLMIDI Library API: Copyright (c) 2015-2019 Vitaly Novichkov <admin@wohlnet.ru>
+ * ADLMIDI Library API: Copyright (c) 2015-2020 Vitaly Novichkov <admin@wohlnet.ru>
*
* Library is based on the ADLMIDI, a MIDI player for Linux and Windows with OPL3 emulation:
* http://iki.fi/bisqwit/source/adlmidi.html
diff --git a/utils/midiplay/audio_sdl.c b/utils/midiplay/audio_sdl.c
index 02a9ee6..bd03d6e 100644
--- a/utils/midiplay/audio_sdl.c
+++ b/utils/midiplay/audio_sdl.c
@@ -3,7 +3,7 @@
* a Software MIDI synthesizer library with OPL3 emulation
*
* Original ADLMIDI code: Copyright (c) 2010-2014 Joel Yliluoma <bisqwit@iki.fi>
- * ADLMIDI Library API: Copyright (c) 2015-2019 Vitaly Novichkov <admin@wohlnet.ru>
+ * ADLMIDI Library API: Copyright (c) 2015-2020 Vitaly Novichkov <admin@wohlnet.ru>
*
* Library is based on the ADLMIDI, a MIDI player for Linux and Windows with OPL3 emulation:
* http://iki.fi/bisqwit/source/adlmidi.html
diff --git a/utils/midiplay/audio_winmm.c b/utils/midiplay/audio_winmm.c
index e0aca93..afe712d 100644
--- a/utils/midiplay/audio_winmm.c
+++ b/utils/midiplay/audio_winmm.c
@@ -3,7 +3,7 @@
* a Software MIDI synthesizer library with OPL3 emulation
*
* Original ADLMIDI code: Copyright (c) 2010-2014 Joel Yliluoma <bisqwit@iki.fi>
- * ADLMIDI Library API: Copyright (c) 2015-2019 Vitaly Novichkov <admin@wohlnet.ru>
+ * ADLMIDI Library API: Copyright (c) 2015-2020 Vitaly Novichkov <admin@wohlnet.ru>
*
* Library is based on the ADLMIDI, a MIDI player for Linux and Windows with OPL3 emulation:
* http://iki.fi/bisqwit/source/adlmidi.html
diff --git a/utils/mus2mid/CMakeLists.txt b/utils/mus2mid/CMakeLists.txt
new file mode 100644
index 0000000..6430dd4
--- /dev/null
+++ b/utils/mus2mid/CMakeLists.txt
@@ -0,0 +1,7 @@
+add_executable(mus2mid mus2mid.cpp)
+# TODO: Use own library
+target_include_directories(mus2mid PRIVATE ${PROJECT_SOURCE_DIR}/src)
+
+install(TARGETS mus2mid
+ RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
+
diff --git a/utils/mus2mid/mus2mid.cpp b/utils/mus2mid/mus2mid.cpp
new file mode 100644
index 0000000..f737f8c
--- /dev/null
+++ b/utils/mus2mid/mus2mid.cpp
@@ -0,0 +1,74 @@
+
+#include "cvt_mus2mid.hpp"
+#include <stdio.h>
+#include <sys/stat.h>
+#if !defined(_WIN32)
+#include <unistd.h>
+#else
+#include <io.h>
+#define fileno(fd) _fileno(fd)
+#define isatty(fd) _isatty(fd)
+#endif
+
+int main(int argc, char *argv[])
+{
+ if(argc != 2)
+ {
+ fprintf(stderr, "Usage: mus2mid <midi-file>\n");
+ return 1;
+ }
+
+ const char *filename = argv[1];
+
+ FILE *fh = fopen(filename, "rb");
+ if(!fh)
+ {
+ fprintf(stderr, "Error opening file.\n");
+ return 1;
+ }
+
+ struct stat st;
+ if(fstat(fileno(fh), &st) != 0)
+ {
+ fprintf(stderr, "Error reading file status.\n");
+ return 1;
+ }
+
+ size_t insize = (size_t)st.st_size;
+ if(insize > 8 * 1024 * 1024)
+ {
+ fprintf(stderr, "File too large.\n");
+ return 1;
+ }
+
+ uint8_t *filedata = new uint8_t[insize];
+ if(fread(filedata, 1, insize, fh) != insize)
+ {
+ fprintf(stderr, "Error reading file data.\n");
+ return 1;
+ }
+
+ uint8_t *xmidata = NULL;
+ uint32_t xmisize = 0;
+ if(Convert_mus2midi(filedata, static_cast<uint32_t>(insize), &xmidata, &xmisize, 0) < 0)
+ {
+ fprintf(stderr, "Error converting MUS to SMF.\n");
+ return 1;
+ }
+
+ FILE *out = stdout;
+ if(isatty(fileno(out)))
+ {
+ fprintf(stderr, "Not writing SMF data on the text terminal.\n");
+ }
+ else
+ {
+ if (fwrite(xmidata, 1, xmisize, out) != xmisize || fflush(out) != 0)
+ {
+ fprintf(stderr, "Error writing SMF data.\n");
+ return 1;
+ }
+ }
+
+ return 0;
+}
diff --git a/utils/update-copyright.sh b/utils/update-copyright.sh
new file mode 100755
index 0000000..6ff0dee
--- /dev/null
+++ b/utils/update-copyright.sh
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+find . -type f -exec grep -Il "Copyright" {} \; \
+| grep -v \.git \
+| while read file; \
+do \
+ LC_ALL=C sed -b -i "s/\(.*Copyright.*\)[0-9]\{4\}\( *Vitaly Novichkov\)/\1`date +%Y`\2/" "$file"; \
+done
diff --git a/utils/vlc_codec/libadlmidi.c b/utils/vlc_codec/libadlmidi.c
index 77341b0..3d5e5fe 100644
--- a/utils/vlc_codec/libadlmidi.c
+++ b/utils/vlc_codec/libadlmidi.c
@@ -1,7 +1,7 @@
/*****************************************************************************
* libadlmidi.c: Software MIDI synthesizer using OPL3 Synth emulation
*****************************************************************************
- * Copyright © 2015-2018 Vitaly Novichkov
+ * Copyright © 2015-2020 Vitaly Novichkov
* $Id$
*
* This program is free software: you can redistribute it and/or modify