Intensity setting
This commit is contained in:
+11
-3
@@ -6,11 +6,19 @@
|
||||
|
||||
class EuclideanStrategy : 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;
|
||||
|
||||
int pulses = random(1, numSteps + 1);
|
||||
// Intensity controls density.
|
||||
// Intensity 1 = ~10% density, Intensity 10 = ~100% density
|
||||
int targetPulses = (numSteps * intensity) / 10;
|
||||
if (targetPulses < 1) targetPulses = 1;
|
||||
// Add some variation (+/- 1 pulse)
|
||||
int pulses = targetPulses + random(-1, 2);
|
||||
if (pulses < 1) pulses = 1;
|
||||
if (pulses > numSteps) pulses = numSteps;
|
||||
|
||||
int offset = random(numSteps);
|
||||
|
||||
// Euclidean distribution (Bresenham)
|
||||
@@ -61,7 +69,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 {
|
||||
// Rotate sequence
|
||||
if (random(2) == 0) {
|
||||
Step last = sequence[track][numSteps - 1];
|
||||
|
||||
Reference in New Issue
Block a user