speaker device object

A speaker object is optional. You only need to add one if you want to change a property from default. Note you can also change the default values themselves using pb_prefs at the MATLAB command line, which may be more convenient.

An object of type speaker represents the high-precision PortAudio driver Psychtoolbox uses to play sound. Most commonly if you want one, you're using a sound element. An experiment can only have one speaker object. You can add columns setting properties for it in the optional table for objects not specific to trial (experiment, device, staircase objects). [Or in the coding method: Make a speaker object outside trials using function speakerObject, set properties, and input it to addToExperiment.]

See help text for Psychtoolbox functions InitializePsychSound and generally the Psychtoolbox website for technical notes on PortAudio with different operating systems and hardware.

Input properties
Record properties
speaker objects

n_device
numChannels

sampleRate
priority
bufferSize
latency
latencyBias

All objects
report
info

n_device

Default, changeable in pb_prefs: system default sound output device

A system can have multiple internal sound output “devices”. n_device is an integer setting device to use (0, 1, 2, …). See also record property n_device_r below.

You can use Psychtoolbox PsychPortAudio('GetDevices') to get a struct of available devices—n_device corresponds to numbers in field DeviceIndex. Devices with field NrOutputChannels > 0 are output devices. Type help InitializePsychSound for more information from Psychtoolbox.

numChannels

Default, changeable in pb_prefs: 2 = stereo

Number of channels to use. 1 = mono, 2 = stereo, etc. Generally this must be ≥ number of channels in sound files/data to play.

sampleRate

Default, changeable in pb_prefs: device default sample rate

Sample rate for the sound device to use (Hz). Psychtoolbox PortAudio is designed so that parameters like this need to match to the sound files/data you play to reduce resource usage for best timing performance. Different internal sound devices can use different sample rates as well as have different default sample rates. You can change the sound device in n_device above, or change its sample rate in sampleRate here. If you set a sample rate the current device cannot use, Psychtoolbox will give an error. Common rates are 44,100 and 48,000 Hz. See also record property sampleRate_r below.

priority
bufferSize
latency
latencyBias

Default, changeable in pb_prefs: priority = medium
Default, changeable in pb_prefs: bufferSize = Psychtoolbox automatic
Default, changeable in pb_prefs: latency = Psychtoolbox automatic
Default, changeable in pb_prefs: latencyBias = 0 sec

These properties set tradeoffs between sound timing precision (low latency) and compatibility. Note if sound output is crackly on your system, try setting latency.

priority corresponds to Psychtoolbox PsychPortAudio('Open') input reqlatencyclass setting resource usage priority. ≥ 2 also flips the latency input to InitializePsychSound. Higher values decrease latency but also compatibility. See Psychtoolbox help text for more information, but briefly:

<cd>0    <cd> – low
<cd>1    <cd> – medium
<cd>2    <cd> – high
<cd>3, 4 <cd> – highest but might not work and might actually increase latency

bufferSize goes to Psychtoolbox PsychPortAudio('Open') input buffersize. <cd>[]<cd> (default) = Psychtoolbox automatic.

latency goes to Psychtoolbox PsychPortAudio('Open') input suggestedLatency. This is a number that is requested sound output latency (sec). Higher values increase latency but also improve compatibility. If needed, try increasing in increments of 0.005 sec. <cd>[]<cd> (default) = Psychtoolbox automatic. Note you can often compensate for increased latency by setting properties startBuffer/endBuffer.

latencyBias: If sound output start/end is earlier or later than expected on average, you can try setting this to compensate (sec). See Psychtoolbox PsychPortAudio('LatencyBias') for more information.

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.

speaker objects

n_device_r
sampleRate_r

n_device_r

Internal sound device number. You can set device using input property n_device above. This records the result in case you leave n_device at default.

sampleRate_r

Sample rate the internal sound device used. You can set a sample rate using input property sampleRate above. This records the result in case you leave sampleRate at default.