46class ArpeggiatorSettings {
48 ArpeggiatorSettings();
52 void cloneFrom(ArpeggiatorSettings
const* other);
54 bool readCommonTagsFromFile(
Deserializer& reader,
char const* tagName,
Song* songToConvertSyncLevel);
56 bool readNonAudioTagsFromFile(
Deserializer& reader,
char const* tagName);
58 void writeCommonParamsToFile(
Serializer& writer,
Song* songToConvertSyncLevel);
60 void writeNonAudioParamsToFile(
Serializer& writer);
62 void generateNewNotePattern();
64 void updatePresetFromCurrentSettings();
66 void updateSettingsFromCurrentPreset();
68 uint32_t getPhaseIncrement(int32_t arpRate);
71 ArpPreset preset{ArpPreset::OFF};
72 ArpMode mode{ArpMode::OFF};
74 bool includeInKitArp{
true};
77 ArpOctaveMode octaveMode{ArpOctaveMode::UP};
78 ArpNoteMode noteMode{ArpNoteMode::UP};
81 uint8_t numOctaves{2};
84 uint8_t numStepRepeats{1};
87 uint8_t chordTypeIndex{0};
94 bool randomizerLock{
false};
97 ArpMpeModSource mpeVelocity{ArpMpeModSource::OFF};
100 uint32_t lastLockedNoteProbabilityParameterValue{0};
101 uint32_t lastLockedBassProbabilityParameterValue{0};
102 uint32_t lastLockedStepProbabilityParameterValue{0};
103 uint32_t lastLockedReverseProbabilityParameterValue{0};
104 uint32_t lastLockedChordProbabilityParameterValue{0};
105 uint32_t lastLockedRatchetProbabilityParameterValue{0};
106 uint32_t lastLockedSpreadVelocityParameterValue{0};
107 uint32_t lastLockedSpreadGateParameterValue{0};
108 uint32_t lastLockedSpreadOctaveParameterValue{0};
111 std::array<int8_t, RANDOMIZER_LOCK_MAX_SAVED_VALUES> lockedNoteProbabilityValues;
112 std::array<int8_t, RANDOMIZER_LOCK_MAX_SAVED_VALUES> lockedBassProbabilityValues;
113 std::array<int8_t, RANDOMIZER_LOCK_MAX_SAVED_VALUES> lockedStepProbabilityValues;
114 std::array<int8_t, RANDOMIZER_LOCK_MAX_SAVED_VALUES> lockedReverseProbabilityValues;
115 std::array<int8_t, RANDOMIZER_LOCK_MAX_SAVED_VALUES> lockedChordProbabilityValues;
116 std::array<int8_t, RANDOMIZER_LOCK_MAX_SAVED_VALUES> lockedRatchetProbabilityValues;
117 std::array<int8_t, RANDOMIZER_LOCK_MAX_SAVED_VALUES> lockedSpreadVelocityValues;
118 std::array<int8_t, RANDOMIZER_LOCK_MAX_SAVED_VALUES> lockedSpreadGateValues;
119 std::array<int8_t, RANDOMIZER_LOCK_MAX_SAVED_VALUES> lockedSpreadOctaveValues;
122 std::array<int8_t, PATTERN_MAX_BUFFER_SIZE> notePattern;
125 bool flagForceArpRestart{
false};
131 uint32_t sequenceLength{0};
132 uint32_t chordPolyphony{0};
133 uint32_t ratchetAmount{0};
134 uint32_t noteProbability{4294967295u};
135 uint32_t bassProbability{0};
136 uint32_t stepProbability{0};
137 uint32_t reverseProbability{0};
138 uint32_t chordProbability{0};
139 uint32_t ratchetProbability{0};
140 uint32_t spreadVelocity{0};
141 uint32_t spreadGate{0};
142 uint32_t spreadOctave{0};
191class ArpeggiatorBase {
194 noteCodeCurrentlyOnPostArp.fill(ARP_NOTE_NONE);
195 outputMIDIChannelForNoteCurrentlyOnPostArp.fill(0);
201 uint32_t gateThreshold, uint32_t phaseIncrement);
203 bool currentlyPlayingReversed);
205 virtual bool hasAnyInputNotesActive() = 0;
206 virtual void reset() = 0;
207 virtual ArpType getArpType() = 0;
209 bool gateCurrentlyActive =
false;
210 uint32_t gatePos = 0;
212 bool playedFirstArpeggiatedNoteYet =
false;
213 uint8_t lastVelocity = 0;
214 std::array<int16_t, ARP_MAX_INSTRUCTION_NOTES> noteCodeCurrentlyOnPostArp;
215 std::array<uint8_t, ARP_MAX_INSTRUCTION_NOTES> outputMIDIChannelForNoteCurrentlyOnPostArp;
218 uint32_t notesPlayedFromSequence = 0;
219 uint32_t randomNotesPlayedFromOctave = 0;
222 int16_t whichNoteCurrentlyOnPostArp;
223 int8_t currentOctave = 0;
224 int8_t currentDirection = 1;
225 int8_t currentOctaveDirection = 1;
228 uint32_t notesPlayedFromRhythm = 0;
229 uint32_t lastNormalNotePlayedFromRhythm = 0;
232 uint32_t notesPlayedFromLockedRandomizer = 0;
235 bool lastNormalNotePlayedFromNoteProbability =
true;
238 bool lastNormalNotePlayedFromBassProbability =
false;
241 bool lastNormalNotePlayedFromStepProbability =
false;
244 bool lastNormalNotePlayedFromReverseProbability =
false;
247 bool lastNormalNotePlayedFromChordProbability =
false;
250 int32_t stepRepeatIndex = 0;
253 uint32_t ratchetNotesIndex = 0;
254 uint32_t ratchetNotesMultiplier = 0;
255 uint32_t ratchetNotesCount = 0;
256 bool isRatcheting =
false;
259 uint32_t chordNotesCount = 0;
262 bool isPlayNoteForCurrentStep =
true;
263 bool isPlayBassForCurrentStep =
false;
264 bool isPlayRandomStepForCurrentStep =
false;
265 bool isPlayReverseForCurrentStep =
false;
266 bool isPlayChordForCurrentStep =
false;
267 bool isPlayRatchetForCurrentStep =
false;
268 int32_t spreadVelocityForCurrentStep = 0;
269 int32_t spreadGateForCurrentStep = 0;
270 int32_t spreadOctaveForCurrentStep = 0;
271 bool resetLockedRandomizerValuesNextTime =
false;
279 uint32_t maxSequenceLength, uint32_t rhythm,
bool* shouldCarryOnRhythmNote,
280 bool* shouldPlayNote,
bool* shouldPlayBassNote,
bool* shouldPlayRandomStep,
281 bool* shouldPlayReverseNote,
bool* shouldPlayChordNote);
282 void increasePatternIndexes(uint8_t numStepRepeats);
283 void increaseSequenceIndexes(uint32_t maxSequenceLength, uint32_t rhythm);
285 bool evaluateRhythm(uint32_t rhythm,
bool isRatchet);
286 bool evaluateNoteProbability(
bool isRatchet);
287 bool evaluateBassProbability(
bool isRatchet);
288 bool evaluateStepProbability(
bool isRatchet);
289 bool evaluateReverseProbability(
bool isRatchet);
290 bool evaluateChordProbability(
bool isRatchet);
291 uint32_t calculateSpreadVelocity(uint8_t velocity, int32_t spreadVelocityForCurrentStep);
295 bool getRandomProbabilityResult(uint32_t value);
296 int8_t getRandomBipolarProbabilityAmount(uint32_t value);
297 int8_t getRandomWeighted2BitsAmount(uint32_t value);