xxxxxxxxxx
46
var song;
var sliderVolume;
var sliderPan;
var sliderRate;
function preload(){
song = loadSound("YN sound for p5/P5 loop.mp3");
}
function setup() {
createCanvas(400, 50);
sliderVolume = createSlider(0, 1, 0.75, 0.01);
sliderPan = createSlider(-1, 1, 0, 0.01);
sliderRate = createSlider(-1, 2.5, 1, 0.01);
let play = createButton("PLAY");
let stop = createButton("STOP");
play.position(110,80);
stop.position(240,80);
play.mousePressed(click_play);
stop.mousePressed(click_stop);
}
function click_play(){
song.play();
}
function click_stop(){
song.stop();
}
function draw() {
background(220);
song.setVolume(sliderVolume.value());
song.pan(sliderPan.value());
song.rate(sliderRate.value());
textSize(25);
text("Vol", 10, 40);
text("Pan", 140, 40);
text("Rate", 270, 40);
}