Hi!
I’m trying to figure out a way to have two separate sound files loaded and playing at the same time connect to two separate amplitude objects. At the moment all the sounds just go straight to the first amplitude object declared and the p5.Sound connect function that should be able to link them separately doesn’t have enough documentation or examples.
Do any of you have experience figuring this stuff out?
Here is a simplified version of my code:
let sound1;
let sound2;
var sound1_Amp;
var sound2_Amp;
var sound1_Vol;
var sound2_Vol;
function preload(){
sound1 = loadSound ('assets/sound-1.mp3');
sound2 = loadSound('assets/sound-2.mp3');
}
function setup() {
sound1_Amp = new p5.Amplitude();
sound1.connect(sound1_Amp);
sound2_Amp = new p5.Amplitude();
sound2.connect(sound2_Amp);
createCanvas(windowWidth, windowHeight);
}
function draw() {
background(0);
sound1_Vol = sound1_Amp.getLevel();
sound2_Vol = sound2_Amp.getLevel();
fill(255, 0, 0);
ellipse(100, 100, 50 + sound1_Vol*500);
fill(0, 255,0);
ellipse(400, 100, 50 + sound2_Vol*500);
}
Thanks for reading, any help would be greatly appreciated!