xxxxxxxxxx
56
/*
https://mobcup.net/ringtone/somewhere-july-95sznr70
https://ia600306.us.archive.org/14/items/Yiruma-RiverFlowsInYou/Yiruma-RiverFlowsInYou.mp3
https://ia800504.us.archive.org/15/items/KissTheRain_Yiruma/KissTheRain-yiruma.mp3
*/
var sound1;
var sound2;
var sound3;
function preload() {
sound = loadSound("sound.mp3");
sound2 = loadSound("sound2.mp3");
sound3 = loadSound("sound3.mp3");
}
function setup() {
createCanvas(400, 400);
amplitude = new p5.Amplitude();
noStroke();
createP("press number1-3 to change the song");
}
function draw() {
background(0.5);
fill(255, random(255), random(255));
let level = amplitude.getLevel();
let r = map(level, 0, 1, 0, 400);
ellipse(width / 2, height / 2, r, r);
}
function keyPressed() {
if (keyCode === 49) {
if (sound.isPlaying()) {
sound.pause();
} else {
sound.play();
}
}
if (keyCode === 50) {
if (sound2.isPlaying()) {
sound2.pause();
} else {
sound2.play();
}
}
if (keyCode === 51) {
if (sound3.isPlaying()) {
sound3.pause();
} else {
sound3.play();
}
}
}