diff options
-rw-r--r-- | CMakeLists.txt | 4 | ||||
-rw-r--r-- | src/midi_sequencer.h | 79 | ||||
-rw-r--r-- | src/midi_sequencer_impl.hpp | 4 |
3 files changed, 46 insertions, 41 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 090a6c6..74600b8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -63,8 +63,8 @@ if(NOT MSVC AND NOT MSDOS) endif() # Supress the std::vector::insert() GCC change warning if(VITA) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fcompare-debug-second") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcompare-debug-second") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DVITA -DVITA=1 -fcompare-debug-second") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DVITA -DVITA=1 -fcompare-debug-second") endif() endif() diff --git a/src/midi_sequencer.h b/src/midi_sequencer.h index 1f75586..8ed96cd 100644 --- a/src/midi_sequencer.h +++ b/src/midi_sequencer.h @@ -33,20 +33,56 @@ extern "C" { #include <stddef.h> #include <stdint.h> +/*! Raw MIDI event hook */ +typedef void (*RawEventHook)(void *userdata, uint8_t type, uint8_t subtype, uint8_t channel, const uint8_t *data, size_t len); +/*! PCM render */ +typedef void (*PcmRender)(void *userdata, uint8_t *stream, size_t length); +/*! Library internal debug messages */ +typedef void (*DebugMessageHook)(void *userdata, const char *fmt, ...); +/*! Loop Start event hook */ +typedef void (*LoopStartHook)(void *userdata); +/*! Loop Start event hook */ +typedef void (*LoopEndHook)(void *userdata); +typedef void (*SongStartHook)(void *userdata); + + +/*! Note-On MIDI event */ +typedef void (*RtNoteOn)(void *userdata, uint8_t channel, uint8_t note, uint8_t velocity); +/*! Note-Off MIDI event */ +typedef void (*RtNoteOff)(void *userdata, uint8_t channel, uint8_t note); +/*! Note-Off MIDI event with a velocity */ +typedef void (*RtNoteOffVel)(void *userdata, uint8_t channel, uint8_t note, uint8_t velocity); +/*! Note aftertouch MIDI event */ +typedef void (*RtNoteAfterTouch)(void *userdata, uint8_t channel, uint8_t note, uint8_t atVal); +/*! Channel aftertouch MIDI event */ +typedef void (*RtChannelAfterTouch)(void *userdata, uint8_t channel, uint8_t atVal); +/*! Controller change MIDI event */ +typedef void (*RtControllerChange)(void *userdata, uint8_t channel, uint8_t type, uint8_t value); +/*! Patch change MIDI event */ +typedef void (*RtPatchChange)(void *userdata, uint8_t channel, uint8_t patch); +/*! Pitch bend MIDI event */ +typedef void (*RtPitchBend)(void *userdata, uint8_t channel, uint8_t msb, uint8_t lsb); +/*! System Exclusive MIDI event */ +typedef void (*RtSysEx)(void *userdata, const uint8_t *msg, size_t size); +/*! Meta event hook */ +typedef void (*MetaEventHook)(void *userdata, uint8_t type, const uint8_t *data, size_t len); +/*! Device Switch MIDI event */ +typedef void (*RtDeviceSwitch)(void *userdata, size_t track, const char *data, size_t length); +/*! Get the channels offset for current MIDI device */ +typedef size_t (*RtCurrentDevice)(void *userdata, size_t track); +/*! [Non-Standard] Pass raw OPL3 data to the chip (when playing IMF files) */ +typedef void (*RtRawOPL)(void *userdata, uint8_t reg, uint8_t value); + /** \brief Real-Time MIDI interface between Sequencer and the Synthesizer */ typedef struct BW_MidiRtInterface { - /*! Raw MIDI event hook */ - typedef void (*RawEventHook)(void *userdata, uint8_t type, uint8_t subtype, uint8_t channel, const uint8_t *data, size_t len); /*! MIDI event hook which catches all MIDI events */ RawEventHook onEvent; /*! User data which will be passed through On-Event hook */ void *onEvent_userData; - /*! PCM render */ - typedef void (*PcmRender)(void *userdata, uint8_t *stream, size_t length); /*! PCM render hook which catches passing of loop start point */ PcmRender onPcmRender; /*! User data which will be passed through On-PCM-render hook */ @@ -58,28 +94,21 @@ typedef struct BW_MidiRtInterface /*! Size of one sample in bytes */ uint32_t pcmFrameSize; - /*! Library internal debug messages */ - typedef void (*DebugMessageHook)(void *userdata, const char *fmt, ...); /*! Debug message hook */ DebugMessageHook onDebugMessage; /*! User data which will be passed through Debug Message hook */ void *onDebugMessage_userData; - /*! Loop Start event hook */ - typedef void (*LoopStartHook)(void *userdata); /*! Loop start hook which catches passing of loop start point */ LoopStartHook onloopStart; /*! User data which will be passed through On-LoopStart hook */ void *onloopStart_userData; - /*! Loop Start event hook */ - typedef void (*LoopEndHook)(void *userdata); /*! Loop start hook which catches passing of loop start point */ LoopEndHook onloopEnd; /*! User data which will be passed through On-LoopStart hook */ void *onloopEnd_userData; - typedef void (*SongStartHook)(void *userdata); /*! Song start hook which is calling when starting playing song at begin */ SongStartHook onSongStart; /*! User data which will be passed through On-SongStart hook */ @@ -93,48 +122,29 @@ typedef struct BW_MidiRtInterface * Standard MIDI events. All of them are required! * ***************************************************/ - /*! Note-On MIDI event */ - typedef void (*RtNoteOn)(void *userdata, uint8_t channel, uint8_t note, uint8_t velocity); /*! Note-On MIDI event hook */ RtNoteOn rt_noteOn; - - /*! Note-Off MIDI event */ - typedef void (*RtNoteOff)(void *userdata, uint8_t channel, uint8_t note); /*! 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 */ RtNoteAfterTouch rt_noteAfterTouch; - /*! Channel aftertouch MIDI event */ - typedef void (*RtChannelAfterTouch)(void *userdata, uint8_t channel, uint8_t atVal); /*! Channel aftertouch MIDI event hook */ RtChannelAfterTouch rt_channelAfterTouch; - /*! Controller change MIDI event */ - typedef void (*RtControllerChange)(void *userdata, uint8_t channel, uint8_t type, uint8_t value); /*! Controller change MIDI event hook */ RtControllerChange rt_controllerChange; - /*! Patch change MIDI event */ - typedef void (*RtPatchChange)(void *userdata, uint8_t channel, uint8_t patch); /*! Patch change MIDI event hook */ RtPatchChange rt_patchChange; - /*! Pitch bend MIDI event */ - typedef void (*RtPitchBend)(void *userdata, uint8_t channel, uint8_t msb, uint8_t lsb); /*! Pitch bend MIDI event hook */ RtPitchBend rt_pitchBend; - /*! System Exclusive MIDI event */ - typedef void (*RtSysEx)(void *userdata, const uint8_t *msg, size_t size); /*! System Exclusive MIDI event hook */ RtSysEx rt_systemExclusive; @@ -143,18 +153,12 @@ 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 */ RtDeviceSwitch rt_deviceSwitch; - /*! Get the channels offset for current MIDI device */ - typedef size_t (*RtCurrentDevice)(void *userdata, size_t track); /*! Get the channels offset for current MIDI device hook. Returms multiple to 16 value. */ RtCurrentDevice rt_currentDevice; @@ -162,9 +166,6 @@ typedef struct BW_MidiRtInterface /****************************************** * NonStandard events. There are optional * ******************************************/ - - /*! [Non-Standard] Pass raw OPL3 data to the chip (when playing IMF files) */ - typedef void (*RtRawOPL)(void *userdata, uint8_t reg, uint8_t value); /*! [Non-Standard] Pass raw OPL3 data to the chip hook */ RtRawOPL rt_rawOPL; diff --git a/src/midi_sequencer_impl.hpp b/src/midi_sequencer_impl.hpp index 901821d..f13768f 100644 --- a/src/midi_sequencer_impl.hpp +++ b/src/midi_sequencer_impl.hpp @@ -32,6 +32,10 @@ #include <set> #include <assert.h> +#if defined(VITA) +#include <psp2kern/kernel/sysclib.h> // snprintf +#endif + #if defined(_WIN32) && !defined(__WATCOMC__) # ifdef _MSC_VER # ifdef _WIN64 |