From 9f0f9e4e374798851da39335406ac4bafad81297 Mon Sep 17 00:00:00 2001 From: Vitaly Novichkov Date: Thu, 21 Jun 2018 04:23:14 +0300 Subject: Move MIDI sequencer into completely separated class TODO: - implement C bindings for most of class functions - test it in work on any different synthesizer --- src/midi_sequencer.h | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 src/midi_sequencer.h (limited to 'src/midi_sequencer.h') diff --git a/src/midi_sequencer.h b/src/midi_sequencer.h new file mode 100644 index 0000000..d3b542e --- /dev/null +++ b/src/midi_sequencer.h @@ -0,0 +1,91 @@ +/* + * BW_Midi_Sequencer - MIDI Sequencer for C++ + * + * Copyright (c) 2015-2018 Vitaly Novichkov + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#pragma once +#ifndef BISQUIT_AND_WOHLSTANDS_MIDI_SEQUENCER_HHHH +#define BISQUIT_AND_WOHLSTANDS_MIDI_SEQUENCER_HHHH + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +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); + RawEventHook onEvent; + void *onEvent_userData; + + //! Library internal debug messages + typedef void (*DebugMessageHook)(void *userdata, const char *fmt, ...); + DebugMessageHook onDebugMessage; + void *onDebugMessage_userData; + + void *rtUserData; + + /* Standard MIDI events. All of them are required! */ + typedef void (*RtNoteOn)(void *userdata, uint8_t channel, uint8_t note, uint8_t velocity); + RtNoteOn rt_noteOn; + + typedef void (*RtNoteOff)(void *userdata, uint8_t channel, uint8_t note); + RtNoteOff rt_noteOff; + + typedef void (*RtNoteAfterTouch)(void *userdata, uint8_t channel, uint8_t note, uint8_t atVal); + RtNoteAfterTouch rt_noteAfterTouch; + + typedef void (*RtChannelAfterTouch)(void *userdata, uint8_t channel, uint8_t atVal); + RtChannelAfterTouch rt_channelAfterTouch; + + typedef void (*RtControlerChange)(void *userdata, uint8_t channel, uint8_t type, uint8_t value); + RtControlerChange rt_controllerChange; + + typedef void (*RtPatchChange)(void *userdata, uint8_t channel, uint8_t patch); + RtPatchChange rt_patchChange; + + typedef void (*RtPitchBend)(void *userdata, uint8_t channel, uint8_t msb, uint8_t lsb); + RtPitchBend rt_pitchBend; + + typedef void (*RtSysEx)(void *userdata, const uint8_t *msg, size_t size); + RtSysEx rt_systemExclusive; + + + /* NonStandard events. There are optional */ + typedef void (*RtRawOPL)(void *userdata, uint8_t reg, uint8_t value); + RtRawOPL rt_rawOPL; + + typedef void (*RtDeviceSwitch)(void *userdata, size_t track, const char *data, size_t length); + RtDeviceSwitch rt_deviceSwitch; + + typedef uint64_t (*RtCurrentDevice)(void *userdata, size_t track); + RtCurrentDevice rt_currentDevice; +}; + +#ifdef __cplusplus +} +#endif + +#endif /* BISQUIT_AND_WOHLSTANDS_MIDI_SEQUENCER_HHHH */ -- cgit v1.2.3 From 51ffa56a7f30679ecb40d76725a94b9c954546a1 Mon Sep 17 00:00:00 2001 From: Vitaly Novichkov Date: Thu, 21 Jun 2018 04:41:54 +0300 Subject: Attempt to fix a Windows build --- src/midi_sequencer.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/midi_sequencer.h') diff --git a/src/midi_sequencer.h b/src/midi_sequencer.h index d3b542e..2a2b543 100644 --- a/src/midi_sequencer.h +++ b/src/midi_sequencer.h @@ -33,7 +33,7 @@ extern "C" { #include #include -struct BW_MidiRtInterface +typedef struct { //! 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); @@ -82,7 +82,7 @@ struct BW_MidiRtInterface typedef uint64_t (*RtCurrentDevice)(void *userdata, size_t track); RtCurrentDevice rt_currentDevice; -}; +} BW_MidiRtInterface; #ifdef __cplusplus } -- cgit v1.2.3 From 12f0c3565a0d7b59629dbb2800df5e887ff6fde3 Mon Sep 17 00:00:00 2001 From: Vitaly Novichkov Date: Sat, 23 Jun 2018 01:45:02 +0300 Subject: Added little documentation for the sequencer event hooks --- src/midi_sequencer.h | 55 ++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 49 insertions(+), 6 deletions(-) (limited to 'src/midi_sequencer.h') diff --git a/src/midi_sequencer.h b/src/midi_sequencer.h index 2a2b543..afbffed 100644 --- a/src/midi_sequencer.h +++ b/src/midi_sequencer.h @@ -33,55 +33,98 @@ extern "C" { #include #include +/** + \brief Real-Time MIDI interface between Sequencer and the Synthesizer + */ typedef struct { - //! Raw MIDI event hook + /*! 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; - //! Library internal debug messages + /*! 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; + /*! MIDI Run Time event calls user data */ void *rtUserData; - /* Standard MIDI events. All of them are required! */ + + /*************************************************** + * 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 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 (*RtControlerChange)(void *userdata, uint8_t channel, uint8_t type, uint8_t value); + /*! Controller change MIDI event hook */ RtControlerChange 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; - /* NonStandard events. There are optional */ - typedef void (*RtRawOPL)(void *userdata, uint8_t reg, uint8_t value); - RtRawOPL rt_rawOPL; + /******************* + * Optional events * + *******************/ + /*! 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 uint64_t (*RtCurrentDevice)(void *userdata, size_t track); + /*! Get the channels offset for current MIDI device hook. Returms multiple to 16 value. */ RtCurrentDevice rt_currentDevice; + + + /****************************************** + * 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; + } BW_MidiRtInterface; #ifdef __cplusplus -- cgit v1.2.3