xxxxxxxxxx
85
var synth = new Tone.Synth().toMaster();
Tone.Transport.bpm.value = 180;
// Passamezzo moderno
//1)I IV I V
//2)I IV I–V I
//C F C G | C F C–G C
var C_chord = ["C3", "E3", "G3", "C4"];
var F_chord = ["F2", "C3", "F3", "A3"];
var G_chord = ["G2", "D3", "G3", "B3"];
var arpeggio = new Tone.Pattern(function(time, chord) {
synth.triggerAttackRelease(chord, "8n", time);
});
arpeggio.values = F_chord;
var pianoPart = new Tone.Part(function(time, chord) {
arpeggio.values = chord;
}, [
["0:0", C_chord],
["1:0", F_chord],
["2:0", C_chord],
["3:0", G_chord],
["4:0", C_chord],
["5:0", F_chord],
["6:0", C_chord],
["7:0", G_chord],
["8:0", C_chord]
]).start();
pianoPart.loop = true;
pianoPart.loopEnd = "4m";
function keyPressed(){
if(key == '1'){
//cycles upward
arpeggio.pattern = "up";
}
else if(key == '2'){
//cycles downward
arpeggio.pattern = "down";
}
else if(key == '3'){
//cycles up then and down
arpeggio.pattern = "upDown";
}
else if(key == '4'){
//cycles down then up
arpeggio.pattern = "downUp";
}
else if(key =="5"){
//jump up two and down one
arpeggio.pattern = "alternateUp";
}
else if(key =="6"){
//jump down two and up one
arpeggio.pattern = "alternateDown";
}
else if(key == '7'){
//randomly select an index
arpeggio.pattern = "random";
}
else if(key =="8"){
//randomly moves one index away from the current position
arpeggio.pattern = "randomWalk";
}
else if(key =="9"){
//randomly select an index without repeating until all values have been chosen
arpeggio.pattern = "randomOnce";
}
}
function setup() {
Tone.Transport.start();
pianoPart.start();
arpeggio.start();
}
function draw() {
}