1 #ifndef __AMUSE_VOICE_HPP__ 2 #define __AMUSE_VOICE_HPP__ 8 #include "SoundMacroState.hpp" 10 #include "AudioGroupSampleDirectory.hpp" 11 #include "AudioGroup.hpp" 12 #include "Envelope.hpp" 37 Submix* m_submix =
nullptr;
38 std::list<std::shared_ptr<Voice>>::iterator m_engineIt;
40 std::unique_ptr<IBackendVoice> m_backendVoice;
42 SoundMacroState::EventTrap m_keyoffTrap;
43 SoundMacroState::EventTrap m_sampleEndTrap;
44 SoundMacroState::EventTrap m_messageTrap;
45 std::list<int32_t> m_messageQueue;
46 std::list<std::shared_ptr<Voice>> m_childVoices;
47 uint8_t m_keygroup = 0;
49 enum class SampleFormat : uint8_t
55 const Sample* m_curSample =
nullptr;
56 const unsigned char* m_curSampleData =
nullptr;
57 SampleFormat m_curFormat;
58 uint32_t m_curSamplePos = 0;
59 uint32_t m_lastSamplePos = 0;
62 double m_sampleRate = 32000.0;
65 VoiceState m_voxState = VoiceState::Dead;
66 bool m_sustained =
false;
67 bool m_sustainKeyOff =
false;
68 uint8_t m_curAftertouch = 0;
70 float m_userVol = 1.f;
75 float m_curPitchWheel = 0.f;
76 int32_t m_pitchWheelUp;
77 int32_t m_pitchWheelDown;
78 int32_t m_pitchWheelVal;
83 double m_envelopeTime;
85 float m_envelopeStart;
87 const Curve* m_envelopeCurve;
89 bool m_pitchEnv =
false;
91 int32_t m_pitchEnvRange;
93 uint32_t m_pitchSweep1;
94 uint32_t m_pitchSweep2;
95 int16_t m_pitchSweep1Add;
96 int16_t m_pitchSweep2Add;
97 uint8_t m_pitchSweep1Times;
98 uint8_t m_pitchSweep2Times;
99 uint8_t m_pitchSweep1It;
100 uint8_t m_pitchSweep2It;
107 float m_spanningTime;
112 int32_t m_vibratoLevel;
113 int32_t m_vibratoModLevel;
114 float m_vibratoPeriod;
115 bool m_vibratoModWheel;
117 float m_tremoloScale;
118 float m_tremoloModScale;
120 float m_lfoPeriods[2];
121 std::unique_ptr<int8_t[]> m_ctrlValsSelf;
122 int8_t* m_extCtrlVals =
nullptr;
126 bool _checkSamplePos();
129 void _macroSampleEnd();
130 bool _advanceSample(int16_t& samp, int32_t& curPitch);
131 void _setTotalPitch(int32_t cents,
bool slew);
132 bool _isRecursivelyDead();
133 void _bringOutYourDead();
134 std::shared_ptr<Voice> _findVoice(
int vid, std::weak_ptr<Voice> thisPtr);
135 std::unique_ptr<int8_t[]>& _ensureCtrlVals();
137 std::shared_ptr<Voice> _allocateVoice(
double sampleRate,
bool dynamicPitch);
138 std::list<std::shared_ptr<Voice>>::iterator _destroyVoice(
Voice* voice);
140 bool _loadSoundMacro(
const unsigned char* macroData,
int macroStep,
double ticksPerSec,
141 uint8_t midiKey, uint8_t midiVel, uint8_t midiMod,
bool pushPc=
false);
142 bool _loadKeymap(
const Keymap* keymap,
int macroStep,
double ticksPerSec,
143 uint8_t midiKey, uint8_t midiVel, uint8_t midiMod,
bool pushPc=
false);
144 bool _loadLayer(
const std::vector<const LayerMapping*>& layer,
int macroStep,
double ticksPerSec,
145 uint8_t midiKey, uint8_t midiVel, uint8_t midiMod,
bool pushPc=
false);
146 std::shared_ptr<Voice> _startChildMacro(ObjectId macroId,
int macroStep,
double ticksPerSec,
147 uint8_t midiKey, uint8_t midiVel, uint8_t midiMod,
bool pushPc=
false);
155 size_t supplyAudio(
size_t frames, int16_t* data);
161 VoiceState
state()
const {
return m_voxState;}
164 int vid()
const {
return m_vid;}
170 std::shared_ptr<Voice> startChildMacro(int8_t addNote, ObjectId macroId,
int macroStep);
173 bool loadSoundObject(ObjectId objectId,
int macroStep,
double ticksPerSec,
174 uint8_t midiKey, uint8_t midiVel, uint8_t midiMod,
181 void message(int32_t val);
184 void startSample(int16_t sampId, int32_t offset);
190 void setVolume(
float vol);
193 void setPan(
float pan);
196 void setSurroundPan(
float span);
199 void startEnvelope(
double dur,
float vol,
const Curve* envCurve);
202 void startFadeIn(
double dur,
float vol,
const Curve* envCurve);
205 void startPanning(
double dur, uint8_t panPos, uint8_t panWidth);
208 void startSpanning(
double dur, uint8_t spanPos, uint8_t spanWidth);
211 void setPitchKey(int32_t cents);
214 void setPedal(
bool pedal);
217 void setDoppler(
float doppler);
220 void setVibrato(int32_t level, int32_t modLevel,
float period);
223 void setMod2VibratoRange(int32_t modLevel);
226 void setTremolo(
float tremoloScale,
float tremoloModScale);
235 void setPitchSweep1(uint8_t times, int16_t add);
238 void setPitchSweep2(uint8_t times, int16_t add);
241 void setReverbVol(
float rvol);
244 void setAdsr(ObjectId adsrId,
bool dls);
247 void setPitchFrequency(uint32_t hz, uint16_t fine);
250 void setPitchAdsr(ObjectId adsrId, int32_t cents);
253 void setPitchWheel(
float pitchWheel);
256 void setPitchWheelRange(int8_t up, int8_t down);
259 void setAftertouch(uint8_t aftertouch);
267 void notifyCtrlChange(uint8_t ctrl, int8_t val);
275 m_ctrlValsSelf[ctrl];
278 return m_extCtrlVals[ctrl];
286 std::unique_ptr<int8_t[]>& vals = _ensureCtrlVals();
290 m_extCtrlVals[ctrl] = val;
291 notifyCtrlChange(ctrl, val);
300 m_ctrlValsSelf.reset();
311 size_t getTotalVoices()
const;
317 #endif // __AMUSE_VOICE_HPP__ int8_t getAftertouch() const
int8_t getModWheel() const
int8_t getPitchWheel() const
void setLFO2Period(float period)
void setKeygroup(uint8_t kg)
void installCtrlValues(int8_t *cvs)
uint8_t getLastNote() const
void setCtrlValue(uint8_t ctrl, int8_t val)
void setLFO1Period(float period)
int8_t getCtrlValue(uint8_t ctrl) const