1 |
iliev |
2012 |
/*************************************************************************** |
2 |
|
|
* * |
3 |
|
|
* LinuxSampler - modular, streaming capable sampler * |
4 |
|
|
* * |
5 |
|
|
* Copyright (C) 2003,2004 by Benno Senoner and Christian Schoenebeck * |
6 |
|
|
* Copyright (C) 2005-2009 Christian Schoenebeck * |
7 |
|
|
* * |
8 |
|
|
* 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 * |
10 |
|
|
* the Free Software Foundation; either version 2 of the License, or * |
11 |
|
|
* (at your option) any later version. * |
12 |
|
|
* * |
13 |
|
|
* This program is distributed in the hope that it will be useful, * |
14 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
15 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
16 |
|
|
* GNU General Public License for more details. * |
17 |
|
|
* * |
18 |
|
|
* You should have received a copy of the GNU General Public License * |
19 |
|
|
* along with this program; if not, write to the Free Software * |
20 |
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, * |
21 |
|
|
* MA 02111-1307 USA * |
22 |
|
|
***************************************************************************/ |
23 |
|
|
|
24 |
|
|
#ifndef __LS_VOICE_H__ |
25 |
|
|
#define __LS_VOICE_H__ |
26 |
|
|
|
27 |
|
|
#include "Event.h" |
28 |
|
|
#include "../../common/Pool.h" |
29 |
|
|
|
30 |
iliev |
2015 |
#include <gig.h> // TODO: remove gig dependency |
31 |
|
|
|
32 |
iliev |
2012 |
namespace LinuxSampler { |
33 |
|
|
|
34 |
|
|
class Voice { |
35 |
|
|
public: |
36 |
|
|
enum playback_state_t { |
37 |
|
|
playback_state_end = 0, |
38 |
|
|
playback_state_init = 1, |
39 |
|
|
playback_state_ram = 2, |
40 |
|
|
playback_state_disk = 3 |
41 |
|
|
}; |
42 |
|
|
|
43 |
|
|
// Types |
44 |
|
|
enum type_t { |
45 |
|
|
type_normal, |
46 |
|
|
type_release_trigger_required, ///< If the key of this voice will be released, it causes a release triggered voice to be spawned |
47 |
|
|
type_release_trigger ///< Release triggered voice which cannot be killed by releasing its key |
48 |
|
|
}; |
49 |
iliev |
2015 |
|
50 |
|
|
struct PitchInfo { |
51 |
|
|
float PitchBase; ///< Basic pitch depth, stays the same for the whole life time of the voice |
52 |
|
|
float PitchBend; ///< Current pitch value of the pitchbend wheel |
53 |
|
|
float PitchBendRange; ///< The pitch range of the pitchbend wheel, value is in cents / 8192 |
54 |
|
|
}; |
55 |
|
|
|
56 |
|
|
struct EGInfo { |
57 |
|
|
double Attack; |
58 |
|
|
double Decay; |
59 |
|
|
double Release; |
60 |
|
|
}; |
61 |
|
|
|
62 |
|
|
struct SampleInfo { |
63 |
|
|
uint SampleRate; |
64 |
|
|
uint ChannelCount; |
65 |
|
|
uint FrameSize; |
66 |
|
|
uint TotalFrameCount; |
67 |
|
|
uint BitDepth; |
68 |
|
|
bool HasLoops; |
69 |
|
|
uint LoopStart; |
70 |
|
|
uint LoopLength; |
71 |
|
|
uint LoopPlayCount; ///< Number of times the loop should be played (a value of 0 = infinite). |
72 |
|
|
bool Unpitched; ///< sound which is not characterized by a perceived frequency |
73 |
|
|
}; |
74 |
|
|
|
75 |
|
|
struct RegionInfo { |
76 |
|
|
uint8_t UnityNote; ///< The MIDI key number of the recorded pitch of the sample |
77 |
|
|
int16_t FineTune; |
78 |
|
|
int Pan; ///< Panorama / Balance (-64..0..63 <-> left..middle..right) |
79 |
|
|
uint SampleStartOffset; ///< Number of samples the sample start should be moved |
80 |
|
|
|
81 |
|
|
double EG1PreAttack; ///< Preattack value of the sample amplitude EG (in permilles) |
82 |
|
|
double EG1Attack; ///< Attack time of the sample amplitude EG (in seconds) |
83 |
|
|
double EG1Hold; ///< If true, Decay1 stage should be postponed until the sample reached the sample loop start |
84 |
|
|
double EG1Decay1; ///< Decay time of the sample amplitude EG (in seconds) |
85 |
|
|
double EG1Decay2; ///< Only if (EG1InfiniteSustain == false): 2nd decay stage time of the sample amplitude EG (in seconds) |
86 |
|
|
double EG1Sustain; ///< Sustain value of the sample amplitude EG (in permilles) |
87 |
|
|
bool EG1InfiniteSustain; ///< If true, instead of going into Decay2 phase, Decay1 level will be hold until note will be released. |
88 |
|
|
double EG1Release; ///< Release time of the sample amplitude EG (in seconds) |
89 |
|
|
|
90 |
|
|
double EG2PreAttack; ///< Preattack value of the filter cutoff EG (in permilles) |
91 |
|
|
double EG2Attack; ///< Attack time of the filter cutoff EG (in seconds) |
92 |
|
|
double EG2Decay1; ///< Decay time of the filter cutoff EG (in seconds) |
93 |
|
|
double EG2Decay2; ///< Only if (EG2InfiniteSustain == false): 2nd decay stage time of the filter cutoff EG (in seconds) |
94 |
|
|
double EG2Sustain; ///< Sustain value of the filter cutoff EG (in permilles) |
95 |
|
|
bool EG2InfiniteSustain; ///< If true, instead of going into Decay2 phase, Decay1 level will be hold until note will be released. |
96 |
|
|
double EG2Release; ///< Release time of the filter cutoff EG (in seconds) |
97 |
|
|
|
98 |
|
|
double EG3Attack; ///< Attack time of the sample pitch EG (in seconds) |
99 |
|
|
int EG3Depth; ///< Depth of the sample pitch EG (-1200 - +1200) |
100 |
persson |
2061 |
double ReleaseTriggerDecay; ///< How much release sample volume depends on note length. Release sample amplitude is multiplied with (1 - ReleaseTriggerDecay * note length). |
101 |
iliev |
2015 |
|
102 |
|
|
bool VCFEnabled; ///< If filter should be used. |
103 |
|
|
::gig::vcf_type_t VCFType; ///< Defines the general filter characteristic (lowpass, highpass, bandpass, etc.). |
104 |
|
|
uint8_t VCFResonance; ///< Firm internal filter resonance weight. |
105 |
|
|
}; |
106 |
|
|
|
107 |
|
|
struct InstrumentInfo { |
108 |
|
|
int FineTune; // in cents |
109 |
|
|
uint PitchbendRange; ///< Number of semitones pitchbend controller can pitch |
110 |
|
|
}; |
111 |
|
|
|
112 |
|
|
/// Reflects a MIDI controller |
113 |
|
|
struct midi_ctrl { |
114 |
|
|
uint8_t controller; ///< MIDI control change controller number |
115 |
|
|
uint8_t value; ///< Current MIDI controller value |
116 |
|
|
float fvalue; ///< Transformed / effective value (e.g. volume level or filter cutoff frequency) |
117 |
|
|
}; |
118 |
|
|
|
119 |
|
|
Voice() { } |
120 |
|
|
virtual ~Voice() { } |
121 |
iliev |
2012 |
}; |
122 |
|
|
} // namespace LinuxSampler |
123 |
|
|
|
124 |
|
|
#endif /* __LS_VOICE_H__ */ |
125 |
|
|
|