Deluge Firmware
Loading...
Searching...
No Matches
voice.h
Go to the documentation of this file.
1/*
2 * Copyright © 2014-2023 Synthstrom Audible Limited
3 *
4 * This file is part of The Synthstrom Audible Deluge Firmware.
5 *
6 * The Synthstrom Audible Deluge Firmware is free software: you can redistribute it and/or modify it under the
7 * terms of the GNU General Public License as published by the Free Software Foundation,
8 * either version 3 of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
11 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 * See the GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along with this program.
15 * If not, see <https://www.gnu.org/licenses/>.
16 */
17
18#ifndef VOICE_H
19#define VOICE_H
20
21#include <patcher.h>
23#include "definitions.h"
24#include "envelope.h"
25#include "lfo.h"
26#include "voiceunisonpart.h"
27#include "FilterSet.h"
28
29class StereoSample;
30class FilterSetConfig;
32
33class Voice final {
34public:
35 Voice();
36
38
39 VoiceUnisonPart unisonParts[maxNumUnison]; // Stores all oscillator positions and stuff, for each Source within each Unison too
40 VoiceSamplePlaybackGuide guides[NUM_SOURCES]; // Stores overall info on each Source (basically just sample memory bounds), for the play-through associated with this Voice right now.
41
43
44 int32_t paramFinalValues[FIRST_GLOBAL_PARAM]; // This is just for the *local* params, specific to this Voice only
45 int32_t sourceValues[NUM_PATCH_SOURCES]; // At the start of this list are local copies of the "global" ones. It's cheaper to copy them here than to pick and choose where the Patcher looks for them
46
48
51
53 int inputCharacteristics[2]; // Contains what used to be called noteCodeBeforeArpeggiation, and fromMIDIChannel
55
58
60
65
67
72
73 uint32_t orderSounded;
74
76
78
79 void setAsUnassigned(ModelStackWithVoice* modelStack, bool deletingSong = false);
80 bool render(ModelStackWithVoice* modelStack, int32_t* soundBuffer, int numSamples, bool soundRenderingInStereo, bool applyingPanAtVoiceLevel, uint32_t sourcesChanged, FilterSetConfig* filterSetConfig, int32_t externalPitchAdjust);
81
83 bool sampleZoneChanged(ModelStackWithVoice* modelStack, int s, int markerType);
84 bool noteOn(ModelStackWithVoice* modelStack, int newNoteCodeBeforeArpeggiation, int newNoteCodeAfterArpeggiation, uint8_t velocity, uint32_t newSampleSyncLength, int32_t ticksLate, uint32_t samplesLate, bool resetEnvelopes, int fromMIDIChannel, const int16_t* mpeValues);
85 void noteOff(ModelStackWithVoice* modelStack, bool allowReleaseStage = true);
86 bool doFastRelease(uint32_t releaseIncrement = 4096);
87 void randomizeOscPhases(Sound* sound);
88 void changeNoteCode(ModelStackWithVoice* modelStack, int newNoteCodeBeforeArpeggiation, int newNoteCodeAfterArpeggiation, int newInputMIDIChannel, const int16_t* newMPEValues);
89 bool hasReleaseStage();
90 void unassignStuff();
91 uint32_t getPriorityRating();
92 void expressionEventImmediate(Sound* sound, int32_t voiceLevelValue, int s);
93 void expressionEventSmooth(int32_t newValue, int s);
94
95private:
96 //inline int32_t doFM(uint32_t *carrierPhase, uint32_t* lastShiftedPhase, uint32_t carrierPhaseIncrement, uint32_t phaseShift);
97
98 void renderOsc(int s, int type, int32_t amplitude, int32_t* thisSample, int32_t* bufferEnd, int numSamples, uint32_t phaseIncrementNow, uint32_t phaseWidth, uint32_t* thisPhase, bool applyAmplitude, int32_t amplitudeIncrement, bool doOscSync, uint32_t resetterPhase, uint32_t resetterPhaseIncrement, uint32_t retriggerPhase, int32_t waveIndexIncrement);
99 void renderBasicSource(Sound* sound, ParamManagerForTimeline* paramManager, int s, int32_t* oscBuffer, int numSamples, int32_t sourceAmplitude, bool* unisonPartBecameInactive, int32_t overallPitchAdjust, bool doOscSync, uint32_t* oscSyncPos, uint32_t* oscSyncPhaseIncrements, int32_t amplitudeIncrement, uint32_t* getPhaseIncrements, bool getOutAfterPhaseIncrements, int32_t waveIndexIncrement);
100 bool adjustPitch(uint32_t* phaseIncrement, int32_t adjustment);
101
102 void renderSineWaveWithFeedback(int32_t* thisSample, int numSamples, uint32_t* phase, int32_t amplitude, uint32_t phaseIncrement, int32_t feedbackAmount, int32_t* lastFeedbackValue, bool add, int32_t amplitudeIncrement);
103 void renderFMWithFeedback(int32_t* thisSample, int numSamples, int32_t* fmBuffer, uint32_t* phase, int32_t amplitude, uint32_t phaseIncrement, int32_t feedbackAmount, int32_t* lastFeedbackValue, int32_t amplitudeIncrement);
104 void renderFMWithFeedbackAdd(int32_t* thisSample, int numSamples, int32_t* fmBuffer, uint32_t* phase, int32_t amplitude, uint32_t phaseIncrement, int32_t feedbackAmount, int32_t* lastFeedbackValue, int32_t amplitudeIncrement);
105 bool areAllUnisonPartsInactive(ModelStackWithVoice* modelStackWithVoice);
106 void setupPorta(Sound* sound);
107 int32_t combineExpressionValues(Sound* sound, int whichExpressionDimension);
108
109};
110
111#endif // VOICE_H
Definition: envelope.h:29
Definition: FilterSetConfig.h:23
Definition: FilterSet.h:68
Definition: lfo.h:24
Definition: ModelStack.h:305
Definition: ParamManager.h:166
Definition: patcher.h:48
Definition: sound.h:66
Definition: AudioSample.h:25
Definition: voice.h:33
Sound * assignedToSound
Definition: voice.h:42
bool noteOn(ModelStackWithVoice *modelStack, int newNoteCodeBeforeArpeggiation, int newNoteCodeAfterArpeggiation, uint8_t velocity, uint32_t newSampleSyncLength, int32_t ticksLate, uint32_t samplesLate, bool resetEnvelopes, int fromMIDIChannel, const int16_t *mpeValues)
Definition: voice.cpp:113
uint32_t portaEnvelopePos
Definition: voice.h:56
uint32_t getPriorityRating()
Definition: voice.cpp:2875
int32_t overallOscAmplitudeLastTime
Definition: voice.h:61
int inputCharacteristics[2]
Definition: voice.h:53
bool hasReleaseStage()
Definition: voice.cpp:2860
Voice()
Definition: voice.cpp:86
int32_t filterGainLastTime
Definition: voice.h:66
Envelope envelopes[numEnvelopes]
Definition: voice.h:49
int32_t modulatorAmplitudeLastTime[numModulators]
Definition: voice.h:63
uint32_t orderSounded
Definition: voice.h:73
Voice * nextUnassigned
Definition: voice.h:77
void noteOff(ModelStackWithVoice *modelStack, bool allowReleaseStage=true)
Definition: voice.cpp:532
int32_t sourceAmplitudesLastTime[NUM_SOURCES]
Definition: voice.h:62
int32_t localExpressionSourceValuesBeforeSmoothing[NUM_EXPRESSION_DIMENSIONS]
Definition: voice.h:47
void setAsUnassigned(ModelStackWithVoice *modelStack, bool deletingSong=false)
Definition: voice.cpp:93
LFO lfo
Definition: voice.h:50
VoiceUnisonPart unisonParts[maxNumUnison]
Definition: voice.h:39
void unassignStuff()
Definition: voice.cpp:101
bool sampleZoneChanged(ModelStackWithVoice *modelStack, int s, int markerType)
Definition: voice.cpp:583
uint8_t whichExpressionSourcesFinalValueChanged
Definition: voice.h:71
uint8_t whichExpressionSourcesCurrentlySmoothing
Definition: voice.h:70
uint32_t sourceWaveIndexesLastTime[NUM_SOURCES]
Definition: voice.h:64
void expressionEventImmediate(Sound *sound, int32_t voiceLevelValue, int s)
Definition: voice.cpp:311
int32_t paramFinalValues[FIRST_GLOBAL_PARAM]
Definition: voice.h:44
bool doneFirstRender
Definition: voice.h:68
void changeNoteCode(ModelStackWithVoice *modelStack, int newNoteCodeBeforeArpeggiation, int newNoteCodeAfterArpeggiation, int newInputMIDIChannel, const int16_t *newMPEValues)
Definition: voice.cpp:325
bool previouslyIgnoredNoteOff
Definition: voice.h:69
int32_t portaEnvelopeMaxAmplitude
Definition: voice.h:57
VoiceSamplePlaybackGuide guides[NUM_SOURCES]
Definition: voice.h:40
uint32_t lastSaturationTanHWorkingValue[2]
Definition: voice.h:59
Patcher patcher
Definition: voice.h:37
FilterSet filterSets[2]
Definition: voice.h:52
void expressionEventSmooth(int32_t newValue, int s)
Definition: voice.cpp:319
void calculatePhaseIncrements(ModelStackWithVoice *modelStack)
Definition: voice.cpp:379
int32_t sourceValues[NUM_PATCH_SOURCES]
Definition: voice.h:45
int noteCodeAfterArpeggiation
Definition: voice.h:54
int32_t overrideAmplitudeEnvelopeReleaseRate
Definition: voice.h:75
bool doFastRelease(uint32_t releaseIncrement=4096)
Definition: voice.cpp:2847
void randomizeOscPhases(Sound *sound)
Definition: voice.cpp:364
bool render(ModelStackWithVoice *modelStack, int32_t *soundBuffer, int numSamples, bool soundRenderingInStereo, bool applyingPanAtVoiceLevel, uint32_t sourcesChanged, FilterSetConfig *filterSetConfig, int32_t externalPitchAdjust)
Definition: voice.cpp:641
Definition: voicesampleplaybackguide.h:29
Definition: voiceunisonpart.h:25
#define NUM_EXPRESSION_DIMENSIONS
Definition: definitions.h:919
#define numModulators
Definition: definitions.h:319
#define NUM_SOURCES
Definition: definitions.h:608
#define numEnvelopes
Definition: definitions.h:317
#define FIRST_GLOBAL_PARAM
Definition: definitions.h:430
#define NUM_PATCH_SOURCES
Definition: definitions.h:355
#define maxNumUnison
Definition: definitions.h:321