More harmony through chord notes
This commit is contained in:
+13
-9
@@ -6,9 +6,13 @@
|
||||
|
||||
class WaveStrategy : 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* sourceNotes = (numChordNotes > 0) ? chordNotes : scaleNotes;
|
||||
int sourceNoteCount = (numChordNotes > 0) ? numChordNotes : numScaleNotes;
|
||||
|
||||
if (sourceNoteCount == 0) return;
|
||||
|
||||
// Wave parameters
|
||||
// Frequency: How many cycles per sequence
|
||||
@@ -19,8 +23,8 @@ public:
|
||||
int type = random(3);
|
||||
|
||||
// Center pitch (note index)
|
||||
int centerIdx = numScaleNotes * 2; // Middle of 4 octaves roughly
|
||||
int amp = numScaleNotes + (intensity); // Amplitude in scale degrees
|
||||
int centerIdx = sourceNoteCount * 2; // Middle of 4 octaves roughly
|
||||
int amp = sourceNoteCount + (intensity); // Amplitude in scale degrees
|
||||
|
||||
for (int i = 0; i < numSteps; i++) {
|
||||
float t = (float)i / (float)numSteps; // 0.0 to 1.0
|
||||
@@ -43,17 +47,17 @@ public:
|
||||
int totalIdx = centerIdx + noteIdxOffset;
|
||||
|
||||
// Normalize totalIdx
|
||||
while(totalIdx < 0) totalIdx += numScaleNotes;
|
||||
while(totalIdx < 0) totalIdx += sourceNoteCount;
|
||||
|
||||
int octave = 2 + (totalIdx / numScaleNotes);
|
||||
int scaleIdx = totalIdx % numScaleNotes;
|
||||
int octave = 2 + (totalIdx / sourceNoteCount);
|
||||
int noteIdx = totalIdx % sourceNoteCount;
|
||||
|
||||
if (octave < 0) octave = 0;
|
||||
if (octave > 8) octave = 8;
|
||||
|
||||
// Rhythmic density based on intensity
|
||||
if (random(100) < (40 + intensity * 5)) {
|
||||
sequence[track][i].note = 12 * octave + scaleNotes[scaleIdx];
|
||||
sequence[track][i].note = 12 * octave + sourceNotes[noteIdx];
|
||||
sequence[track][i].accent = (val > 0.8f); // Accent peaks
|
||||
sequence[track][i].tie = false;
|
||||
} else {
|
||||
@@ -77,7 +81,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 {
|
||||
// Phase shift the sequence
|
||||
int shift = random(1, 4);
|
||||
Step temp[NUM_STEPS];
|
||||
|
||||
Reference in New Issue
Block a user