Beep new design

Stephane Ducasse ducasse at iam.unibe.ch
Sat May 17 14:41:20 UTC 2003


Andreas

have you any comment on this? Because I found that it remove the 
Smalltalk at: check and
let applications change it

Stef

On Saturday, May 17, 2003, at 01:14 PM, Stephane Ducasse wrote:

> Hi all
>
> Here is what we propose for removing beep from Object. I would like to 
> have your feedback.
>
>
> Object subclass: #Beeper
> 	instanceVariableNames: ''
> 	classVariableNames: ''
> 	poolDictionaries: ''
> 	category: 'System-Support'!
>
> !Beeper commentStamp: 'sd 5/17/2003 13:04' prior: 0!
> I'm a simple object been responsible to provide an audible feedback. 
> However, the feedback can be change by using my class side method 
> setDefault: with an object understanding the message play.
>
> So you can invoke Beeper as follow
>
> 	Beeper default beep
> 	Beeper default play
>
> But the idiom is really Beeper beep
>
> Note that play is introduced to propose a common interface between 
> AbstractSound and Beeper.
> This way we can have more enhanced beepers doing the following:
>
> SampleSound class>>initialize
> 	"SampledSound initialize"
>
> 	IncrementFractionBits _ 16.
> 	IncrementScaleFactor _ 2 raisedTo: IncrementFractionBits.
> 	ScaledIndexOverflow _ 2 raisedTo: 29.  "handle overflow before 
> needing LargePositiveIntegers"
> 	self useCoffeeCupClink.
> 	SoundLibrary ifNil: [SoundLibrary _ Dictionary new].
> 	Beeper setDefault: (self new
> 						setSamples: self coffeeCupClink
> 						samplingRate: 12000)).
>
>
> Then Beeper beep will play the coffeeCup sound.
>
>
>
>
>
>
> !
>
> Beeper class
> 	instanceVariableNames: 'default '!
>
> !Beeper methodsFor: 'playing' stamp: 'sd 5/17/2003 12:12'!
> beepPrimitive
> 	"Beep in the absence of sound support"
>
> 	<primitive: 140>
> 	self primitiveFailed! !
>
> !Beeper methodsFor: 'playing' stamp: 'sd 5/17/2003 12:13'!
> play
>
> 	self beepPrimitive
> 	! !
>
>
> !Beeper class methodsFor: 'customize' stamp: 'sd 5/17/2003 13:08'!
> clearDefault
> 	"Beeper clearDefault set as default the primitive beep"	
>
> 	default := nil! !
>
> !Beeper class methodsFor: 'customize' stamp: 'sd 5/15/2003 22:51'!
> default
>
> 	default isNil
> 		ifTrue: [default := self newDefault].
> 	^ default! !
>
> !Beeper class methodsFor: 'customize' stamp: 'sd 5/15/2003 22:52'!
> newDefault
> 	"Subclass may override me to provide a default beep"
>
> 	^ self basicNew! !
>
> !Beeper class methodsFor: 'customize' stamp: 'sd 5/17/2003 12:11'!
> setDefault: aPlayableEntity
> 	"aBeepingEntity should anwers the message play"
> 	default := aPlayableEntity! !
>
> !Beeper class methodsFor: 'instance creation' stamp: 'sd 5/17/2003 
> 13:12'!
> beep
> 	"The preferred way of producing a sonor feedback"
>
> 	self default play! !
>
>
> !SampledSound class methodsFor: 'class initialization' stamp: 'sd 
> 5/17/2003 13:04'!
> initialize
> 	"SampledSound initialize"
>
> 	IncrementFractionBits _ 16.
> 	IncrementScaleFactor _ 2 raisedTo: IncrementFractionBits.
> 	ScaledIndexOverflow _ 2 raisedTo: 29.  "handle overflow before 
> needing LargePositiveIntegers"
> 	self useCoffeeCupClink.
> 	SoundLibrary ifNil: [SoundLibrary _ Dictionary new].
> 	Beeper setDefault: (self new
> 						setSamples: self coffeeCupClink
> 						samplingRate: 12000).
> ! !
>
> SampledSound initialize!
>
>



More information about the Squeak-dev mailing list