--- linuxsampler/trunk/src/engines/common/Event.h 2004/09/19 14:12:55 246 +++ linuxsampler/trunk/src/engines/common/Event.h 2005/02/26 22:44:51 412 @@ -24,6 +24,8 @@ #define __LS_EVENT_H__ #include "../../common/global.h" +#include "../../common/RTMath.h" +#include "EngineChannel.h" namespace LinuxSampler { @@ -40,9 +42,9 @@ void UpdateFragmentTime(uint SamplesToProcess); Event CreateEvent(); protected: - typedef uint32_t time_stamp_t; ///< We read the processor's cycle count register as a reference for the real time. These are of course only abstract values with arbitrary time entity, but that's not a problem as we calculate relatively. - inline uint ToFragmentPos(time_stamp_t TimeStamp) { - return uint ((TimeStamp - FragmentTime.begin) * FragmentTime.sample_ratio); + typedef RTMath::time_stamp_t time_stamp_t; + inline int32_t ToFragmentPos(time_stamp_t TimeStamp) { + return int32_t (int32_t(TimeStamp - FragmentTime.begin) * FragmentTime.sample_ratio); } friend class Event; private: @@ -53,7 +55,6 @@ time_stamp_t end; ///< Real time stamp of the end of this audio fragment cycle. float sample_ratio; ///< (Samples per cycle) / (Real time duration of cycle) } FragmentTime; - time_stamp_t CreateTimeStamp(); }; /** @@ -87,6 +88,8 @@ struct _Note { 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). } Note; /// Control change event specifics struct _CC { @@ -102,10 +105,16 @@ uint Size; ///< Data length (in bytes) of MIDI system exclusive message. } Sysex; } Param; + EngineChannel* pEngineChannel; ///< Pointer to the EngineChannel where this event occured on, NULL means Engine global event (e.g. SysEx message). - inline uint FragmentPos() { - if (iFragmentPos >= 0) return (uint) iFragmentPos; - return (uint) (iFragmentPos = pEventGenerator->ToFragmentPos(TimeStamp)); + inline int32_t FragmentPos() { + if (iFragmentPos >= 0) return iFragmentPos; + iFragmentPos = pEventGenerator->ToFragmentPos(TimeStamp); + if (iFragmentPos < 0) iFragmentPos = 0; // if event arrived shortly before the beginning of current fragment + return iFragmentPos; + } + inline void ResetFragmentPos() { + iFragmentPos = -1; } protected: typedef EventGenerator::time_stamp_t time_stamp_t; @@ -114,7 +123,7 @@ private: EventGenerator* pEventGenerator; ///< Creator of the event. time_stamp_t TimeStamp; ///< Time stamp of the event's occurence. - int iFragmentPos; ///< Position in the current fragment this event refers to. + int32_t iFragmentPos; ///< Position in the current fragment this event refers to. }; } // namespace LinuxSampler