Mantis - Squeak
Viewing Issue Advanced Details
7497 Sound feature always 04-09-10 00:44 02-06-11 23:47
none trunk  
0007497: [FIX][Enh] Sound that name.
deprecated object methods included #beep:

This kaboshed Beeper beep: 'click' which was my former favored way to produce a sound.

To fix the problem in the spirit of squeak I have added a method #sound to string which will return a playable sound from the sound library or the Beeper default sound.

The method Sting>>#sound is in the *sound-Synthesis category to keep it with SampledSound the owner of SoundLibrary.

Uploaded fileout:

'From Squeak4.1beta of 5 April 2010 [latest update: #9885] on 8 April 2010 at 7:52:50 pm'

String methodsFor: '*sound-Synthesis' stamp: 'wiz 4/8/2010 19:52'

"Return a sound. Either from the sound library via SampleSound or else the Beeper default"

^SampledSound soundNamed: self ifAbsent: [ Beeper default ]

 String-* [^] (323 bytes) 04-09-10 00:44 [^] (1,253 bytes) 04-09-10 20:58
 SoundSupportTests.2.cs [^] (1,261 bytes) 05-03-10 04:34

04-09-10 00:48   

"SampledSound soundNames atRandom sound play"

" 'oops' sound play " (plays Beeper beep)

Yours in curiosity and service, --Jerome Peace
04-09-10 21:00

adds simple test for the existance of the String>>#sound selector
and the return of a playable object.
04-13-10 12:19   
I changed this to feature, because there is no bug to fix as far as I can tell.

Also I guess you will need to mobilize more supporters for your idea on squeak-dev to make this happen.
04-13-10 12:23   
Just to say, that I wouldn't like the String class to be "polluted" with such "convenience" methods. There would be no end ...

String image
String morph
String fileContent
04-14-10 00:50   
Hi laza,

Each to his own opinion.

My take is that in squeak everything is an object. This means that basic classes such as number and string serve as objects. It leads to the following problem:

The number or name of something acts as a modifier, yet if you use the number or name first in squeak it is a receiver. To have a worthwhile language which resembles my speaking language I choose to allow my modifiers to be receivers.

It is stupid IMO to invent classes inorder to use modifiers as argument parameters. In squeak modifiers sometimes belong in the position of receivers.

In this case the problem is the invented and arbitrary class that takes the sound name as an argument was deprecated and nuked. Leaving broken code behind it.

The easy and English sounding way to avoid this is to give the modifier it's rightful place as the receiver of the message.

'click' sound play.

Is IMHO the right way to say lets play a click like sound. It sounds right when you speak it.

I feel very strongly about this.

Any other solution I could propose would involve arbitrary invention and would not be as general.

Who wants to remember what class is responsible for playing a click sound when programming an application. This solution is elegant.

Remember the old class used was Object.

So you could say:

self beep: 'click'
and aviod looking up the sound making class or creating a new object just to play your sound.

Conversion methods are used all the time. While I have seen some warning against using them too readily I have not seen any more elegant solutions.

So I am stating that all strings should be able to make a sound if they so wish.

The #sound method is in charge of knowing what that sound should be. Playing a library sound if one exists of a default sound if one does not. It doesn't belong to the String package it belongs to the Sound package along with the class that keeps the Sound Library. It extends the String classes.

The programmer should be having fun using squeak not a frustrating time trying to find the missing word.

Sorry for the rant. I feel quite strongly about this and dislike the additional hurdles being put in the way of an elegant solution.

Rantingly, --Jerome Peace
04-18-10 03:41   
I have submitted
Sound-wiz.16 to the inbox.

In case it should prove acceptable.

I am also using this simple case to learn the process of submitting .mcz versions of things.

I am still an MC luddite. So feedback on the process is appreciated as I try to learn more.


Yours in curiosity and service, --Jerome Peace
05-03-10 04:20   
Fixed. Sound-wiz.18 now in trunk.
To meet Berts demands the selector is called #asSound rather than #sound.

So tests need updating.
05-03-10 04:35   
SoundSupportTests.2.cs uploaded.

Changed selector name in test and class comment
from #sound to asSound

Also submitted changes to inbox as Tests-wiz.75.mcz

05-03-10 04:38   
see notes.

Selector has been accepted in trunk.

Tests are in inbox.