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 |
|
#define DEFAULT_NOTE_PAN_TIME_S 0.013f /* 13ms */ |
20 |
|
|
21 |
namespace LinuxSampler { |
namespace LinuxSampler { |
22 |
|
|
37 |
/// 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.). |
38 |
struct _Override { |
struct _Override { |
39 |
float Volume; ///< as linear amplification ratio (1.0 being neutral) |
float Volume; ///< as linear amplification ratio (1.0 being neutral) |
40 |
|
float VolumeTime; ///< Transition duration (in seconds) for changes to @c Volume. |
41 |
float Pitch; ///< as linear frequency ratio (1.0 being neutral) |
float Pitch; ///< as linear frequency ratio (1.0 being neutral) |
42 |
|
float PitchTime; ///< Transition duration (in seconds) for changes to @c Pitch. |
43 |
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. |
44 |
|
float PanTime; ///< Transition duration (in seconds) for changes to @c Pan. |
45 |
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. |
46 |
float Cutoff; ///< between 0.0 and 1.0 |
float Cutoff; ///< between 0.0 and 1.0 |
47 |
float Resonance; ///< between 0.0 and 1.0 |
float Resonance; ///< between 0.0 and 1.0 |
48 |
float Attack; ///< between 0.0 and 1.0 |
float Attack; ///< between 0.0 and 1.0 |
49 |
float Decay; ///< between 0.0 and 1.0 |
float Decay; ///< between 0.0 and 1.0 |
50 |
|
float Sustain; ///< between 0.0 and 1.0 |
51 |
float Release; ///< between 0.0 and 1.0 |
float Release; ///< between 0.0 and 1.0 |
52 |
float AmpLFODepth; ///< between 0.0 and 1.0 |
float AmpLFODepth; ///< between 0.0 and 1.0 |
53 |
float AmpLFOFreq; ///< between 0.0 and 1.0 |
float AmpLFOFreq; ///< between 0.0 and 1.0 |
54 |
float PitchLFODepth; ///< between 0.0 and 1.0 |
float PitchLFODepth; ///< between 0.0 and 1.0 |
55 |
float PitchLFOFreq; ///< between 0.0 and 1.0 |
float PitchLFOFreq; ///< between 0.0 and 1.0 |
56 |
|
fade_curve_t VolumeCurve; |
57 |
|
fade_curve_t PitchCurve; |
58 |
|
fade_curve_t PanCurve; |
59 |
|
int SampleOffset; ///< Where the sample shall start playback in microseconds (otherwise this is -1 for being ignored). |
60 |
} Override; |
} Override; |
61 |
/// Sampler format specific informations and variables. |
/// Sampler format specific informations and variables. |
62 |
union _Format { |
union _Format { |
66 |
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. |
67 |
} Gig; |
} Gig; |
68 |
} Format; |
} Format; |
69 |
|
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). |
70 |
protected: |
protected: |
71 |
NoteBase() : hostKey(0), parentNoteID(0), pChildNotes(NULL) { |
NoteBase() : hostKey(0), parentNoteID(0), pChildNotes(NULL) { |
72 |
Override.Volume = 1.f; |
Override.Volume = 1.f; |
73 |
|
Override.VolumeTime = DEFAULT_NOTE_VOLUME_TIME_S; |
74 |
Override.Pitch = 1.f; |
Override.Pitch = 1.f; |
75 |
|
Override.PitchTime = DEFAULT_NOTE_PITCH_TIME_S; |
76 |
Override.Pan = 0.f; |
Override.Pan = 0.f; |
77 |
|
Override.PanTime = DEFAULT_NOTE_PAN_TIME_S; |
78 |
Override.PanSources = 0; |
Override.PanSources = 0; |
79 |
Override.Cutoff = 1.f; |
Override.Cutoff = 1.f; |
80 |
Override.Resonance = 1.f; |
Override.Resonance = 1.f; |
81 |
Override.Attack = 1.f; |
Override.Attack = 1.f; |
82 |
Override.Decay = 1.f; |
Override.Decay = 1.f; |
83 |
|
Override.Sustain = 1.f; |
84 |
Override.Release = 1.f; |
Override.Release = 1.f; |
85 |
Override.AmpLFODepth = 1.f; |
Override.AmpLFODepth = 1.f; |
86 |
Override.AmpLFOFreq = 1.f; |
Override.AmpLFOFreq = 1.f; |
87 |
Override.PitchLFODepth = 1.f; |
Override.PitchLFODepth = 1.f; |
88 |
Override.PitchLFOFreq = 1.f; |
Override.PitchLFOFreq = 1.f; |
89 |
|
Override.VolumeCurve = DEFAULT_FADE_CURVE; |
90 |
|
Override.PitchCurve = DEFAULT_FADE_CURVE; |
91 |
|
Override.PanCurve = DEFAULT_FADE_CURVE; |
92 |
|
Override.SampleOffset = -1; |
93 |
|
|
94 |
Format = _Format(); |
Format = _Format(); |
95 |
|
|
96 |
|
userPar[0] = 0; |
97 |
|
userPar[1] = 0; |
98 |
|
userPar[2] = 0; |
99 |
|
userPar[3] = 0; |
100 |
} |
} |
101 |
}; |
}; |
102 |
|
|
103 |
/** |
/** |
104 |
* Contains the voices caused by one specific note, as well as basic |
* Contains the voices caused by one specific note, as well as basic |
105 |
* 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 |
106 |
* 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 |
107 |
* time and all those voices due to the same cause. |
* time and all those voices due to the same cause. |
108 |
* |
* |
109 |
* 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 |
110 |
* trigger the same note on the keyboard multiple times, for each key |
* trigger the same note on the keyboard multiple times, for each key |
111 |
* strokes a separate Note instance is created. |
* strokes a separate Note instance is created. Assuming you have a layered |
112 |
|
* sound with 4 layers, then for each note that is triggered 4 voices will |
113 |
|
* be spawned and assigned to the same Note object. By grouping those voices |
114 |
|
* to one specific Note object, it allows to control the synthesis paramters |
115 |
|
* of those layered voices simultaniously. |
116 |
* |
* |
117 |
* If your instrument contains a real-time instrument script, then that |
* If your instrument contains a real-time instrument script, then that |
118 |
* script might also trigger additional voices programmatically (by |
* script might also trigger additional voices programmatically (by |
151 |
cause = Event(); |
cause = Event(); |
152 |
eventID = 0; |
eventID = 0; |
153 |
Override.Volume = 1.f; |
Override.Volume = 1.f; |
154 |
|
Override.VolumeTime = DEFAULT_NOTE_VOLUME_TIME_S; |
155 |
Override.Pitch = 1.f; |
Override.Pitch = 1.f; |
156 |
|
Override.PitchTime = DEFAULT_NOTE_PITCH_TIME_S; |
157 |
Override.Pan = 0.f; |
Override.Pan = 0.f; |
158 |
|
Override.PanTime = DEFAULT_NOTE_PAN_TIME_S; |
159 |
Override.PanSources = 0; |
Override.PanSources = 0; |
160 |
Override.Cutoff = 1.f; |
Override.Cutoff = 1.f; |
161 |
Override.Resonance = 1.f; |
Override.Resonance = 1.f; |
162 |
Override.Attack = 1.f; |
Override.Attack = 1.f; |
163 |
Override.Decay = 1.f; |
Override.Decay = 1.f; |
164 |
|
Override.Sustain = 1.f; |
165 |
Override.Release = 1.f; |
Override.Release = 1.f; |
166 |
Override.AmpLFODepth = 1.f; |
Override.AmpLFODepth = 1.f; |
167 |
Override.AmpLFOFreq = 1.f; |
Override.AmpLFOFreq = 1.f; |
168 |
Override.PitchLFODepth = 1.f; |
Override.PitchLFODepth = 1.f; |
169 |
Override.PitchLFOFreq = 1.f; |
Override.PitchLFOFreq = 1.f; |
170 |
|
Override.VolumeCurve = DEFAULT_FADE_CURVE; |
171 |
|
Override.PitchCurve = DEFAULT_FADE_CURVE; |
172 |
|
Override.PanCurve = DEFAULT_FADE_CURVE; |
173 |
|
Override.SampleOffset = -1; |
174 |
Format = _Format(); |
Format = _Format(); |
175 |
|
userPar[0] = 0; |
176 |
|
userPar[1] = 0; |
177 |
|
userPar[2] = 0; |
178 |
|
userPar[3] = 0; |
179 |
if (pActiveVoices) { |
if (pActiveVoices) { |
180 |
typename RTList<V>::Iterator itVoice = pActiveVoices->first(); |
typename RTList<V>::Iterator itVoice = pActiveVoices->first(); |
181 |
typename RTList<V>::Iterator itVoicesEnd = pActiveVoices->end(); |
typename RTList<V>::Iterator itVoicesEnd = pActiveVoices->end(); |