More harmony through chord notes
This commit is contained in:
+14
-5
@@ -6,7 +6,7 @@
|
||||
|
||||
class DroneStrategy : 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;
|
||||
|
||||
@@ -30,8 +30,12 @@ public:
|
||||
// Pick a note from the scale
|
||||
// Prefer lower octaves for drones (3 and 4)
|
||||
int octave = 3 + random(2);
|
||||
int noteIndex = random(numScaleNotes);
|
||||
int note = 12 * octave + scaleNotes[noteIndex];
|
||||
int note;
|
||||
if (numChordNotes > 0) {
|
||||
note = 12 * octave + chordNotes[random(numChordNotes)];
|
||||
} else {
|
||||
note = 12 * octave + scaleNotes[random(numScaleNotes)];
|
||||
}
|
||||
|
||||
for (int k = 0; k < duration; k++) {
|
||||
int stepIndex = currentStep + k;
|
||||
@@ -65,7 +69,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 by shifting the pitch of a random segment
|
||||
int s = random(numSteps);
|
||||
if (sequence[track][s].note != -1) {
|
||||
@@ -83,7 +87,12 @@ public:
|
||||
|
||||
// Pick a new note
|
||||
int octave = 3 + random(2);
|
||||
int newNote = 12 * octave + scaleNotes[random(numScaleNotes)];
|
||||
int newNote;
|
||||
if (numChordNotes > 0) {
|
||||
newNote = 12 * octave + chordNotes[random(numChordNotes)];
|
||||
} else {
|
||||
newNote = 12 * octave + scaleNotes[random(numScaleNotes)];
|
||||
}
|
||||
|
||||
for (int i = start; i <= end; i++) {
|
||||
sequence[track][i].note = newNote;
|
||||
|
||||
Reference in New Issue
Block a user