/[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 2931 by schoenebeck, Sat Jul 9 14:38:33 2016 UTC revision 3246 by schoenebeck, Sun May 28 22:22:56 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
45                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 Release;      ///< between 0.0 and 1.0
49                float AmpLFODepth;  ///< between 0.0 and 1.0
50                float AmpLFOFreq;   ///< between 0.0 and 1.0
51                float PitchLFODepth; ///< between 0.0 and 1.0
52                float PitchLFOFreq; ///< between 0.0 and 1.0
53                fade_curve_t VolumeCurve;
54                fade_curve_t PitchCurve;
55          } Override;          } Override;
56          /// Sampler format specific informations and variables.          /// Sampler format specific informations and variables.
57          union _Format {          union _Format {
# Line 43  namespace LinuxSampler { Line 61  namespace LinuxSampler {
61                  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.
62              } Gig;              } Gig;
63          } Format;          } Format;
64            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).
65      protected:      protected:
66          NoteBase() : hostKey(0), parentNoteID(0), pChildNotes(NULL) {          NoteBase() : hostKey(0), parentNoteID(0), pChildNotes(NULL) {
67              Override.Volume     = 1.f;              Override.Volume     = 1.f;
68                Override.VolumeTime = DEFAULT_NOTE_VOLUME_TIME_S;
69              Override.Pitch      = 1.f;              Override.Pitch      = 1.f;
70                Override.PitchTime  = DEFAULT_NOTE_PITCH_TIME_S;
71              Override.Pan        = 0.f;              Override.Pan        = 0.f;
72              Override.PanSources = 0;              Override.PanSources = 0;
73                Override.Cutoff     = 1.f;
74                Override.Resonance  = 1.f;
75                Override.Attack     = 1.f;
76                Override.Decay      = 1.f;
77                Override.Release    = 1.f;
78                Override.AmpLFODepth   = 1.f;
79                Override.AmpLFOFreq    = 1.f;
80                Override.PitchLFODepth = 1.f;
81                Override.PitchLFOFreq  = 1.f;
82                Override.VolumeCurve = DEFAULT_FADE_CURVE;
83                Override.PitchCurve  = DEFAULT_FADE_CURVE;
84    
85              Format = _Format();              Format = _Format();
86    
87                userPar[0] = 0;
88                userPar[1] = 0;
89                userPar[2] = 0;
90                userPar[3] = 0;
91          }          }
92      };      };
93    
94      /**      /**
95       * Contains the voices caused by one specific note, as well as basic       * Contains the voices caused by one specific note, as well as basic
96       * informations about the note itself.       * information about the note itself. You can see a Note object as one
97         * specific event in time where one or more voices were spawned at the same
98         * time and all those voices due to the same cause.
99         *
100         * For example when you press down and hold the sustain pedal, and then
101         * trigger the same note on the keyboard multiple times, for each key
102         * strokes a separate Note instance is created. Assuming you have a layered
103         * sound with 4 layers, then for each note that is triggered 4 voices will
104         * be spawned and assigned to the same Note object. By grouping those voices
105         * to one specific Note object, it allows to control the synthesis paramters
106         * of those layered voices simultaniously.
107         *
108         * If your instrument contains a real-time instrument script, then that
109         * script might also trigger additional voices programmatically (by
110         * calling the built-in script function play_note()). Each time the script
111         * calls play_note() a new Note instance is created and the script may then
112         * further control the voices of specific notes independently from each
113         * other. For example for each key stroke on your keyboard the instrument
114         * script might trigger 3 additional notes programmatically and assign a
115         * different tuning filter parameters for each one of the 3 notes
116         * independently.
117       */       */
118      template<class V>      template<class V>
119      class Note : public NoteBase {      class Note : public NoteBase {
# Line 84  namespace LinuxSampler { Line 142  namespace LinuxSampler {
142              cause = Event();              cause = Event();
143              eventID = 0;              eventID = 0;
144              Override.Volume     = 1.f;              Override.Volume     = 1.f;
145                Override.VolumeTime = DEFAULT_NOTE_VOLUME_TIME_S;
146              Override.Pitch      = 1.f;              Override.Pitch      = 1.f;
147                Override.PitchTime  = DEFAULT_NOTE_PITCH_TIME_S;
148              Override.Pan        = 0.f;              Override.Pan        = 0.f;
149              Override.PanSources = 0;              Override.PanSources = 0;
150                Override.Cutoff     = 1.f;
151                Override.Resonance  = 1.f;
152                Override.Attack     = 1.f;
153                Override.Decay      = 1.f;
154                Override.Release    = 1.f;
155                Override.AmpLFODepth   = 1.f;
156                Override.AmpLFOFreq    = 1.f;
157                Override.PitchLFODepth = 1.f;
158                Override.PitchLFOFreq  = 1.f;
159                Override.VolumeCurve = DEFAULT_FADE_CURVE;
160                Override.PitchCurve  = DEFAULT_FADE_CURVE;
161              Format = _Format();              Format = _Format();
162                userPar[0] = 0;
163                userPar[1] = 0;
164                userPar[2] = 0;
165                userPar[3] = 0;
166              if (pActiveVoices) {              if (pActiveVoices) {
167                  typename RTList<V>::Iterator itVoice = pActiveVoices->first();                  typename RTList<V>::Iterator itVoice = pActiveVoices->first();
168                  typename RTList<V>::Iterator itVoicesEnd = pActiveVoices->end();                  typename RTList<V>::Iterator itVoicesEnd = pActiveVoices->end();

Legend:
Removed from v.2931  
changed lines
  Added in v.3246

  ViewVC Help
Powered by ViewVC