如何通过Psychtoolbox中的声音指示错误?

时间:2018-03-13 08:56:11

标签: psychtoolbox

主要是,当主题按下Psychtoolbox中的错误按钮时,我想通过声音来指示错误???

通过窗口的刺激,主体应按下响应键的按钮(" g"或" p")。 此时,我想通过声音表示响应错误。 如何生成代码以响应他们是否通过psychtoolbox中的声音按错按钮?

1 个答案:

答案 0 :(得分:0)

%% include at the start of the experiment

% initialize sound, requesting low latency (parameter = 1)
InitializePsychSound(1);
% open stereo audio handle
% here, use the first audio device with stereo output, if you have an
% external sound card you may have more than one output device available
samplingRate = 44100;
devices = PsychPortAudio('GetDevices');
outputDevice = devices(find([devices.NrOutputChannels] == 2, 1, 'first')).DeviceIndex;
pahandle = PsychPortAudio('Open', outputDevice, 1, 1, samplingRate, 2);

% generate the waveform of a sound, here a 1000 Hz sine wav, 200 ms long
% you could instead load a .wav file from a file, or generate the waveform
% using any MATLAB functions
beepWav = MakeBeep(1000, .2, samplingRate);

% make the beep stereo
beepWav = repmat(beepWav, [2 1]);

% fill the audio buffer with the beep waveform
PsychPortAudio('FillBuffer', pahandle, beepWav );

%% include whenever you want to play the sound
PsychPortAudio('Start', pahandle, 1, 0, 1);