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
+6 -4
View File
@@ -6,7 +6,7 @@
class MarkovStrategy : 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;
@@ -32,8 +32,10 @@ public:
int currentIdx = random(numScaleNotes);
for (int i = 0; i < numSteps; i++) {
// 20% chance of rest
if (random(100) < 20) {
// Intensity 1 = 60% rest, Intensity 10 = 0% rest
int restChance = 60 - (intensity * 6);
if (restChance < 0) restChance = 0;
if (random(100) < restChance) {
sequence[track][i].note = -1;
sequence[track][i].accent = false;
sequence[track][i].tie = false;
@@ -85,7 +87,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 {
// Drift mutation: pick a note and move it stepwise in the scale
int s = random(numSteps);
if (sequence[track][s].note != -1) {