Recording

recordSound records the microphone. It gives you the recording at once and does not wait: your program carries on, and the take fills up behind it.

const mic = useMicrophone()
const says = label("Press record and say something")
let take = null

button("record", () => {
  take = recordSound(3)                // three seconds of the microphone, starting now
  says.value = "Recording"
  take.onDone(() => { says.value = take.seconds ? "Recorded: press play" : "Nothing was recorded" })
})
button("play", () => {
  if (take) take.play()
})

function draw() {
  background("midnightblue")
}

That is a whole program. Recording does not need listen(), so there is nothing to howl and no need for headphones.

The microphone is not connected in Circuitry's own preview yet, so there a recording of it is empty: see where the microphone works. Recording what you play needs no microphone.

A take is a sample

So everything a sample does it does, even while it is still recording:

take.play()                       // as you said it
take.play("E4")                   // higher and faster: middle C is its own pitch
take.reverse = true               // backwards
take.loop = true                  // round and round while its note is held
take.voice = "monster"            // any voice, afterwards
console.log(take.done, take.seconds)    // is it over, and how long it is
  • What is recorded is your plain voice, whether or not you are listening. The take is then given the voice the microphone has, so it plays back the way the microphone sounds, and you can change your mind afterwards: take.voice = "none" is you, and take.soundLike(mic) is the microphone as it is set now (take.sound_like(mic)).
  • mic.record(3) is the same as recordSound(3).
  • One recording is made at a time: starting another ends the one before, which keeps what it had.
  • recordSound(3, { effects: true }) records the voice after its effects instead of before (effects=True). That only works while you are listening.

Until you say stop

let take = null

function onMouseDown() {
  if (take && take.recording) return stopRecording()
  take = startRecording()           // it stops by itself after 30 seconds
  take.onDone(() => take.play())
}

startRecording({ max: 60 }) gives it longer, up to 120 seconds (start_recording(max=60)).

When it is over

take.onDone(fn) calls your function when the recording is over (take.on_done(fn)). take.done is true from then on, and take.seconds is how long it is: 0 when there was no microphone.

In Python the page makes the recording and tells your program with the next frame, so take.done and take.seconds change the frame after the recording ended.

A word on the keys

A recording plays at any pitch, so a word becomes an instrument. Middle C is the word as you said it; higher keys are higher and faster, and several keys make a chord of you.

const mic = useMicrophone()
let word = makeSynth("bell")           // what the keys play until a word is recorded

button("record", () => {
  const take = mic.record(1.5)         // a second and a half, starting now
  take.onDone(() => { if (take.seconds) word = take })
})

// The keys play whatever word is now.
keyboard({
  noteOn: (note, loud) => word.noteOn(note, loud),
  noteOff: (note) => word.noteOff(note),
  notes: () => word.notes(),
}, { octave: 4 })

function draw() {
  background("darkslategray")
}

With no microphone the keys go on playing the bell.

Recording what you play

recordOutput records everything the program plays, in stereo, and needs no microphone. lead.record(4) records one synth alone.

let tune = null

function onMouseDown() {
  tune = recordOutput(3)            // everything that is played for the next three seconds
  playNotes("C4 E4 G4 C5", 0.25)
  tune.onDone(() => tune.play("C3"))      // then the same tune an octave lower, and slower
}

Saving

saveSound makes a WAV file from a recording or a sample. Asked for while the recording is still being made, it saves as soon as it is over.

const tune = recordOutput(2)
playNotes("C4 E4 G4 C5", 0.25)
saveSound(tune, "my-tune.wav")

Where the file goes, as of October 2026:

Where the program runsWhere the file goes
A web page of your own, or pictures runThe browser downloads it
pyctures runIt is written beside your program
Circuitry's own previewNot connected yet: nothing is saved

How long

A recording can be up to 120 seconds. With no length it stops by itself after 30 seconds, or after max.