Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!swrinde!elroy.jpl.nasa.gov!decwrl!deccrl!bloom-beacon!eru!hagbard!sunic!news.funet.fi!funic!santra!hila.hut.fi!jmunkki From: jmunkki@hila.hut.fi (Juri Munkki) Newsgroups: comp.sys.mac.programmer Subject: Re: Sound Manager Message-ID: <1991Apr3.135312.14276@santra.uucp> Date: 3 Apr 91 13:53:12 GMT References: <1991Mar30.160749.28551@ecmwf.co.uk> <50989@apple.Apple.COM> <1991Apr3.191758.3314@waikato.ac.nz> Sender: news@santra.uucp (Cnews - USENET news system) Reply-To: jmunkki@hila.hut.fi (Juri Munkki) Organization: Helsinki University of Technology, FINLAND Lines: 58 ldo@waikato.ac.nz (Lawrence D'Oliveiro, Waikato University) writes: >In article <50989@apple.Apple.COM>, nerm@Apple.COM (Dean Yu) writes: >> In article <1991Mar30.160749.28551@ecmwf.co.uk> mab@ecmwf.co.uk >> (Baudouin Raoult) writes: >>> I try to use the Sound Manager to play sounds sampled with MacRecorder. >>> What I want is to play a *big* sound that does not fit in memory. I want >>> to read my sound file in several parts and send the data to a sound command >>> (using SoundCmd). Does anyone know how to do it ? >> >> Upgrade to 6.0.7 or 7.0 (when we get the silly thing finished) and use >> _PlayFromDisk. > >Sorry, I don't think this is going to work. Double-buffered asynchronous >continuous playback (how's that for a mouthful?) only works on machines >with an Apple Sound Chip. MACE claims to be able to play and decompress in real time even on a MacPlus. I know there's enough CPU power, so I wouldn't forget the new Sound Manager before trying it first. The alternate method is much more complicated and involves the Sound Driver. I don't konw how well it likes the SCSI driver, but it's worth a try. The method is described in the old technical note 19, but just in case you are unable to find that, I'm giving a short summary here. First, learn how to play a sampled sound buffer with the sound driver. You should do it with the appropriate _Write (or was it _Control) command, not with the glue routines. You need to prepare a parameter block. Make the routine play asynchronously, so that you can do other things while the sound is playing. To make timings easier, you might want to install your own VBL task. This is not absolutely necessary, but it sure helps a lot. In the simple case of just playing a sound from disk, a VBL task would not be necessary. If you have to do anything else, you probably need a VBL task. To be compatible with MultiFinder, you should install a short VBL stub in the system heap. If your output sampling rate is 22kHz, 370 samples get played between the times that your vertical blanking routine is called (at 60 Hz). This is also the amount of samples that are read and written at a time. For 11kHz, this number is 185 bytes. This technique is based on the ability to change the ioActCount on the fly. When ioActCount reaches a certain value (preferably a multiple of 370 bytes), reset it to the beginning of your buffer. If you filled the first half of your sound buffer while the second was playing, your sound should play without breaks. While the first part of the buffer is playing, fill the second half. As long as you can read faster than the sound can play and the read routines do not interfere with the sound generator, everything should be fine. Of course, none of this is guaranteed to work, although I do something like this quite successfully in another program (that program also now has an option to use the Sound Manager). ____________________________________________________________________________ / Juri Munkki / Helsinki University of Technology / Wind / Project / / jmunkki@hut.fi / Computing Center Macintosh Support / Surf / STORM / ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~