hydra-synth/hydra

Pass midi values into p5 Draw function

staus opened this issue · 2 comments

staus commented

Maybe I'm doing something wrong, but it doesn't seem like it's possible to use midi controllers inside the draw function of p5. I've tried a bunch of things, but none of it seems to work

Writing the cc() inside the draw call

p5.draw = () => {
  p5.background(0, 0, 0, 0)
  p5.torus(180, cc(0).range(10,80) )
}

Passing it in

radius = cc(0).range(10,80) 
p5.draw = (r = radius) => {
  p5.background(0, 0, 0, 0)
  p5.torus(180, r )
}

Hydra doesn't have any pre-defined functions for MIDI such as cc as you're writing there. If there's a library you're trying to use please clarify! You can also look here for a basic WebMIDI setup: https://github.com/ojack/hydra/blob/master/docs/midi.md

I think cc is an array (if you follow this guide) so you need to use it such as p5.background(cc[8] * 256) (note that cc ranges from 0 to 1).

I close the issue but if the problem persists feel free to reopen :)