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
+16 -4
View File
@@ -6,7 +6,7 @@
class EuclideanStrategy : 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;
@@ -42,7 +42,13 @@ public:
if (pattern[i]) {
int octave = random(3) + 3; // 3, 4, 5
sequence[track][stepIndex].note = 12 * octave + scaleNotes[random(numScaleNotes)];
int note;
if (numChordNotes > 0) {
note = 12 * octave + chordNotes[random(numChordNotes)];
} else {
note = 12 * octave + scaleNotes[random(numScaleNotes)];
}
sequence[track][stepIndex].note = note;
sequence[track][stepIndex].accent = (random(100) < 30);
sequence[track][stepIndex].tie = (random(100) < 10);
} else {
@@ -69,7 +75,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 {
// Rotate sequence
if (random(2) == 0) {
Step last = sequence[track][numSteps - 1];
@@ -82,7 +88,13 @@ public:
int s = random(numSteps);
if (sequence[track][s].note != -1) {
int octave = random(3) + 3;
sequence[track][s].note = 12 * octave + scaleNotes[random(numScaleNotes)];
int note;
if (numChordNotes > 0) {
note = 12 * octave + chordNotes[random(numChordNotes)];
} else {
note = 12 * octave + scaleNotes[random(numScaleNotes)];
}
sequence[track][s].note = note;
}
}
}