More harmony through chord notes

This commit is contained in:
Dejvino
2026-03-10 21:58:03 +01:00
parent f34f960358
commit aa51e1e95a
13 changed files with 269 additions and 242 deletions
+11 -4
View File
@@ -6,16 +6,23 @@
class LuckyStrategy : public MelodyStrategy {
public:
void generate(Step (*sequence)[NUM_STEPS], int track, int numSteps, int* scaleNotes, int numScaleNotes, int seed, int intensity) override {
void generate(Step (*sequence)[NUM_STEPS], int track, int numSteps, int* scaleNotes, int numScaleNotes, int* chordNotes, int numChordNotes, int seed, int intensity) override {
randomSeed(seed);
if (numScaleNotes == 0) return;
int noteChance = intensity * 9; // 10% to 90%
int accentChance = intensity * 6; // 6% to 60%
for (int i = 0; i < numSteps; i++) {
int octave = random(3) + 3; // 3, 4, 5 (Base is 4)
sequence[track][i].note = (random(100) < noteChance) ? (12 * octave + scaleNotes[random(numScaleNotes)]) : -1;
int note = -1;
if (random(100) < noteChance) {
if (numChordNotes > 0) {
note = 12 * octave + chordNotes[random(numChordNotes)];
} else if (numScaleNotes > 0) {
note = 12 * octave + scaleNotes[random(numScaleNotes)];
}
}
sequence[track][i].note = note;
sequence[track][i].accent = (random(100) < accentChance);
sequence[track][i].tie = (random(100) < 20);
}
@@ -37,7 +44,7 @@ public:
sortArray(scaleNotes, numScaleNotes);
}
void mutate(Step (*sequence)[NUM_STEPS], int track, int numSteps, int* scaleNotes, int numScaleNotes, int intensity) override {
void mutate(Step (*sequence)[NUM_STEPS], int track, int numSteps, int* scaleNotes, int numScaleNotes, int* chordNotes, int numChordNotes, int intensity) override {
// Mutate 1 or 2 steps
int count = random(1, 3);
for (int i = 0; i < count; i++) {