--- linuxsampler/trunk/src/engines/common/Event.h 2006/07/23 16:44:08 906 +++ linuxsampler/trunk/src/engines/common/Event.h 2014/06/09 19:20:37 2611 @@ -3,7 +3,7 @@ * LinuxSampler - modular, streaming capable sampler * * * * Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck * - * Copyright (C) 2005, 2006 Christian Schoenebeck * + * Copyright (C) 2005 - 2014 Christian Schoenebeck * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * @@ -64,7 +64,7 @@ * controller like LFO or EG. An event should only be created by an * EventGenerator! * - * @see EventGenerator + * @see EventGenerator, ScriptEvent */ class Event { public: @@ -76,31 +76,58 @@ type_control_change, type_sysex, ///< MIDI system exclusive message type_cancel_release, ///< transformed either from a note-on or sustain-pedal-down event - type_release ///< transformed either from a note-off or sustain-pedal-up event + type_release, ///< transformed either from a note-off or sustain-pedal-up event + type_channel_pressure, ///< a.k.a. aftertouch + type_note_pressure, ///< polyphonic key pressure (aftertouch) } Type; union { /// Note-on and note-off event specifics struct _Note { + uint8_t Channel; ///< MIDI channel (0..15) uint8_t Key; ///< MIDI key number of note-on / note-off event. uint8_t Velocity; ///< Trigger or release velocity of note-on / note-off event. int8_t Layer; ///< Layer index (usually only used if a note-on event has to be postponed, e.g. due to shortage of free voices). int8_t ReleaseTrigger; ///< If new voice should be a release triggered voice (actually boolean field and usually only used if a note-on event has to be postponed, e.g. due to shortage of free voices). + void* pRegion; ///< Engine specific pointer to instrument region } Note; /// Control change event specifics struct _CC { + uint8_t Channel; ///< MIDI channel (0..15) uint8_t Controller; ///< MIDI controller number of control change event. uint8_t Value; ///< Controller Value of control change event. } CC; /// Pitchbend event specifics struct _Pitch { + uint8_t Channel; ///< MIDI channel (0..15) int16_t Pitch; ///< Pitch value of pitchbend event. } Pitch; /// MIDI system exclusive event specifics struct _Sysex { uint Size; ///< Data length (in bytes) of MIDI system exclusive message. } Sysex; + /// Channel Pressure (aftertouch) event specifics + struct _ChannelPressure { + uint8_t Channel; ///< MIDI channel (0..15) + uint8_t Controller; ///< Should always be assigned to CTRL_TABLE_IDX_AFTERTOUCH. + uint8_t Value; ///< New aftertouch / pressure value for keys on that channel. + } ChannelPressure; + /// Polyphonic Note Pressure (aftertouch) event specifics + struct _NotePressure { + uint8_t Channel; ///< MIDI channel (0..15) + uint8_t Key; ///< MIDI note number where key pressure (polyphonic aftertouch) changed. + uint8_t Value; ///< New pressure value for note. + } NotePressure; } Param; + /// Sampler format specific informations and variables. + union { + /// Gigasampler/GigaStudio format specifics. + struct _Gig { + uint8_t DimMask; ///< May be used to override the Dimension zone to be selected for a new voice: each 1 bit means that respective bit shall be overridden by taking the respective bit from DimBits instead. + uint8_t DimBits; ///< Used only in conjunction with DimMask: Dimension bits that shall be selected. + } Gig; + } Format; EngineChannel* pEngineChannel; ///< Pointer to the EngineChannel where this event occured on, NULL means Engine global event (e.g. SysEx message). + MidiInputPort* pMidiInputPort; ///< Pointer to the MIDI input port on which this event occured (NOTE: currently only for global events, that is SysEx messages) inline int32_t FragmentPos() { if (iFragmentPos >= 0) return iFragmentPos; @@ -122,6 +149,24 @@ int32_t iFragmentPos; ///< Position in the current fragment this event refers to. }; + class VMEventHandler; + class VMExecContext; + + /** @brief Real-time instrument script event. + * + * Encapsulates one execution instance of a real-time instrument script for + * exactly one script event handler (script event callback). + */ + class ScriptEvent { + public: + Event cause; ///< Original external event that triggered this script event (i.e. MIDI note on event, MIDI CC event, etc.). + int id; ///< Unique ID of the external event that triggered this cript event. + VMEventHandler** handlers; ///< The script's event handlers (callbacks) to be processed (NULL terminated list). + VMExecContext* execCtx; ///< Script's current execution state (polyphonic variables and execution stack). + int currentHandler; ///< Current index in 'handlers' list above. + int executionSlices; ///< Amount of times this script event has been executed by the ScriptVM runner class. + }; + } // namespace LinuxSampler #endif // __LS_EVENT_H__