/[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 246 by schoenebeck, Sun Sep 19 14:12:55 2004 UTC revision 890 by schoenebeck, Sat Jul 1 13:43:04 2006 UTC
# Line 3  Line 3 
3   *   LinuxSampler - modular, streaming capable sampler                     *   *   LinuxSampler - modular, streaming capable sampler                     *
4   *                                                                         *   *                                                                         *
5   *   Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck   *   *   Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck   *
6     *   Copyright (C) 2005, 2006 Christian Schoenebeck                        *
7   *                                                                         *   *                                                                         *
8   *   This program is free software; you can redistribute it and/or modify  *   *   This program is free software; you can redistribute it and/or modify  *
9   *   it under the terms of the GNU General Public License as published by  *   *   it under the terms of the GNU General Public License as published by  *
# Line 24  Line 25 
25  #define __LS_EVENT_H__  #define __LS_EVENT_H__
26    
27  #include "../../common/global.h"  #include "../../common/global.h"
28    #include "../../common/RTMath.h"
29    #include "../EngineChannel.h"
30    
31  namespace LinuxSampler {  namespace LinuxSampler {
32    
# Line 40  namespace LinuxSampler { Line 43  namespace LinuxSampler {
43              void UpdateFragmentTime(uint SamplesToProcess);              void UpdateFragmentTime(uint SamplesToProcess);
44              Event CreateEvent();              Event CreateEvent();
45          protected:          protected:
46              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;
47              inline uint ToFragmentPos(time_stamp_t TimeStamp) {              inline int32_t ToFragmentPos(time_stamp_t TimeStamp) {
48                  return uint ((TimeStamp - FragmentTime.begin) * FragmentTime.sample_ratio);                  return int32_t (int32_t(TimeStamp - FragmentTime.begin) * FragmentTime.sample_ratio);
49              }              }
50              friend class Event;              friend class Event;
51          private:          private:
# Line 53  namespace LinuxSampler { Line 56  namespace LinuxSampler {
56                  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.
57                  float        sample_ratio; ///< (Samples per cycle) / (Real time duration of cycle)                  float        sample_ratio; ///< (Samples per cycle) / (Real time duration of cycle)
58              } FragmentTime;              } FragmentTime;
             time_stamp_t CreateTimeStamp();  
59      };      };
60    
61      /**      /**
# Line 75  namespace LinuxSampler { Line 77  namespace LinuxSampler {
77                  type_cancel_release,  ///< transformed either from a note-on or sustain-pedal-down event                  type_cancel_release,  ///< transformed either from a note-on or sustain-pedal-down event
78                  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
79              } Type;              } Type;
             enum destination_t {  
                 destination_vca,   ///< Volume level  
                 destination_vco,   ///< Pitch depth  
                 destination_vcfc,  ///< Filter curoff frequency  
                 destination_vcfr,  ///< Filter resonance  
                 destination_count  ///< Total number of modulation destinations (this has to stay the last element in the enum)  
             };  
80              union {              union {
81                  /// Note-on and note-off event specifics                  /// Note-on and note-off event specifics
82                  struct _Note {                  struct _Note {
83                      uint8_t Key;         ///< MIDI key number of note-on / note-off event.                      uint8_t Key;         ///< MIDI key number of note-on / note-off event.
84                      uint8_t Velocity;    ///< Trigger or release velocity of note-on / note-off event.                      uint8_t Velocity;    ///< Trigger or release velocity of note-on / note-off event.
85                        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).
86                        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).
87                  } Note;                  } Note;
88                  /// Control change event specifics                  /// Control change event specifics
89                  struct _CC {                  struct _CC {
# Line 102  namespace LinuxSampler { Line 99  namespace LinuxSampler {
99                      uint Size;           ///< Data length (in bytes) of MIDI system exclusive message.                      uint Size;           ///< Data length (in bytes) of MIDI system exclusive message.
100                  } Sysex;                  } Sysex;
101              } Param;              } Param;
102                EngineChannel* pEngineChannel; ///< Pointer to the EngineChannel where this event occured on, NULL means Engine global event (e.g. SysEx message).
103    
104              inline uint FragmentPos() {              inline int32_t FragmentPos() {
105                  if (iFragmentPos >= 0) return (uint) iFragmentPos;                  if (iFragmentPos >= 0) return iFragmentPos;
106                  return (uint) (iFragmentPos = pEventGenerator->ToFragmentPos(TimeStamp));                  iFragmentPos = pEventGenerator->ToFragmentPos(TimeStamp);
107                    if (iFragmentPos < 0) iFragmentPos = 0; // if event arrived shortly before the beginning of current fragment
108                    return iFragmentPos;
109                }
110                inline void ResetFragmentPos() {
111                    iFragmentPos = -1;
112              }              }
113          protected:          protected:
114              typedef EventGenerator::time_stamp_t time_stamp_t;              typedef EventGenerator::time_stamp_t time_stamp_t;
# Line 114  namespace LinuxSampler { Line 117  namespace LinuxSampler {
117          private:          private:
118              EventGenerator* pEventGenerator; ///< Creator of the event.              EventGenerator* pEventGenerator; ///< Creator of the event.
119              time_stamp_t    TimeStamp;       ///< Time stamp of the event's occurence.              time_stamp_t    TimeStamp;       ///< Time stamp of the event's occurence.
120              int             iFragmentPos;    ///< Position in the current fragment this event refers to.              int32_t         iFragmentPos;    ///< Position in the current fragment this event refers to.
121      };      };
122    
123  } // namespace LinuxSampler  } // namespace LinuxSampler

Legend:
Removed from v.246  
changed lines
  Added in v.890

  ViewVC Help
Powered by ViewVC