Microphone

sound Microphone

This manager handles the recording of audio signal.

Constructor

new Microphone(options)

Source:
Parameters:
Name Type Description
options Object
Properties
Name Type Attributes Default Description
win module:core.Window

the associated Window

name String

the name used when logging messages from this stimulus

format string <optional>
'audio/webm;codecs=opus'

the format for the audio file

sampleRateHz number <optional>
48000

the audio sampling rate, in Hz

clock Clock <optional>

an optional clock

autoLog boolean <optional>
false

whether to log

Extends

  • PsychObject

Methods

(protected) _onChange()

Source:

Callback for changes to the recording settings.

Changes to the settings require the recording to stop and be re-started.

(async, protected) _prepareRecording()

Source:

Prepare the recording.

download(filename)

Source:

Offer the audio recording to the participant as a sound file to download.

Parameters:
Name Type Default Description
filename string audio.webm

the filename

flush() → {Promise}

Source:

Submit a request to flush the recording.

Returns:

promise fulfilled when the data has actually been made available

Type
Promise

(async) getRecording(tag, flushopt)

Source:

Get the current audio recording as an AudioClip in the given format.

Parameters:
Name Type Attributes Default Description
tag string

an optional tag for the audio clip

flush boolean <optional>
false

whether or not to first flush the recording

pause() → {Promise}

Source:

Submit a request to pause the recording.

Returns:

promise fulfilled when the recording actually paused

Type
Promise

resume(options) → {Promise}

Source:

Submit a request to resume the recording.

resume has no effect if the recording was not previously paused.

Parameters:
Name Type Description
options Object
Properties
Name Type Attributes Default Description
clear boolean <optional>
false

whether or not to empty the audio buffer before resuming the recording

Returns:

promise fulfilled when the recording actually resumed

Type
Promise

start() → {Promise}

Source:

Submit a request to start the recording.

Note that it typically takes 50ms-200ms for the recording to actually starts once a request to start has been submitted.

Returns:

promise fulfilled when the recording actually started

Type
Promise

stop(options) → {Promise}

Source:

Submit a request to stop the recording.

Parameters:
Name Type Description
options Object
Properties
Name Type Attributes Description
filename string <optional>

the name of the file to which the audio recording will be saved

Returns:

promise fulfilled when the recording actually stopped, and the recorded data was made available

Type
Promise

(async) upload(tag)

Source:

Upload the audio recording to the pavlovia server.

Parameters:
Name Type Description
tag string

an optional tag for the audio file