soundRecorder

 elements

Captures sound from a microphone until a cue you set in property end occurs, then records it to file after the trial (or if the experiment halts on error). Times reported by record properties startTime/endTime correspond to recording start/end—you can use these to analyze the times of recorded sounds. 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 make 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.

For each trial you define in an experiment script, you can make one or more 

soundRecorder

 objects using 

soundRecorder

Object and input them to addTrial.

For each trial you define in an experiment script, you can make one or more 

soundRecorder

 objects using 

soundRecorder

Object and input them to addTrial.

Input properties

Adjustable properties

You can allow the subject to adjust the following input properties of an object of this type during the experiment using an adjuster element. If you need to make other properties adjustable, you can copy the element type using newPbType and edit it.

position
nn_eyes
rotation
opacity

(None)

(None)

fileName
numberFile
minNumDigitsInFileName

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

fileName is a string that is name of 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>, PsychBench automatically adds a number to file name starting at 1, then incrementing to not overwrite any existing files. This means if you have multiple soundRecorder 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 (e.g. sound1.wav, sound2.wav, sound3.wav, ...). NOTE: If you set numberFile = <cd>false<cd> then the element will not add a number and will overwrite any existing file with the specified name.

minNumDigitsInFileName sets the minimum number of digits to use for auto-numbering the 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 channel sample 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 soundRecorder element waits after a trial it runs in for Psychtolbox 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.

Input properties all visual elements have

position

Input properties all adjuster elements have

adjust

Input properties all objects have

report
info

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.

fileName_r
n_file

fileName_r is a string recording the file name written to. This is the same as input property fileName except it includes the number added if numberFile = <cd>true<cd>.

n_file records the number added (numeric).