hydra-synth / hydra

Livecoding networked visuals in the browser
https://hydra.ojack.xyz
GNU Affero General Public License v3.0
2.16k stars 261 forks source link

question about p5.sound.js #134

Closed rekombination closed 2 years ago

rekombination commented 3 years ago

first of all, thank you for the great work!

i've a question rather than a issue. is it possible to use the p5.sound.js library inside hydra? i've seen that the library is already included in the node modules. i also played a bit with the p5 integration which worked for me.. (thanks for the example) however i couldn't find a way to use the p5.sound library.

if it should be possible how would this example look like to use it in hydra?

let mic;

 function setup(){
  let cnv = createCanvas(windowWidth, windowHeight);
  cnv.mousePressed(userStartAudio);
  textAlign(CENTER);
  mic = new p5.AudioIn();
  mic.start();
}

function draw(){
  background(0);
  fill(255);
  text('tap to start', width/2, 20);

  micLevel = mic.getLevel();
  let y = height - micLevel * height;
  ellipse(width/2, y, 100, 100);
}

it would be great if someone could give me a hint.

ojack commented 2 years ago

hmmm, I think p5.sound is an extra module that is not included in the core p5 library. I would like to add a "loadScript" function that lets you include an external script.

ojack commented 2 years ago

loadScript is now added --- check the readme for details