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

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

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

revision 2938 by schoenebeck, Mon Jul 11 17:10:40 2016 UTC revision 3316 by schoenebeck, Thu Jul 20 12:05:53 2017 UTC
# Line 1  Line 1 
1  /*  /*
2   * Copyright (c) 2016 Christian Schoenebeck   * Copyright (c) 2016 - 2017 Christian Schoenebeck
3   *   *
4   * http://www.linuxsampler.org   * http://www.linuxsampler.org
5   *   *
# Line 12  Line 12 
12    
13  #include "../../common/Pool.h"  #include "../../common/Pool.h"
14  #include "Event.h"  #include "Event.h"
15    #include "Fade.h"
16    
17    #define DEFAULT_NOTE_VOLUME_TIME_S  0.013f /* 13ms */
18    #define DEFAULT_NOTE_PITCH_TIME_S   0.013f /* 13ms */
19    
20  namespace LinuxSampler {  namespace LinuxSampler {
21    
# Line 28  namespace LinuxSampler { Line 32  namespace LinuxSampler {
32          RTList<note_id_t>* pChildNotes; ///< Note ID list of "child" notes of this note. These are special notes that must be released once this note gets released.          RTList<note_id_t>* pChildNotes; ///< Note ID list of "child" notes of this note. These are special notes that must be released once this note gets released.
33          Event cause; ///< Copy of the original event (usually a note-on event) which caused this note.          Event cause; ///< Copy of the original event (usually a note-on event) which caused this note.
34          event_id_t eventID; ///< Unique ID of the actual original @c Event which caused this note.          event_id_t eventID; ///< Unique ID of the actual original @c Event which caused this note.
35            sched_time_t triggerSchedTime; ///< Engine's scheduler time when this note was launched.
36          /// Optional synthesis parameters that might be overridden (by calling real-time instrument script functions like change_vol(), change_pitch(), etc.).          /// Optional synthesis parameters that might be overridden (by calling real-time instrument script functions like change_vol(), change_pitch(), etc.).
37          struct  _Override {          struct  _Override {
38              float Volume;       ///< as linear amplification ratio (1.0 being neutral)              float Volume;       ///< as linear amplification ratio (1.0 being neutral)
39                float VolumeTime;   ///< Transition duration (in seconds) for changes to @c Volume.
40              float Pitch;        ///< as linear frequency ratio (1.0 being neutral)              float Pitch;        ///< as linear frequency ratio (1.0 being neutral)
41                float PitchTime;    ///< Transition duration (in seconds) for changes to @c Pitch.
42              float Pan;          ///< between -1.0 (most left) and +1.0 (most right) and 0.0 being neutral.              float Pan;          ///< between -1.0 (most left) and +1.0 (most right) and 0.0 being neutral.
43              int64_t PanSources; ///< Might be used for calculating an average pan value in differential way: amount of times the Pan value had been changed and shall be calculated relatively upon.              int64_t PanSources; ///< Might be used for calculating an average pan value in differential way: amount of times the Pan value had been changed and shall be calculated relatively upon.
44              float Cutoff;       ///< between 0.0 and 1.0              float Cutoff;       ///< between 0.0 and 1.0
45              float Resonance;    ///< between 0.0 and 1.0              float Resonance;    ///< between 0.0 and 1.0
46                float Attack;       ///< between 0.0 and 1.0
47                float Decay;        ///< between 0.0 and 1.0
48                float Sustain;      ///< between 0.0 and 1.0
49                float Release;      ///< between 0.0 and 1.0
50                float AmpLFODepth;  ///< between 0.0 and 1.0
51                float AmpLFOFreq;   ///< between 0.0 and 1.0
52                float PitchLFODepth; ///< between 0.0 and 1.0
53                float PitchLFOFreq; ///< between 0.0 and 1.0
54                fade_curve_t VolumeCurve;
55                fade_curve_t PitchCurve;
56                int SampleOffset; ///< Where the sample shall start playback in microseconds (otherwise this is -1 for being ignored).
57          } Override;          } Override;
58          /// Sampler format specific informations and variables.          /// Sampler format specific informations and variables.
59          union _Format {          union _Format {
# Line 45  namespace LinuxSampler { Line 63  namespace LinuxSampler {
63                  uint8_t DimBits; ///< Used only in conjunction with DimMask: Dimension bits that shall be selected.                  uint8_t DimBits; ///< Used only in conjunction with DimMask: Dimension bits that shall be selected.
64              } Gig;              } Gig;
65          } Format;          } Format;
66            int userPar[4]; ///< Used only for real-time instrument script functions set_event_par() and get_event_par() to store script author's user specific data ($EVENT_PAR_0 to $EVENT_PAR_3).
67      protected:      protected:
68          NoteBase() : hostKey(0), parentNoteID(0), pChildNotes(NULL) {          NoteBase() : hostKey(0), parentNoteID(0), pChildNotes(NULL) {
69              Override.Volume     = 1.f;              Override.Volume     = 1.f;
70                Override.VolumeTime = DEFAULT_NOTE_VOLUME_TIME_S;
71              Override.Pitch      = 1.f;              Override.Pitch      = 1.f;
72                Override.PitchTime  = DEFAULT_NOTE_PITCH_TIME_S;
73              Override.Pan        = 0.f;              Override.Pan        = 0.f;
74              Override.PanSources = 0;              Override.PanSources = 0;
75              Override.Cutoff     = 1.f;              Override.Cutoff     = 1.f;
76              Override.Resonance  = 1.f;              Override.Resonance  = 1.f;
77                Override.Attack     = 1.f;
78                Override.Decay      = 1.f;
79                Override.Sustain    = 1.f;
80                Override.Release    = 1.f;
81                Override.AmpLFODepth   = 1.f;
82                Override.AmpLFOFreq    = 1.f;
83                Override.PitchLFODepth = 1.f;
84                Override.PitchLFOFreq  = 1.f;
85                Override.VolumeCurve = DEFAULT_FADE_CURVE;
86                Override.PitchCurve  = DEFAULT_FADE_CURVE;
87                Override.SampleOffset = -1;
88    
89              Format = _Format();              Format = _Format();
90    
91                userPar[0] = 0;
92                userPar[1] = 0;
93                userPar[2] = 0;
94                userPar[3] = 0;
95          }          }
96      };      };
97    
98      /**      /**
99       * Contains the voices caused by one specific note, as well as basic       * Contains the voices caused by one specific note, as well as basic
100       * informations about the note itself. You can see a Note object as one       * information about the note itself. You can see a Note object as one
101       * specific event in time where one or more voices were spawned at the same       * specific event in time where one or more voices were spawned at the same
102       * time and all those voices due to the same cause.       * time and all those voices due to the same cause.
103       *       *
104       * For example when you press down and hold the sustain pedal, and then       * For example when you press down and hold the sustain pedal, and then
105       * trigger the same note on the keyboard multiple times, for each key       * trigger the same note on the keyboard multiple times, for each key
106       * strokes a separate Note instance is created.       * strokes a separate Note instance is created. Assuming you have a layered
107         * sound with 4 layers, then for each note that is triggered 4 voices will
108         * be spawned and assigned to the same Note object. By grouping those voices
109         * to one specific Note object, it allows to control the synthesis paramters
110         * of those layered voices simultaniously.
111       *       *
112       * If your instrument contains a real-time instrument script, then that       * If your instrument contains a real-time instrument script, then that
113       * script might also trigger additional voices programmatically (by       * script might also trigger additional voices programmatically (by
# Line 104  namespace LinuxSampler { Line 146  namespace LinuxSampler {
146              cause = Event();              cause = Event();
147              eventID = 0;              eventID = 0;
148              Override.Volume     = 1.f;              Override.Volume     = 1.f;
149                Override.VolumeTime = DEFAULT_NOTE_VOLUME_TIME_S;
150              Override.Pitch      = 1.f;              Override.Pitch      = 1.f;
151                Override.PitchTime  = DEFAULT_NOTE_PITCH_TIME_S;
152              Override.Pan        = 0.f;              Override.Pan        = 0.f;
153              Override.PanSources = 0;              Override.PanSources = 0;
154              Override.Cutoff     = 1.f;              Override.Cutoff     = 1.f;
155              Override.Resonance  = 1.f;              Override.Resonance  = 1.f;
156                Override.Attack     = 1.f;
157                Override.Decay      = 1.f;
158                Override.Sustain    = 1.f;
159                Override.Release    = 1.f;
160                Override.AmpLFODepth   = 1.f;
161                Override.AmpLFOFreq    = 1.f;
162                Override.PitchLFODepth = 1.f;
163                Override.PitchLFOFreq  = 1.f;
164                Override.VolumeCurve = DEFAULT_FADE_CURVE;
165                Override.PitchCurve  = DEFAULT_FADE_CURVE;
166                Override.SampleOffset = -1;
167              Format = _Format();              Format = _Format();
168                userPar[0] = 0;
169                userPar[1] = 0;
170                userPar[2] = 0;
171                userPar[3] = 0;
172              if (pActiveVoices) {              if (pActiveVoices) {
173                  typename RTList<V>::Iterator itVoice = pActiveVoices->first();                  typename RTList<V>::Iterator itVoice = pActiveVoices->first();
174                  typename RTList<V>::Iterator itVoicesEnd = pActiveVoices->end();                  typename RTList<V>::Iterator itVoicesEnd = pActiveVoices->end();

Legend:
Removed from v.2938  
changed lines
  Added in v.3316

  ViewVC Help
Powered by ViewVC