Intensity setting
This commit is contained in:
+11
-6
@@ -6,7 +6,7 @@
|
||||
|
||||
class ArpStrategy : 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;
|
||||
|
||||
@@ -51,8 +51,10 @@ public:
|
||||
}
|
||||
|
||||
for (int i = 0; i < arpLength; i++) {
|
||||
// Chance of rest (15%)
|
||||
if (random(100) < 15) {
|
||||
// Use intensity to control density (gaps)
|
||||
// Intensity 10 (max) = 5% rest chance. Intensity 1 (min) = 50% rest chance.
|
||||
int restChance = 55 - (intensity * 5);
|
||||
if (random(100) < restChance) {
|
||||
arpPattern[i].note = -1;
|
||||
arpPattern[i].accent = false;
|
||||
arpPattern[i].tie = false;
|
||||
@@ -60,10 +62,13 @@ public:
|
||||
int octaveOffset = currentIndex / subsetSize;
|
||||
int noteIndex = currentIndex % subsetSize;
|
||||
int octave = baseOctave + octaveOffset;
|
||||
|
||||
|
||||
// Use intensity to control note length (ties)
|
||||
// Intensity 10 (max) = 4% tie chance. Intensity 1 (min) = 40% tie chance.
|
||||
int tieChance = 44 - (intensity * 4);
|
||||
arpPattern[i].note = 12 * octave + subset[noteIndex];
|
||||
arpPattern[i].accent = (i % 4 == 0); // Accent on beat
|
||||
arpPattern[i].tie = false;
|
||||
arpPattern[i].tie = (random(100) < tieChance);
|
||||
}
|
||||
|
||||
if (mode == 0) { // Up
|
||||
@@ -106,7 +111,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 {
|
||||
// Swap two notes
|
||||
int s1 = random(numSteps);
|
||||
int s2 = random(numSteps);
|
||||
|
||||
Reference in New Issue
Block a user