Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!thunder.mcrcim.mcgill.edu!quiche!peterd From: peterd@cs.mcgill.ca (Peter Deutsch) Newsgroups: comp.sys.next Subject: Showing off the sounds Keywords: hacking, playing, wasting time... :-) Message-ID: <1991May24.230242.22506@cs.mcgill.ca> Date: 24 May 91 23:02:42 GMT Sender: news@cs.mcgill.ca (Netnews Administrator) Organization: SOCS, McGill University, Montreal, Canada Lines: 143 Originator: peterd@opus ---------------------------------------------------------------------- g'day, Here's a little bit of hacking that may or may not be of interest. But first, some background: For those who haven't seen it (or are cut off from the alt.* hierarchy of Usenet) there is now a new group alt.sex.sounds. In the finest hacker traditions, this has contained almost nothing vaguely resembling an erotic sound (like, a Rodney Dangerfiled joke! really, people..) It's mostly unix weenies and amiga weenies and Mac weenies arguing and sharing sound conversion info. For those who can get it, check it out.. Now, the most "interesting" sound I saw/heard (in fact, the only one I saw that would vaguely fit the mandate of the newsgroup) was "Sally.snd", which is the diner scene from "When Harry Met Sally" (and you should see the faces of the DOS users in this place when I replaced the "Print out of Paper" voice message with THAT!). Since I'm actually a unix weenie myself, I of course spent half an hour converting this to the appropriate format for NeXT, discovering things about NeXT sounds, etc. This is an area I hadn't explored before and I'm impressed. Well done, NeXTites. Anyways, to the hacking bit. After playing with this osund on the NeXT for a while I started getting ideas. Given that the original Sally.snd file started life as an old style Sun sound file (no format header) and we'd been playing it on the IPC to verify this (in fact, the way we converted it was to load up the demos sound program on the sun and let it handle it. Since then I've learned about sndconvert), I had the idea to try and play the sound across the network. I tried: cat sally.snd | rsh machine.mcgill.ca -l root "cat - > /dev/audio" and lo and behold it worked like a charm. No pauses, nothing. This is fun. My next idea was to look in the NextDeveloper/Examples/Sound directory and see what I could use. I noticed that all of these sample programs seem to write recorded sounds out to a file. "That's no good" I said. So I hacked "recordtest.c" to write to standard out (see below).I could now do this (I called the compiled program "doit"): doit | rsh machine.mcgill.ca -l root "cat - > /dev/audio" And it worked like a charm. I spoke into the mike and it came out on the Sun, after aa short delay. Now, it was choppy (this program records a fragment of sound, then plays it, then records some more, etc) so there are gaps in the output, but it works. So, here's the project - anybody want to convert this to use multiple Mach threads, one recording one playing so we don't get the gaps? Add a GUI so the front desk people can do departmental wide paging, click on the face of someone to call them, maybe have little phono plugs you drag into sockets to connect to other machines? The possibilities seem endless. I hope to play with this some more (like, from NeXT to NeXT, which is no big deal) but I wanted to share how easy this was with you all. From first idea to talking across the net to the Sun was no more than five minutes work. Gosh, I love these little toys! So, I hope this puts a few ideas in people's heads. I'm going to keep playing and would be interested in hearing from others working along simliar lines. Enjoy... - peterd ---------------------------------------------------------------------- /* * recordtest - record many short soundfiles, Hacked to write to standard out instead of a file and loop 20 times then halt.... - peterd (yeah, like I gotta sign five minutes work...) */ #import #import main (int argc, char *argv[]) { int size, err, j; SNDSoundStruct *s[10], *s2; /* if (argc < 2) { printf("usage : recordtest file ...\n"); exit(0); } */ // // Allocate a fixed-sized buffer for each file // for (j=1; j<5; j++) { err = SNDAlloc(&s[j],4096,SND_FORMAT_MULAW_8,SND_RATE_CODEC,1,0); if (err) fprintf(stderr,"recordtest : cannot allocate buffers\n"); } // // enqueue all the recording requests // fprintf(stderr, "recording...\n"); for (j=1; j<20; j++) { fprintf(stderr,"recordtest : start recording\n"); err = SNDStartRecording(s[1],0,1,0,0,0); if (err) fprintf(stderr,"recordtest : cannot start recording\n"); fprintf(stderr,"recordtest : await recording\n"); SNDWait(0); fprintf(stderr,"recordtest : done recording, now write\n"); err = SNDWrite(1,s[1]); if (err) fprintf(stderr,"recordtest : cannot write output...\n" ); } // // Wait for all of the requests to complete // // // Write out the files // // printf("writing files...\n"); for (j=1; j<5; j++) { } exit(0); }