Welcome! Log In Create A New Profile

Advanced

problems with rewind_sound

Posted by teichert 
problems with rewind_sound
July 20, 2020 11:49AM
Hi Jaewon,

I am trying to use the new ML to present sequences of sounds within a single trial. Following an earlier post on this forum we use rewind_sound, but ran into some unexpected behavior on our platform.

In a nutshell, the rewind_sound command has two un-intended consequences on our platform. In certain settings it crashes Matlab hard without any error message, in other settings it changes the duration of the tones played. I have attached a series of timing files that re-creates the different outcomes on our end.

The test_sine_cnd.txt file specifies five 50 ms sine tones. By default it calls the timing file test.m. (To test the three timing files attached here please edit the name accordingly.)

All of the timing files are set up to play 5 tones with an inter-stimulus interval of 300 ms. They differ with respect to whether the same tone is repeated 5 times, or a new tones is played at each instance. And they differ with respect to whether rewind_sound is called or not.

The first example timing file (test_noRewind_sameTone_omissions.m) requests the same sound 5 times and does not use rewind_sound. This has the anticipated effect of dropping tones. (However, somewhat unexpectedly to me it plays the sound twice, instead of just once.)

The second example timing file (test_rewindAll_sameTone_differentToneDuration.m) uses "rewind_sound(n)" after each presentation. This leads to the presentation of all 5 instances, but the duration of instances 2 and 4 are noticeably longer than instances 1,3 and 5.

The third timing file (test_rewindAll_differentTones_crash) requests a different tone each time and rewinds after each presentation. This crashes the program after all 5 tones have been presented. The crash always happens after all tones have been played, regardless of their order or number of presentations. In some, but not all, instances we have been able to avoid the crash by not rewinding the very last sound.

We have also noticed that on our platform the command rewind_sound without arguments in brackets (i.e., "rewind_sound" instead of "rewind_sound(n)" ) reliably crashes matlab the first time it is called. Adding a second argument to the brackets ("rewind_sound(n,0)") did not have any effect on the different durations that we observed with timing file test_rewindAll_sameTone_differentToneDuration.m.

A couple of details about the setup: we use matlab 2020a on a new dell windows 10 machine. We have observed these outcomes using two different sound-cards, one of them an internal sound-card from M-Audio, the other one an external usb sound-card from focusrite.

Any help or suggestions are greatly appreciated :-)

Cheers,
Tobias
Attachments:
open | download - testSine_cnd.txt (211 bytes)
open | download - test_noRewind_SameTone_omissions.m (1 KB)
open | download - test_rewindAll_sameTone_differentToneDurations.m (1 KB)
open | download - test_rewindAll_differentTones_crash.m (1 KB)
Re: problems with rewind_sound
July 21, 2020 11:10PM
First of all, rewinding is necessary only when you play the same sound again in the same trial. So you don't need to call rewind_sound() in your first and third examples.

In the first example, you hear beeps twice (or three times) because the length of your stimulus is 50 ms but you played only the ~20 ms of it in the first run. When you toggle it on again in the second (and third) run, the rest of the sound is resumed. Make a shorter sound or play longer than 50 ms to avoid the second (or third) beep.

The second example is actually a bug of NIMH ML that an XAudio sound does not stop immediately if the last sound buffer is already submitted. It is fixed now. Please download the package again.

The issue in the third example is also related to the bug, I believe. It should be fixed. Calling rewind_sound() should not cause a problem, whether the function call is necessary or not.
Re: problems with rewind_sound
July 22, 2020 02:18PM
Hi Jaewon,

Thanks so much for the fast fix! The new version works like a charm :-)

Cheers,
Tobias

The National Institute of Mental Health (NIMH) is part of the National Institutes of Health (NIH), a component of the U.S. Department of Health and Human Services.