Intensity setting

This commit is contained in:
Dejvino
2026-02-22 22:25:17 +01:00
parent e6a4711861
commit 33c6329f0b
13 changed files with 182 additions and 40 deletions
+11 -6
View File
@@ -6,7 +6,7 @@
class ArpStrategy : public MelodyStrategy {
public:
void generate(Step (*sequence)[NUM_STEPS], int track, int numSteps, int* scaleNotes, int numScaleNotes, int seed) override {
void generate(Step (*sequence)[NUM_STEPS], int track, int numSteps, int* scaleNotes, int numScaleNotes, int seed, int intensity) override {
randomSeed(seed);
if (numScaleNotes == 0) return;
@@ -51,8 +51,10 @@ public:
}
for (int i = 0; i < arpLength; i++) {
// Chance of rest (15%)
if (random(100) < 15) {
// Use intensity to control density (gaps)
// Intensity 10 (max) = 5% rest chance. Intensity 1 (min) = 50% rest chance.
int restChance = 55 - (intensity * 5);
if (random(100) < restChance) {
arpPattern[i].note = -1;
arpPattern[i].accent = false;
arpPattern[i].tie = false;
@@ -60,10 +62,13 @@ public:
int octaveOffset = currentIndex / subsetSize;
int noteIndex = currentIndex % subsetSize;
int octave = baseOctave + octaveOffset;
// Use intensity to control note length (ties)
// Intensity 10 (max) = 4% tie chance. Intensity 1 (min) = 40% tie chance.
int tieChance = 44 - (intensity * 4);
arpPattern[i].note = 12 * octave + subset[noteIndex];
arpPattern[i].accent = (i % 4 == 0); // Accent on beat
arpPattern[i].tie = false;
arpPattern[i].tie = (random(100) < tieChance);
}
if (mode == 0) { // Up
@@ -106,7 +111,7 @@ public:
sortArray(scaleNotes, numScaleNotes);
}
void mutate(Step (*sequence)[NUM_STEPS], int track, int numSteps, int* scaleNotes, int numScaleNotes) override {
void mutate(Step (*sequence)[NUM_STEPS], int track, int numSteps, int* scaleNotes, int numScaleNotes, int intensity) override {
// Swap two notes
int s1 = random(numSteps);
int s2 = random(numSteps);