soundRecorder

 element objects

Captures sound from a microphone, then records it to file after the trial. Properties start/end set when recording starts and ends, and times reported in record properties startTime/endTime correspond to recording start/end—you can use these to analyze the times of recorded sounds relative to other things in the trial/experiment. Set recording volume in your system sound settings.

This uses the high-precision PortAudio driver in Psychtoolbox. A system can have multiple internal sound “devices”. If you want to change which sound device to use for recording or other parameters, you can use pb_prefs -> microphone tab. Or to change for only the current experiment, you can add an object of type microphone and set its properties. See help text for the Psychtoolbox function InitializePsychSound and generally the Psychtoolbox website and PsychPortAudio documentation for technical notes on PortAudio with different operating systems and hardware.

▸ Object ends on its own?

"Ends on its own" means ends automatically at that point. If an element can end on its own, you don't need to set end conditions for it in property end (unless you want it to maybe end earlier).

No—runs until any condition you set in property end.

Input properties
Record properties
soundRecorder
elements (see below)

fileName
numberFile
minNumDigitsInFileName
bitDepth
bitRate
reportTimeout

All visual elements
position

All adjuster elements have
adjust

All elements
start
end

startBuffer
endBuffer

vary
staircase

All objects
report
info

fileName
numberFile
minNumDigitsInFileName

No default: fileName
Default: numberFile = automatically number files
Default: minNumDigitsInFileName = 1

fileName is a string setting name for the sound file to write. If you include a path, it will save there, and make the folder if it doesn't exist. If you don't, it will save in the MATLAB current folder. Specify file format by the extension you give the file name. The file can be any format MATLAB audiowrite understands (e.g. .wav, .mp4, etc.).

numberFile = <cd>true<cd>/<cd>false<cd>: If = <cd>true<cd> (default), the sound recorder adds a number to file name starting at 1 and incrementing as needed to not overwrite any existing files. This means if you have multiple sound recorder elements in an experiment, you can set fileName the same for all of them (e.g. sound.wav) and they will write different files numbered in the order they run in (e.g. sound1.wav, sound2.wav, sound3.wav, ...). NOTE: If you set numberFile = <cd>false<cd> then the sound recorder will not add a number and will overwrite any existing file.

minNumDigitsInFileName sets the minimum number of digits to use for numbering files. e.g. 3 → sound001.wav, sound002.wav, sound003.wav, ...

See also record properties fileName_r, n_file below.

bitDepth
bitRate

Default: bitDepth = 24
Default: bitRate = 256

For a .wav or .flac file, you can optionally specify number of bits for each sample channel in bitDepth.

For a .mp4 or .m4a file, you can optionally specify bit rate to compress at in bitRate.

reportTimeout

Default: 0.5 sec

A sound recorder waits after a trial it runs in for Psychtoolbox PortAudio to report sound input start/end time. If you see a warning that the report was not received and recorded start/end time is approximate, you can increase maximum time to wait for the report here (sec). However, PsychBench cannot prepare or start the next trial while waiting, so set this minimally.

Alternatively, 0 = don't wait and disable the warning that report was not received. This can be useful if you are getting the warning in an experiment where timing doesn't matter.

Adjustable properties

You can vary or allow the subject to adjust the following properties of an object of this type when it's running. If you need to make other properties adjustable, you can edit the element type code—see Element Type Programming Manual.

Adjustable properties

Adjustable properties

position
nn_eyes
rotation
colorMask
alpha
intensity
contrastMult
drawCodeVars

(None)

(None)

Input properties
Record properties

PsychBench uses record properties to record information during experiments. You can't set record properties but you can see them in experiment results using input property report.

soundRecorder
elements (see below)

fileName_r
n_file

All elements
startTime
endTime
duration
n_startFrame
n_endFrame
startLatencyBufferable
endLatencyBufferable

fileName_r
n_file

fileName_r is a string recording name of the file written. This includes number added if numberFile = <cd>true<cd>.

n_file records the number added (numeric) if numberFile = <cd>true<cd>.