Beeper Delayed on Linux

Hi all,

We’re noticing that the Beeper() function is delayed on our Linux machines. When we call it, there is about 500-1000 ms before we hear a beep.

Here are the specs on our operating system:
Computer: NVIDIA Quadro Pro P400 2GB
OS: Ubuntu 18.04
Psychtoolbox Version: 3.0.17
Matlab version: 2020b

Here is the code that we have been using; any help would be much appreciated!

 InitializePsychSound(0);
 Beeper(200, .7, .3);  %this is delayed when it is called

Owen Adams, M.S.
Graduate Research Assistant
Visual Attention & Distraction Lab
Binghamton University, State University of New York

Don’t use Beeper. from help Beeper:
NOTE: Beeper() uses Snd() internally. If you want to use Beeper() - and therefore
Snd() in parallel with PsychPortAudio, read the notes in “help Snd” about pahandle
sharing!

From help Snd:
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.

Snd() is a rather dumb and primitive wrapper around the PsychPortAudio()
driver. It uses PsychPortAudio’s most basic functionality to achieve
“sort of ok” sound playback. The driver is used in high-latency,
low-timing precision mode, so Snd()'s audio playback timing will likely
be very unreliable.

Cheers,
Dee

Yet another reason to not use Beeper is that (at least on Ubuntu 20 running Matlab 2019b and the latest stable release of PTB) it causes a big memory leak! This may be the source of the delay you’ve seen.

No, it likely isn’t the source of the delay. Beeper isn’t meant for timing sensitive stuff.

If you think there is a memory leak in Beeper, instead of simply user error or a misunderstanding on your side, please provide suitable evidence, a reproducing example, and file a bug report on our Github issue tracker, ideally with priority support token attached to pay for time to diagnose potential bugs.

-mario

Psychtoolbox Version 3.0.16
MATLAB Version: 9.6.0.1335978 (R2019a) Update 8
Ubuntu 20.04.3

Run top on the command line
Run Beeper in the Matlab command window
160 MB is lost and not recovered. Do it enough times, the system lags, frames drop, etc. Even more, system crashes. Classic memory leak. So on my system, repeated uses of Beeper led to system lag and crash.

I put the report into github already.

Note, I am using R2019b so not the latest supported MATLAB (maybe that’s actually the issue) and I haven’t got 3.0.18 yet. I can fix the problem for myself by changing over to PsychPortAudio.

Beeper() uses Snd() which uses PsychPortAudio internally by default, although help Snd has notes about using the old Matlab sound() function as a fallback, which was severely buggy at various points in time and is always a lower performer than PsychPortAudio.

Whatever it was, it is not reproducible with PTB 3.0.18 on Ubuntu 20.04.3-LTS or 18.04.6-LTS with Octave, or on 20.04.3-LTS with Matlab R2021b. This covers version 19.6 and 19.7 and 19.8-devel of the underlying libportaudio library. Older versions of PTB or Matlab are officially unsupported by now. One should note that Matlab bundles its own versions of libportaudio, overriding system provided versions for god knows what reasons. This usually means outdated libraries, although occasionally, like with R2021b, one can get lucky and get a newer version than what 20.04 ships. So such bugs could very well be Matlab version specific. One can rename the Matlab provided libportaudio though to revert to system libraries.

I did make some minor improvements to the help mechanism for upcoming Beeper/Snd.

So closing as invalid/wontfix. Work time spent: 1 hour ~ 150 Euros financial loss to the project.