Interactions with the microphone

To be able to interact with the microphone, we need to follow this steps (or similars):

  1. First of all we will create a variable (dedicated to the mic input), e.g. mic.
  2. Then, in the function setup() we have to assing, to this variable, the value of the mic input. We will do it writing this line of code: mic = new p5.AudioIn();.
  3. The next thing that we will do will be start the audio input, writing mic.start();.
  4. The last thing that we'll do will be create a variable in function draw(), map the mic input and assign it the mapped value, we do it because the mic input is a value that varies between 0 and 1, and we almost never need a value between 0 and 1, so we map it writing var h = map();.

See the Pen vdobGR by Dídac Jaquet (@didacjaquet) on CodePen.