Your voice
The microphone is a synth whose sound comes in instead of being made. Ask for it, give it a voice, and listen: you are a robot, a chipmunk or a monster.
const mic = useMicrophone() // the browser asks whether the page may use the microphone
select("voice", mic, "voice") // robot, chipmunk, monster, cave, telephone, alien, whisper
dial("pitch", mic, "pitch")
dial("echo", mic, "echo")
toggle("listen", mic, "listening") // wear headphones before you switch this on
scope(mic)
meter(mic)
function draw() {
background("midnightblue")
}That is a whole program. Pick a voice, put headphones on, switch on listen and say something. The scope and the meter show your voice even while it is not heard.
Where it works
As of October 2026:
| Where | The microphone |
|---|---|
A scene run with pictures run or pyctures run, or a web page of your own | Works in Chrome, Edge, Firefox and Safari. The browser asks once whether the page may use the microphone. See Outside Circuitry |
| Circuitry's own preview, on a computer, an iPad or an iPhone | Not connected yet. The scene runs and everything else in it works, with no microphone: nothing comes in, and a recording of it is empty |
A page has to be served over https or from localhost to be given a microphone (pictures run and pyctures run are), and a page inside a frame needs allow="microphone" on the frame.
Wear headphones
Through loudspeakers the microphone hears itself, and the sound goes round and round until it howls. That is why nothing is heard until you say listen(). Recording, the scope and the meter do not need it.
const mic = useMicrophone()
mic.voice = "robot" // robot, chipmunk, monster, cave, telephone, alien, whisper, or "none"
mic.listen() // now you hear yourself, as a robot
mic.mute() // and now you do notVoices
| Voice | What it is |
|---|---|
"robot" | A machine, ringing in a metal pipe |
"chipmunk" | Small and squeaky: seven semitones higher |
"monster" | Huge and deep: seven semitones lower, with a growl |
"cave" | Far inside a cave: long echoes in a very big room |
"telephone" | Down an old phone line |
"alien" | Not from here: higher, with a slow metallic sweep |
"whisper" | Hoarse and breathy, with no pitch at all |
voiceNames() gives the list to a program (voice_names()), and "none" is your own voice. A voice that is not one of these is said in plain words: "robt" is not a voice. Did you mean "robot"?
Turn it yourself
A voice is only a handful of settings, and you can turn them yourself once it is on. A microphone has every setting a synth has, and a few words of its own:
mic.pitch = 7 // semitones up or down, -12 to 12, without getting faster or slower
mic.echo = 0.4 // and reverb, chorus, distortion, crush, cutoff, pan, volume, as on a synth
mic.ring = 1 // multiply the voice by a wave: mic.ringSpeed = 50 is how fast (the robot)
mic.comb = 0.5 // ring like a pipe at one note: mic.combTone = 110. mic.flanger sweeps it
mic.gain = 2 // turn a quiet microphone up
mic.gate = -40 // quieter than this (in dB) counts as silence. It starts at -50; "off" for noneChoosing another voice first puts back what the last one changed, so pick the voice and then turn the dials. What you set before choosing any voice stays under all of them.
Dials on a microphone
The microphone is a synth to dials too, so each of these is one line:
| Call | What it is |
|---|---|
select("voice", mic, "voice") | The voices, to choose from |
dial("pitch", mic, "pitch") | Higher or lower, from -12 to 12 semitones |
dial("echo", mic, "echo") | Any setting a synth has |
toggle("listen", mic, "listening") | A switch for hearing yourself |
scope(mic), meter(mic) | Your voice as a wave, and how loud it is |
With no microphone
A computer with no microphone, a person who says no, a page that is not allowed to ask: none of these stops your program. Every function still works, it is said once why there is no microphone, and a recording is simply empty.
mic.state is "asking" until the browser has answered, then "on", or why not: "refused", "none", "busy" or "unavailable". A function can be called when it is known:
const mic = useMicrophone()
const says = label("Asking for the microphone")
mic.whenReady().then((there) => {
says.value = there ? "Say something" : "No microphone here: " + mic.state
})stopMicrophone() lets the microphone go, and the browser's recording light goes out (stop_microphone()). It is let go by itself when the scene stops.
In Python the page has the microphone and tells your program a frame later, so mic.state is filled in the frame after the browser answered.
The voice effects on a synth
The pitch shifter, the ring modulator and the comb are not only for voices. Every synth has them, under names that do not clash with its own pitch and ring:
lead.pitchShift = 12 // an octave up, with the same length
lead.ringMod = 0.6 // bell-like and strange: lead.ringSpeed = 300
lead.comb = 0.5 // a metal pipe: lead.combTone, lead.combFeedback
lead.flanger = 0.6 // the comb, sweeping: lead.flangerRate
lead.voice = "robot" // or a whole voice at onceEight synths can use the pitch shifter or the comb at once.
Related
- Recording: record your voice, play it on the keys, save it
- Tying a control to a synth
- Every sound, synth and setting