xxxxxxxxxx
37
let hh; //hihat will serve as a container that holds the sound source
let hhPat; // hihat pattern: an array of number that can be manipulated to make beats (0/1)
let hhPhrase; //hihat phrase: define how hihat is interpreted( what 0 and 1 will correspond to)
let drums; //part. will attach the phrase to the part which will serve as our transport to drive the phrase
function setup() {
createCanvas(400, 400);
hh = loadSound("samples/hh_sample.mp3", () => {
drums.loop();
});
hh.amp(0.5);
hhPat = [1, 0, 0, 1];
hhPhrase = new p5.Phrase(
"hh",
() => {
hh.play();
},
hhPat
);
drums = new p5.Part();
drums.addPhrase(hhPhrase);
}
function draw() {
background(220);
textAlign(CENTER);
text("work in progress", width / 2, 185);
text("play the sound in the editor to hear progress", 200, 200);
text("disclaimer: sound not pleasant", 200, 215);
}