Playing AIFF sounds
John.Maloney at disney.com
John.Maloney at disney.com
Mon May 8 19:58:53 UTC 2000
Hi, Dave.
The Disney IS folks cut us off from the Internet last week in
response to the "love bug" virus and I'm just now getting caught up.
I haven't read every message in this thread carefully, so
pardon me if someone else has already suggested the following
explanation.
I think that the file reading operations may be starving the
the Squeak sound player process. This is especially likely if
you do are trying to do back-to-back playing of sounds from
AIFF files. A quick test would be pre-load all the sounds into
memory and repeat the test. Increasing the SoundPlayer buffer size
fixes the problem by making sure that the sound driver has a buffer
larger than the longest disk read operation. But, as you found,
that also increases the latency before a sound starts playing.
If this is, indeed, the problem, then there are a number of
solutions, ranging from pre-loading all your sounds into memory
to using asynchronous file read operations. A fairly simple
solution might be to simply make SampledSound>fromAIFFfileNamed:
break its file read operation into smaller chunks to allow the
sound player process to slip in and generate the next output
buffer when it needs to. (Right now, I believe it reads the
entire samples chunk in a single file read operation.)
Sorry that you've had these problems...
-- John
P.S. By the way, can you say anything about what you're working
on? The phrase "real kids start using this Real Soon Now" is
intriguing.
At 3:54 PM -0400 5/4/00, David N. Smith \(IBM\) wrote:
>All:
>
>I'm trying to play AIFF sounds (on a Mac) from within Squeak. This works fine:
>
> (SampledSound fromAIFFfileNamed:
> FileDirectory default pathName, ':TRW:sounds:', 'Laugh', '.aif') play
>
>but has reverb on. I don't want reverb on. This stops the reverb:
>
> s := SampledSound fromAIFFfileNamed:
> FileDirectory default pathName, ':TRW:sounds:', 'Laugh', '.aif'.
> SoundPlayer stopReverb.
> s play
>
>Unfortunately, this sets the reverb off globally, but I can live with that.
>
>However, when I run this a lot, playing four different sounds, sometimes a sound is played twice in a row, and on rare occasions it is played four times. They aren't just queuing up; the application never plays the same sound twice in a row. That is, I play A-B-C-A-B-C and I might get A-B-C-A-B-B-C. The problem never repeats in the same place, and is rare, say 1 out of 20 times.
>
>The code I actually run is below. I never play builtin sounds, and I don't know if waiting for the last sound to complete is useful, thought I feel that I see less problems with it in:
>
>playSoundName: aName
> | snd |
>
> lastSound isNil ifFalse: [
> SoundPlayer waitUntilDonePlaying: lastSound ].
>
> (self soundNamesBuiltin includes: aName)
> ifTrue: [
> SoundPlayer stopReverb.
> SampledSound playSoundNamed: aName ]
> ifFalse: [
> snd := SampledSound fromAIFFfileNamed: FileDirectory default
> pathName, ':TRW:sounds:', aName, '.aif'.
> SoundPlayer stopReverb.
> snd play ].
> lastSound := name.
>
>I'm hoping that someone understands sampled sounds better than I do and can make some suggestions on how to fix things. I'd love to go spend more time with sampled sounds, but I'm on a bit of a deadline here; ie, real kids start using this Real Soon Now. I've poked at it off and on for days, but have probably missed something obvious.
>
>Thanks for any help,
>
>Dave
>
>I'm on 2.8 ALPHA, MacOS9, PowerBookG3, and the wind is from the west.
More information about the Squeak-dev
mailing list
|