I-Appliance BBS
The Official Source for Internet Appliance Upgrades and Mods
Amazon Honor System Click Here to Pay Learn More
BBS Main List | Sign In | Sign Up | Search | Help | Linux-Hacker.netReply to Thread | Printer |

Home / Other I-Appliances / 3Com Audrey
Easy utility to play sound effects

New MessageEasy utility to play sound effects (modified 0 times) Sketchy
Profile
Audrey has a built-in driver for playing common "Audrey-like" sound effects, called bleep. I wrote a quick utility to play these effects from the commandline (or thru the CGI web server if you like). The utility is 4KB, the source code is about 10 lines, and doesn't require any libraries other than the C library. So it's very easy to integrate into other apps.

It might be possible to play any sound effect with this method by renaming files in /kojak/snd, but I didn't have time to try it.


-- Jim
ACID and other Audrey apps
04-24-2002 10:14:20

New MessageRE:Easy utility to play sound effects (modified 0 times) Sketchy
Profile
Just to follow up:

It turns out you can play any sound file with this method, just by renaming the sound to one of /kojak/bleep's hardcoded names. This is more lightweight than playsound_noph or phplay, since it uses /kojak/bleep, which is already running on most Audreys.

You can also use this to remotely trigger sounds on the Audrey from any web browser, which could have some interesting uses. Info on that and an improved version of beep is at the site.


-- Jim
ACID and other Audrey apps
04-28-2002 18:11:29

New MessageRE:Easy utility to play sound effects (modified 0 times) bungee
Profile
I tried to use this method as a really lightweight way to play a .wav file, but it didn't work, it still played what sounded like the copy sound. any idea what I'm doing wrong?

void playAudio()
{
if (!quiet){
printf("Playing %s ",fname);
}

// o.k. this is sneaky!
// rename the current file to the sound file
// play it
// rename it back!

if (rename( SOUND_FILE, SOUND_FILE".bak")==0){
if(symlink( fname, SOUND_FILE)==0){
playIt();
usleep(500); // give it a chance...
unlink(SOUND_FILE);
}
rename( SOUND_FILE".bak", SOUND_FILE);
}
}


void playIt()
{
int fd;
int buf;

if (-1 == (fd = open("/dev/bleep", 2)))
{
if (!quiet){
printf("Error: bleep not running ");
}
return;
}

buf[0] = 0;
buf = 2; // the copy sound
write(fd, buf, 8);
close(fd);
}


http://www.bloodyeck.com/projects/audrey/
05-03-2002 12:06:59

New MessageRE:Easy utility to play sound effects (modified 0 times) davistw1
Profile
Are you using the ones out of /tmp? From what I understand at bootup Audrey copy's the soundfiles to there for use.
05-03-2002 13:42:49

New MessageRE:Easy utility to play sound effects (modified 0 times) bungee
Profile
Sorry about that, I cut my source code to avoid posting too much here and ended up striopping out the #define where I say what files I'm using.

#define SOUND_FILE "/tmp/snd/copy-PCM.wav"

so yes, I'm using the ones out of /tmp I'm going to play with it a little more tonight and with Jim's original beep program.

Alex


http://www.bloodyeck.com/projects/audrey/
05-03-2002 15:08:28

New MessageRE:Easy utility to play sound effects (modified 0 times) bungee
Profile
yup it appears to work, the only problem is the call to /dev/bleep returns instantly and when I was putting the old file back it stopped playback :( i was hoping it would be like other stuff I've seen on other OSes where it has an inode and is just loading from that, so you can move the file around and it's still loading the same file.

no problem though, I can just put the file back when my application ends, rather than right after I play it. I already have a method like that to free up shared memory.

it would be nice if beep could wait until the sound is played, but I don't know how to do that, is it trivial to estimate a .wav file's length from just a few bytes from the heder (and its size?) I wonder. if so we'll have a really cool small/zero cost wav file player

Alex


http://www.bloodyeck.com/projects/audrey/
05-03-2002 17:06:36

New MessageRE:Easy utility to play sound effects (modified 0 times) bungee
Profile
I appear to be the king of replying to threads I already replied to today! :) I hope this isn't annoying too many people.

from looking on the web...
http://www.technology.niagarac.on.ca/courses/comp630/WavFileFormat.html
http://www.delphicorner.f9.co.uk/articles/misc12.htm

it appears there is a simple way to estimate a wav's length (although not super accurate, it could be good enough?)

once I do all the other things I plan on doing, I'll get to doing this, if someone else hasn't. here is the rough pseudocode idea of what i want to do...

so you want to play file sound.wav

mv /tmp/snd/copy-PCM.wav to /tmp/snd/copy-PCM.wav.bak
symbolicly link .tmp/snd/copy-PCM.wav to sound.wav
issue the beep command to play copy (0 2)
sleep for the length of sound.wav
remove copy-PCM.wav
put copy-PCM.wav.bak back where it was

tah dah!


http://www.bloodyeck.com/projects/audrey/
05-03-2002 17:20:10

New MessageRE:Easy utility to play sound effects (modified 0 times) Sketchy
Profile
Is it absolutely required to restore the original copy-PCM sound to /tmp? The permanent copy is safe in /kojak/snd. If you don't need to restore, then the timing isn't an issue.

If you must restore, then here is something that might help. /dev/bleep waits on a semaphore until something is written to it. It then streams the sound file from /tmp/snd. When the whole file has been read and closed, it goes back to waiting on the semaphore again. The "pidin" utility will show /dev/bleep's state as "SEM" unless it is playing a sound. Perhaps you can do something like
pidin | grep bleep | grep SEM
If you get any output from that, then bleep is no longer using the sound file and you can restore it. I'm no shell script wiz but there must be a way using this. If not, I could write some code to do it.


-- Jim
ACID and other Audrey apps
05-03-2002 17:48:21

Reply to Thread | Printer |
All times are PSTPowered by UltraBoard v1.62



Copyright © 2000, Netmake Inc. All Rights Reserved.
See Terms and Conditions for more information.




i-opener opener laptop notebook computer help drivers dll free windows dos repair fix linux mac macintosh 2000 95 98 nt pc configure hardware software sound video netscape explorer network networking lan wan software cmos fat bios printer card mouse modem ide scsi cd rom controllers scanner tape hard drive cgi scripts source code mp3