Microphone¶
Tracks the volume and pitch of sound coming into the device microphone.
The first call to mic.start asks the user for permission to use the microphone. While the microphone is running, other sounds keep playing through the speaker.
- mic.start()¶
Start tracking input from the device microphone
function setup() mic.start() end function draw() background(40) text(string.format("%.2f Hz", mic.frequency), WIDTH/2, HEIGHT/2) end
- mic.stop()¶
Stop tracking input from the device microphone. The microphone also stops automatically when the project exits
- amplitude: number [readonly]¶
The volume of sound coming into the microphone. Silence is close to
0, and a loud, full-scale sound reaches about2Returns
0when the microphone is not running
- frequency: number [readonly]¶
The pitch of sound coming into the microphone, in hertz. Keeps its last value when the input goes quiet or has no clear pitch
Returns
0when the microphone is not running