Simultaneous use of screen and beeper incompatibility between Windows 7 and Windows 10

Hello,

I am a new PTB user. In the designed experiment, we would like to have a beep sound while the stimulus on the screen is rotating. I would like to update an existing code working just fine on windows 7 and mac (beep sound and screen rotation are simultaneous). However, when I run the code in windows 10, first beep sound comes, then the screen starts rotating right after the beep sound. Below you can find the part of the code that triggers beep and screen rotation.

    % Indicates the start of a trial with a beep sound.
    Beeper(440, 'low', trialDur);
    
    t1 = GetSecs;
    time = t1;
    
    while (time <= t1 + trialDur) 
        Screen('DrawTextures', window, spiralTexture, srcRect, dstRects, angle,...
        [], [], colorMod, [], kPsychUseTextureMatrixForRotation);
        % Flip to the screen
        Screen('Flip', window);

Thank you for your help!

Beeper() uses Snd(), which (quoting from the help): “Old Sound driver for Psychtoolbox. USE OF THIS DRIVER IS DEPRECATED FOR ALL BUT THE MOST TRIVIAL PURPOSES!
Have a look at the help for PsychPortAudio (“help PsychPortAudio” and “help InitializePsychSound”) for an introduction into the new sound driver, which is recommended for most purposes.”

check
BasicSoundOutputDemo

BasicSoundScheduleDemo

for the way forward

Cheers,
Dee

1 Like

It seems like PsychPortAudio does the trick for me. I used the following code instead of beeper:

% initialize the Psychtoolbox audio system in low latency mode
InitializePsychSound;

% open the first audio device in low-latency, stereo mode
% if you have more than one device attached, you will need to specify the
% appropriate deviceid
pahandle = PsychPortAudio('Open', 2, [], 1, 48000, 2);

% generate a beep
beepWaveform = MakeBeep(220,trialDur);

% make stereo
beepWaveform = repmat(beepWaveform, 2, 1);

% fill buffer, play
PsychPortAudio('FillBuffer', pahandle, beepWaveform );
startTime = PsychPortAudio('Start', pahandle, 1);

Thank you so much for your time and reply.

One step forward, but there are multiple mistakes here affecting timing precision, robustness on different machines, and relationship/correctness between what sound you want, and what you get. Various demos will teach you better approaches, or you can buy paid priority support help PsychPaidSupportAndServices if you want pro advice.

-mario