Playing AIFF sounds

David N. Smith (IBM) dnsmith at watson.ibm.com
Fri May 5 19:38:12 UTC 2000


At 15:08 -0400 5/5/00, Bob Arning wrote:
>On Fri, 5 May 2000 13:10:19 -0400 "David N. Smith \(IBM\)" <dnsmith at watson.ibm.com> wrote:
>>(later) Try this:
>>
>>	SampledSound playSoundNamed: 'clink'
>>
>>Select it, and press Command-D repeatedly but carefully. It shows the same property: every so often it plays multiple sounds with one key press. (I have reverb off.) This is a builtin sound and does not go thru my code at all. We got ghosts!
>
>Dave,
>
>Yep, I hear them too. The thing that is critical to avoiding sounds repeating, either in whole (for short sounds) or in part, is how quickly SoundPlayer class>>playLoop can cycle around to fill the buffer with the next sound samples (or silence for the two passes after the last sound is added). I put some logging in to see how often this was happening. When I heard a repeat (full or partial), there was generally a longer than usual delay in one or two of these cycles. Very often there was an incremental garbage collection that occurred in that interval, but I can't convince myself that this consumed enough time. To test that this longer interval was related, I played with setting the BufferMSecs to 80 and to 300. (Did you remember to "SoundPlayer initialize; shutDown; startUp" after changing the source? I forgot more than once.) At 80 msec I hear some repeat almost every time. At 300 I did not hear an error in 20 tries. I can't tell at this point whether it is Squeak being too busy to get back to the sound player loop quickly enough or whether the MacOS is occasionally doing some of its own work, but the time does seem to make a difference to me. BTW: this was on a G3/400 desktop - you might want to go even higher than 300 msec for a PowerBook.
>
>Cheers,
>Bob

Hummm, yes I did forget.

I tried:

	Smalltalk garbageCollectMost. SampledSound playSoundNamed: 'clink'

and still got repeated sounds at 150ms.

At 500ms (no garbage collection) I hear no duplicate sounds, but the half-second delay makes sounds in the interface happen far too late. A user picks up an object and the sound should happen immediately, not 1/2 second later.

Thanks,

Dave
_______________________________
David N. Smith
IBM T J Watson Research Center
Hawthorne, NY
_______________________________
Any opinions or recommendations
herein are those of the author  
and not of his employer.





More information about the Squeak-dev mailing list