Microphone device object

A microphone object is optional. You only need to make one if you want to change a property from default. Often the easiest way to set microphone object properties is to change their default values using pb_prefs.

An object of type microphone represents the high-precision PortAudio driver Psychtoolbox uses to record sound. There can only be one microphone object for an experiment. In an experiment script you can make one outside trials with the command microphoneObject and add it with addToExperiment. Most commonly if you need one, you're using a soundRecorder element.

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

n_device

Default: system default sound input device

A system can have multiple internal sound input “devices”. n_device is an integer setting device to use (0, 1, 2, …). <cd>[]<cd> = system default sound input device. 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 NrInputChannels > 0 are input devices. Type help InitializePsychSound for more information from Psychtoolbox.

If you need to set n_device, usually easiest is to use pb_prefs → microphone tab since it organizes device numbers and names in an easy menu.

numChannels

Default: 2 (stereo)

Number of channels to record. 1 = mono, 2 = stereo, etc. A typical recording from a mono mic is duplicated in all channels open (so, for example, a recording to two channels may not actually be stereo sound).

sampleRate

Default: device default

Sample rate to record at (Hz). 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. <cd>[]<cd> = default sample rate for the current device. See also record property sampleRate_r below.

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.

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 <cd>[]<cd>.

sampleRate_r

Sample rate of recording. You can set a sample rate using input property sampleRate above. This records the result in case you leave sampleRate at default <cd>[]<cd>.