xxxxxxxxxx
30
let mySound;
let threshold = 10;
function preload() {
soundFormats('mp3', 'ogg');
mySound = loadSound('zouzounisma.mp3');
}
function setup() {
let cnv = createCanvas(windowWidth, windowHeight);
cnv.mousePressed(canvasPressed);
background(220);
text('tap here to play', 10, 20);
setShakeThreshold(threshold);
}
function draw(){
mySound.setVolume(accelerationX);
console.log(accelerationX);
}
function canvasPressed() {
// playing a sound file on a user gesture
// is equivalent to `userStartAudio()`
mySound.loop();
}
function deviceShaken() {
background(accelerationX*100,accelerationY*100,accelerationZ*100);
}