37 ~Voice() { setAsUnassigned(
nullptr); }
41 std::array<VoiceUnisonPart, kMaxNumVoicesUnison> unisonParts;
45 std::array<VoiceSamplePlaybackGuide, kNumSources> guides;
56 std::array<int32_t, kNumPatchSources> sourceValues;
58 std::bitset<kNumExpressionDimensions> expressionSourcesCurrentlySmoothing;
59 std::bitset<kNumExpressionDimensions> expressionSourcesFinalValueChanged;
60 std::array<int32_t, kNumExpressionDimensions> localExpressionSourceValuesBeforeSmoothing;
62 std::array<Envelope, kNumEnvelopes> envelopes;
69 std::array<int32_t, 2> inputCharacteristics;
70 int32_t noteCodeAfterArpeggiation;
72 uint32_t portaEnvelopePos;
73 int32_t portaEnvelopeMaxAmplitude;
75 std::array<uint32_t, 2> lastSaturationTanHWorkingValue;
77 int32_t overallOscAmplitudeLastTime;
78 std::array<int32_t, kNumSources> sourceAmplitudesLastTime;
79 std::array<int32_t, kNumModulators> modulatorAmplitudeLastTime;
80 std::array<uint32_t, kNumSources> sourceWaveIndexesLastTime;
82 int32_t filterGainLastTime;
84 bool previouslyIgnoredNoteOff;
86 uint32_t orderSounded;
88 int32_t overrideAmplitudeEnvelopeReleaseRate;
90 bool justCreated{
false};
95 bool soundRenderingInStereo,
bool applyingPanAtVoiceLevel, uint32_t sourcesChanged,
bool doLPF,
96 bool doHPF, int32_t externalPitchAdjust);
101 int32_t newNoteCodeAfterArpeggiation, uint8_t velocity, uint32_t newSampleSyncLength, int32_t ticksLate,
102 uint32_t samplesLate,
bool resetEnvelopes, int32_t fromMIDIChannel,
const int16_t* mpeValues);
105 void randomizeOscPhases(
const Sound& sound);
107 int32_t newNoteCodeAfterArpeggiation, int32_t newInputMIDIChannel,
const int16_t* newMPEValues);
108 bool hasReleaseStage();
109 void unassignStuff(
bool deletingSong);
110 [[nodiscard]] uint32_t getPriorityRating()
const;
111 void expressionEventImmediate(
const Sound& sound, int32_t voiceLevelValue, int32_t s);
112 void expressionEventSmooth(int32_t newValue, int32_t s);
122 bool forceNormalRelease();
124 bool speedUpRelease();
125 bool shouldBeDeleted() {
return delete_this_voice_; }
128 [[nodiscard]] std::strong_ordering operator<=>(
const Voice& other)
const {
129 return this->getPriorityRating() <=> other.getPriorityRating();
135 bool delete_this_voice_{
false};
137 void renderBasicSource(Sound& sound, ParamManagerForTimeline* paramManager, int32_t s, int32_t* oscBuffer,
138 int32_t numSamples,
bool stereoBuffer, int32_t sourceAmplitude,
139 bool* unisonPartBecameInactive, int32_t overallPitchAdjust,
bool doOscSync,
140 uint32_t* oscSyncPos, uint32_t* oscSyncPhaseIncrements, int32_t amplitudeIncrement,
141 uint32_t* getPhaseIncrements,
bool getOutAfterPhaseIncrements, int32_t waveIndexIncrement);
142 static bool adjustPitch(uint32_t& phaseIncrement, int32_t adjustment);
144 void renderSineWaveWithFeedback(int32_t* thisSample, int32_t numSamples, uint32_t* phase, int32_t amplitude,
145 uint32_t phaseIncrement, int32_t feedbackAmount, int32_t* lastFeedbackValue,
146 bool add, int32_t amplitudeIncrement);
147 void renderFMWithFeedback(int32_t* thisSample, int32_t numSamples, int32_t* fmBuffer, uint32_t* phase,
148 int32_t amplitude, uint32_t phaseIncrement, int32_t feedbackAmount,
149 int32_t* lastFeedbackValue, int32_t amplitudeIncrement);
150 void renderFMWithFeedbackAdd(int32_t* thisSample, int32_t numSamples, int32_t* fmBuffer, uint32_t* phase,
151 int32_t amplitude, uint32_t phaseIncrement, int32_t feedbackAmount,
152 int32_t* lastFeedbackValue, int32_t amplitudeIncrement);
153 bool areAllUnisonPartsInactive(ModelStackWithSoundFlags& modelStack)
const;
154 void setupPorta(
const Sound& sound);
155 int32_t combineExpressionValues(
const Sound& sound, int32_t expressionDimension)
const;
156 void makeUnisonPartsInactive(
const Sound& sound, int32_t source_index);
157 void calculatePhaseIncrementForSource(Sound& sound, int32_t source_index);
158 void calculatePhaseIncrementForFmMod(Sound& sound, int32_t mod_index);