Playing AIFF sounds

Bob Arning arning at charm.net
Fri May 5 21:22:26 UTC 2000


On Fri, 5 May 2000 15:38:12 -0400 "David N. Smith \(IBM\)" <dnsmith at watson.ibm.com> wrote:
>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.

Dave,

I suspect that you can go a bit lower than 500 and still avoid repeats. Whether you can go low enough (maybe 200 to 250) to avoid messing up the user's experience remains to be seen. I have enclosed a little test that tries to measure unexpected pauses in Squeak such as those that prevent the SoundPlayer filling the buffer quickly enough. If you file it in, it will explain itself. What causes these delays (and I'd be interested in the numbers from your system) is still a mystery. I set the priority high enough so that little in Squeak should interfere although long primitives are a possibility. I'm wondering about the VM-to-OS stuff as a possibility.

Cheers,
Bob
===== code follows =====
'From Squeak2.8alpha of 13 January 2000 [latest update: #2052] on 5 May 2000 at 5:13:41 pm'!
Object subclass: #BobsTimer
	instanceVariableNames: 'history stop '
	classVariableNames: 'History Stop '
	poolDictionaries: ''
	category: 'Kernel-Objects'!

!BobsTimer commentStamp: '<historical>' prior: 0!
BobsTimer

tests for unexpected pauses in Squeak activity. To run it, evaluate

	BobsTimer begin

This will start a process that repeatedly waits 10 msec and then checks to see how long it was actually suspended. If the actual elapsed time exceeds a certain threshhold, a notation will be entered in a log. If you If wait 5 or 10 seconds and evaluate

	BobsTimer stop

an inspector will appear showing the results of the test. The result will be a collection of items where each item contains:

1 - the number of loops processed when the threshhold was exceeded.
2 - the value that exceeded the threshhold

My observation is several 100+ msec elapsed times every second. What causes this is still a mystery, but it can play havoc with (e.g.) playing sounds.!
]style[(9 71 17 255 16 389)f3,f1,cblue;f2,f1,cred;f2,f1!

!BobsTimer class methodsFor: 'as yet unclassified' stamp: 'RAA 5/5/2000 16:39'!
begin
"
	BobsTimer begin
"
	History _ OrderedCollection new.
	Stop _ false.
	[self loop] forkAt: 7.! !

!BobsTimer class methodsFor: 'as yet unclassified' stamp: 'RAA 5/5/2000 16:52'!
loop

	| before elapsed loops |

	loops _ 0.
	[Stop] whileFalse: [
		loops _ loops + 1.
		before _ Time millisecondClockValue.
		(Delay forMilliseconds: 10) wait.
		elapsed _ Time millisecondClockValue - before.
		elapsed > 30 ifTrue: [
			History add: {loops. elapsed}.
			loops _ 0.
		].
	].
	History add: {loops. '--complete--'}.
! !

!BobsTimer class methodsFor: 'as yet unclassified' stamp: 'RAA 5/5/2000 16:40'!
stop
"
	BobsTimer stop
"
	Stop _ true.
	History inspect.

! !

"Postscript:
Leave the line above, and replace the rest of this comment by a useful one.
Executable statements should follow this comment, and should
be separated by periods, with no exclamation points (!!).
Be sure to put any further comments in double-quotes, like this one."


StringHolder new
	textContents: BobsTimer comment;
	openLabel: 'About BobsTimer'!





More information about the Squeak-dev mailing list