const bluesGuitar = synth.def( (phase, env) => Math.sign(((phase * 2) % 2) - 1) * env.value);
const nothing = {};
const progression = [
chord(c4, chords.major), chord(f4, chords.major), chord(c4, chords.major), chord(c4, chords.dom7),
chord(f4, chords.major), chord(f4, chords.dom7), chord(c4, chords.major), chord(c4, chords.dom7),
chord(g4, chords.major), chord(f4, chords.major), chord(c4, chords.major), chord(g4, chords.dom7),
];
loop(() => {
progression.forEach(c => {
sleep(playChord(c, 6/8*2));
sleep(playChord(c, 6/8));
});
},{name:'chords'});
loop(() => {
progression.forEach(_ => {
scale(a, scales.blues_minor, 3);
sleep(playChord(scale(a, scales.blues_minor, 3), 6/8*pick(0.5, 1, 2, 4, 8), 6/8, 0.25));
});
},{name:'melody'});
function playChord(c, t = 6/8, interv = 6/8/8, chance = 0.95) {
[...c].sort(_ => -0.5 + Math.random()).forEach(n => (Math.random() < chance ? bluesGuitar.play(n, {amp: 0.45}) : nothing, sleep(interv)));
t -= c.length * interv;
return t;
}
function pick(...args) {
return args[Math.random() * args.length | 0];
}