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 - 2017 Christian Schoenebeck * |
* Copyright (C) 2005 - 2020 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 * |
31 |
#include "../EngineChannel.h" |
#include "../EngineChannel.h" |
32 |
#include "../../scriptvm/common.h" |
#include "../../scriptvm/common.h" |
33 |
|
|
34 |
|
// On Windows RELATIVE might be defined as macro in wingdi.h, which would |
35 |
|
// cause a compiler error of the same token used in this header file below. |
36 |
|
// So we undefine that macro here for now (if present). |
37 |
|
#ifdef RELATIVE |
38 |
|
# warning Preprocessor conflict detected: Macro RELATIVE was declared by system headers; undefining it here. |
39 |
|
# undef RELATIVE |
40 |
|
#endif |
41 |
|
|
42 |
namespace LinuxSampler { |
namespace LinuxSampler { |
43 |
|
|
44 |
// just symbol prototyping |
// just symbol prototyping |
205 |
synth_param_pitch_lfo_depth, |
synth_param_pitch_lfo_depth, |
206 |
synth_param_pitch_lfo_freq, |
synth_param_pitch_lfo_freq, |
207 |
}; |
}; |
208 |
|
enum class ValueScope : unsigned char { |
209 |
|
/** |
210 |
|
* The new synthesis parameter value should be applied |
211 |
|
* relatively to itself (as normalized value range), and then |
212 |
|
* applied relatively against other sources (i.e. LFOs, EGs) |
213 |
|
* for the same synthesis parameter. |
214 |
|
*/ |
215 |
|
SELF_RELATIVE = 1, |
216 |
|
/** |
217 |
|
* The new synthesis paramater value of itself should be |
218 |
|
* replaced, and then applied relatively to other sources |
219 |
|
* (i.e. LFOs, EGs) for the same synthesis parameter. |
220 |
|
*/ |
221 |
|
RELATIVE = 0, //IMPORANT: must remain 0 because of the union structure below which would otherwise i.e. assign invalid pointers/IDs to Param.Note structure in Init() |
222 |
|
/** |
223 |
|
* The new synthesis parameter value should be applied |
224 |
|
* relatively to itself (as normalized value range), and then |
225 |
|
* applied directly (as normalized value range) as final value |
226 |
|
* of this synthesis chain, thus all other sources (i.e. LFOs, |
227 |
|
* EGs) should entirely be ignored. |
228 |
|
*/ |
229 |
|
FINAL_SELF_RELATIVE = 2, |
230 |
|
/** |
231 |
|
* The new synthesis parameter value of itself should be |
232 |
|
* replaced, and then applied directly (as normalized value |
233 |
|
* range) as final value of this synthesis chain, thus all other |
234 |
|
* sources (i.e. LFOs, EGs) should entirely be ignored. |
235 |
|
*/ |
236 |
|
FINAL_NORM = 3, |
237 |
|
/** |
238 |
|
* Same as @c FINAL_NORM, but this one is already in the native |
239 |
|
* unit (i.e. seconds, Hz) of this synthesis parameter. |
240 |
|
*/ |
241 |
|
FINAL_NATIVE = 4, |
242 |
|
}; |
243 |
union { |
union { |
244 |
/// Note-on and note-off event specifics |
/// Note-on and note-off event specifics |
245 |
struct _Note { |
struct _Note { |
284 |
note_id_t NoteID; ///< ID of Note whose voices shall be modified. |
note_id_t NoteID; ///< ID of Note whose voices shall be modified. |
285 |
synth_param_t Type; ///< Synthesis parameter which is to be changed. |
synth_param_t Type; ///< Synthesis parameter which is to be changed. |
286 |
float Delta; ///< The value change that should be applied against the note's current synthesis parameter value. |
float Delta; ///< The value change that should be applied against the note's current synthesis parameter value. |
|
bool Relative; ///< Whether @c Delta should be applied relatively against the note's current synthesis parameter value (false means the paramter's current value is simply replaced by Delta). |
|
287 |
float AbsValue; ///< New current absolute value of synthesis parameter (that is after @c Delta being applied). |
float AbsValue; ///< New current absolute value of synthesis parameter (that is after @c Delta being applied). |
288 |
|
ValueScope Scope; ///< How @c Delta should be applied against @c AbsValue, and how @c AbsValue should then actually be applied to the synthesis chain. |
289 |
|
|
290 |
|
inline bool isFinal() const { return Scope >= ValueScope::FINAL_SELF_RELATIVE; } |
291 |
} NoteSynthParam; |
} NoteSynthParam; |
292 |
} Param; |
} Param; |
293 |
EngineChannel* pEngineChannel; ///< Pointer to the EngineChannel where this event occured on, NULL means Engine global event (e.g. SysEx message). |
EngineChannel* pEngineChannel; ///< Pointer to the EngineChannel where this event occured on, NULL means Engine global event (e.g. SysEx message). |
294 |
MidiInputPort* pMidiInputPort; ///< Pointer to the MIDI input port on which this event occured (NOTE: currently only for global events, that is SysEx messages) |
MidiInputPort* pMidiInputPort; ///< Pointer to the MIDI input port on which this event occured (NOTE: currently only for global events, that is SysEx messages) |
295 |
|
|
296 |
inline void Init() { |
inline void Init() { |
297 |
Param.Note.ID = 0; |
memset(&Param, 0, sizeof(Param)); |
|
Param.Note.ParentNoteID = 0; |
|
|
Param.NoteSynthParam.NoteID = 0; |
|
298 |
} |
} |
299 |
inline int32_t FragmentPos() { |
inline int32_t FragmentPos() { |
300 |
if (iFragmentPos >= 0) return iFragmentPos; |
if (iFragmentPos >= 0) return iFragmentPos; |
312 |
inline sched_time_t SchedTime() { |
inline sched_time_t SchedTime() { |
313 |
return pEventGenerator->schedTimeAtCurrentFragmentStart() + FragmentPos(); |
return pEventGenerator->schedTimeAtCurrentFragmentStart() + FragmentPos(); |
314 |
} |
} |
315 |
|
inline static ValueScope scopeBy_FinalRelativeUnit(bool bFinal, bool bRelative, bool bNativeUnit) { |
316 |
|
if (!bFinal && bRelative) |
317 |
|
return ValueScope::SELF_RELATIVE; |
318 |
|
if (!bFinal) |
319 |
|
return ValueScope::RELATIVE; |
320 |
|
if (bRelative) |
321 |
|
return ValueScope::FINAL_SELF_RELATIVE; |
322 |
|
if (bNativeUnit) |
323 |
|
return ValueScope::FINAL_NATIVE; |
324 |
|
return ValueScope::FINAL_NORM; |
325 |
|
} |
326 |
protected: |
protected: |
327 |
typedef EventGenerator::time_stamp_t time_stamp_t; |
typedef EventGenerator::time_stamp_t time_stamp_t; |
328 |
Event(EventGenerator* pGenerator, EventGenerator::time_stamp_t Time); |
Event(EventGenerator* pGenerator, EventGenerator::time_stamp_t Time); |