0

Mainly, I want to indicate the error by a sound when subject press wrong button in Psychtoolbox???

From the stimulus by a window, subject should press the button for responding key("g" or "p"). At this point, I wanna indicate that responding error by a sound. How to generate the code for responding whether they press wrong button by a sound in psychtoolbox?

1 Answers1

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);
DMR
  • 1,479
  • 1
  • 8
  • 11