[squeak-dev] What is the proper way to add bells and whistles? (was:Re: Beeper can now only make one sound.)

Jerome Peace peace_the_dreamer at yahoo.com
Thu Apr 8 08:10:47 UTC 2010


In the previous thread,

Andreas Raab replied:
>
>Well, interestingly the method Beeper class>>beep: never existed (or at 
>least I can't find an image with it). The only thing that did exist was 
>Object>>beep: (which will work implicitly for requests for "Beeper beep: 
>'clink'"). Object>>beep: on the other hand has been deprecated since 
>Squeak 3.7. It looks like David finally nuked them in 
>39Deprecated-dtl.16 in November.
>
Okay. That would explain it.

Now to deal with the problem.

What is the proper way to add bells and whistles?

the removed method says.

beep: soundName
	"Make the given sound, unless the making of sound is disabled in Preferences."

	self deprecated: 'Use SampledSound>>playSoundNamed: instead.'.
	Preferences soundsEnabled
		ifTrue: [self playSoundNamed: soundName]

Use SampledSound>>playSoundNamed: instead? Is that still good long term advice?


What I would rather have is a String method such as #asSound or #asSampledSound
which would lookup the sound named after the string or return Beeper default.

Then doing:

" 'click' asSound play "
would work

so would
" 'foo' asSound play. "

This means I can now use the argument as the receiver.

The details can be hidden in the #asSound method.

asSound
^ SampleSound soundNamed: self ifAbsent: [Beeper default] .

The only question left is what category/package should contain it?

Yours in curiotiy and service, --Jerome Peace


      



More information about the Squeak-dev mailing list