No BSD License  

Highlights from
Make Beeps with Psychtoolbox

4.33333

4.3 | 3 ratings Rate this file 0 Downloads (last 30 days) File Size: 1.39 KB File ID: #5213

Make Beeps with Psychtoolbox

by Peggy Chen

 

10 Jun 2004 (Updated 11 Jun 2004)

Plays a series of short tones as audible stimuli.

| Watch this File

File Information
Description

This code was modified from beep2 (by Dave Johnson of Raytheon Missile Systems Co). It solved the problem that after about playing 180 beeps, an error message "??? Unable to write into sound device" showed up. If you only want to play several beeps or tones, use beep2. If you want to present more than 200 tones in an experiment, try this one. Please reply if you find any bugs or if you have a better code.

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
beep2.m

MATLAB release MATLAB 6.5 (R13)
Other requirements psychtoolbox
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (5)
01 Nov 2005 V. Bernard

I checked the beep2.m and i think althoug you tried to make a variation of that file, but the ofiginal is still better. But it's good you had the courage to modify it.

24 May 2006 CHI-FENG TAI

Peggy Chen,
There is one improvment that can be done for Window PC user.
Instead of using SND('Wait'), it is better to use pause(seconds). If the beep sound duration is shorter than 1 seconds. SND('Wait') will not work. No beeps at all.

SND('Quiet') = SND('Close'). Just need to use one of them. Don't need to repeat the same action which is clear playsnd.

Bothe example will give you 1000 beeps without giving you an error message.

example1:
Beep=sin([1:400]);
rate=22254;
for n=1:1000
SND('Play',Beep,rate);
pause((length(Beep)/rate));
SND('Close');
end

Example2 (Another simpler and better code):
Beep=sin([1:400]);
rate=22254;
for n=1:1000
sound(Beep,rate);
pause((length(Beep)/rate))
clear playsnd
end

07 Sep 2006 Gerrit Maus

Aaaarrgh! Thanks! Took me ages to find out why my program crashed. And with the tipp from chi-feng tai your fix actually works. I recommend calling it beep3.m to avoid conflict with psychtoolbox' makebeep.m

18 Sep 2007 bart machilsen

This is exactly what I needed! When I first got the 'Unable to write into sound device'-error I didn't know how to solve it. This small script did exactly what I wanted it to do. Thanks!

09 Jan 2008 bob shrew

You may find that the following solution, although tacky, is quick and easy.

---
try
  sound(sin(2*pi*[0:1/44100:.1]*1000),44000);
catch
  pause(.1)
end
--

If an attempt to play a sound fails, the software pauses for 0.1 seconds. This seems to solve my problems.

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
sound Peggy Chen 22 Oct 2008 07:23:22
beep Peggy Chen 22 Oct 2008 07:23:22
snd Peggy Chen 22 Oct 2008 07:23:22
utilities Peggy Chen 22 Oct 2008 07:23:22
johnson Peggy Chen 22 Oct 2008 07:23:22
tones Peggy Chen 22 Oct 2008 07:23:22

Contact us at files@mathworks.com