/[svn]/linuxsampler/trunk/src/engines/common/Event.h
ViewVC logotype

Diff of /linuxsampler/trunk/src/engines/common/Event.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 244 by schoenebeck, Fri Sep 17 01:01:11 2004 UTC revision 412 by schoenebeck, Sat Feb 26 22:44:51 2005 UTC
# Line 24  Line 24 
24  #define __LS_EVENT_H__  #define __LS_EVENT_H__
25    
26  #include "../../common/global.h"  #include "../../common/global.h"
27    #include "../../common/RTMath.h"
28    #include "EngineChannel.h"
29    
30  namespace LinuxSampler {  namespace LinuxSampler {
31    
# Line 40  namespace LinuxSampler { Line 42  namespace LinuxSampler {
42              void UpdateFragmentTime(uint SamplesToProcess);              void UpdateFragmentTime(uint SamplesToProcess);
43              Event CreateEvent();              Event CreateEvent();
44          protected:          protected:
45              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.              typedef RTMath::time_stamp_t time_stamp_t;
46              inline uint ToFragmentPos(time_stamp_t TimeStamp) {              inline int32_t ToFragmentPos(time_stamp_t TimeStamp) {
47                  return uint ((TimeStamp - FragmentTime.begin) * FragmentTime.sample_ratio);                  return int32_t (int32_t(TimeStamp - FragmentTime.begin) * FragmentTime.sample_ratio);
48              }              }
49              friend class Event;              friend class Event;
50          private:          private:
# Line 53  namespace LinuxSampler { Line 55  namespace LinuxSampler {
55                  time_stamp_t end;          ///< Real time stamp of the end of this audio fragment cycle.                  time_stamp_t end;          ///< Real time stamp of the end of this audio fragment cycle.
56                  float        sample_ratio; ///< (Samples per cycle) / (Real time duration of cycle)                  float        sample_ratio; ///< (Samples per cycle) / (Real time duration of cycle)
57              } FragmentTime;              } FragmentTime;
             time_stamp_t CreateTimeStamp();  
58      };      };
59    
60      /**      /**
# Line 83  namespace LinuxSampler { Line 84  namespace LinuxSampler {
84                  destination_count  ///< Total number of modulation destinations (this has to stay the last element in the enum)                  destination_count  ///< Total number of modulation destinations (this has to stay the last element in the enum)
85              };              };
86              union {              union {
87                  uint8_t Key;          ///< MIDI key number for note-on and note-off events.                  /// Note-on and note-off event specifics
88                  uint8_t Controller;   ///< MIDI controller number for control change events.                  struct _Note {
89              };                      uint8_t Key;         ///< MIDI key number of note-on / note-off event.
90              union {                      uint8_t Velocity;    ///< Trigger or release velocity of note-on / note-off event.
91                  uint8_t Velocity;     ///< Trigger or release velocity for note-on or note-off events.                      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).
92                  uint8_t Value;        ///< Value for control change events.                      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).
93              };                  } Note;
94              union {                  /// Control change event specifics
95                  int16_t Pitch;        ///< Pitch value for pitchbend events.                  struct _CC {
96                  uint    Size;         ///< Data length (in bytes) for MIDI system exclusive messages.                      uint8_t Controller;  ///< MIDI controller number of control change event.
97              };                      uint8_t Value;       ///< Controller Value of control change event.
98                    } CC;
99              inline uint FragmentPos() {                  /// Pitchbend event specifics
100                  if (iFragmentPos >= 0) return (uint) iFragmentPos;                  struct _Pitch {
101                  return (uint) (iFragmentPos = pEventGenerator->ToFragmentPos(TimeStamp));                      int16_t Pitch;       ///< Pitch value of pitchbend event.
102                    } Pitch;
103                    /// MIDI system exclusive event specifics
104                    struct _Sysex {
105                        uint Size;           ///< Data length (in bytes) of MIDI system exclusive message.
106                    } Sysex;
107                } Param;
108                EngineChannel* pEngineChannel; ///< Pointer to the EngineChannel where this event occured on, NULL means Engine global event (e.g. SysEx message).
109    
110                inline int32_t FragmentPos() {
111                    if (iFragmentPos >= 0) return iFragmentPos;
112                    iFragmentPos = pEventGenerator->ToFragmentPos(TimeStamp);
113                    if (iFragmentPos < 0) iFragmentPos = 0; // if event arrived shortly before the beginning of current fragment
114                    return iFragmentPos;
115                }
116                inline void ResetFragmentPos() {
117                    iFragmentPos = -1;
118              }              }
119          protected:          protected:
120              typedef EventGenerator::time_stamp_t time_stamp_t;              typedef EventGenerator::time_stamp_t time_stamp_t;
# Line 106  namespace LinuxSampler { Line 123  namespace LinuxSampler {
123          private:          private:
124              EventGenerator* pEventGenerator; ///< Creator of the event.              EventGenerator* pEventGenerator; ///< Creator of the event.
125              time_stamp_t    TimeStamp;       ///< Time stamp of the event's occurence.              time_stamp_t    TimeStamp;       ///< Time stamp of the event's occurence.
126              int             iFragmentPos;    ///< Position in the current fragment this event refers to.              int32_t         iFragmentPos;    ///< Position in the current fragment this event refers to.
127      };      };
128    
129  } // namespace LinuxSampler  } // namespace LinuxSampler

Legend:
Removed from v.244  
changed lines
  Added in v.412

  ViewVC Help
Powered by ViewVC