The Inbox: Sound-wiz.17.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

The Inbox: Sound-wiz.17.mcz

commits-2
A new version of Sound was added to project The Inbox:
http://source.squeak.org/inbox/Sound-wiz.17.mcz

==================== Summary ====================

Name: Sound-wiz.17
Author: wiz
Time: 28 April 2010, 2:31:56.883 am
UUID: 0ea1e8e2-7a94-44cd-8db8-5e01002db31a
Ancestors: Sound-nice.15

Ok this is a resubmission of String>>sound.

I have fixed the nits.

I have discussed why I believe this is the right word rather than asSound on the mailing list. Squeak-dev 2010. I have not heard back from Bert yea of nay. So as not to undermine my own cause I am assuming my arguments were successful.

Usage:

"'click' sound play" will play a click sound from the sound library.
Any name missing from the sound library will return a default sound to be played. Currently the default is the same as Beeper default.

The purpose of the selector is to be a facade to allow access to sounds by name. Currently this only covers the Sampled Sound sound library and the default sound.

However, the contract is only that
" 'name' sound "
return a playable object. So in the future this could be expanded to check other sound libraries as well before relying on the default.

=============== Diff against Sound-nice.15 ===============

Item was added:
+ ----- Method: String>>sound (in category '*sound-synthesis') -----
+ sound
+ "Return a sound. Either from the sound library via SampleSound or
+ else the Beeper default"
+ ^ SampledSound
+ soundNamed: self
+ ifAbsent: [Beeper default]!


Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: Sound-wiz.17.mcz

Bert Freudenberg
On 28.04.2010, at 06:32, [hidden email] wrote:

>
> A new version of Sound was added to project The Inbox:
> http://source.squeak.org/inbox/Sound-wiz.17.mcz
>
> ==================== Summary ====================
>
> Name: Sound-wiz.17
> Author: wiz
> Time: 28 April 2010, 2:31:56.883 am
> UUID: 0ea1e8e2-7a94-44cd-8db8-5e01002db31a
> Ancestors: Sound-nice.15
>
> Ok this is a resubmission of String>>sound.
>
> I have fixed the nits.
>
> I have discussed why I believe this is the right word rather than asSound on the mailing list. Squeak-dev 2010. I have not heard back from Bert yea of nay. So as not to undermine my own cause I am assuming my arguments were successful.

Well, I can see the satisfying smile in being able to write "'croak' sound play". In particular if you're a native speaker. That makes my objection to it not absolute, and in any case, my opinion isn't the only one that counts ;)

But knowing the naming conventions of the system as we have it, I could never guess that selector. The name that comes to my mind when thinking "I've got a String and I want it to be a Sound, wonder if there's a direct method for that" is "asSound". Because I know the pattern of asInteger, asDate, asTime, etc. It just is more in line with the other conversion methods. For reference, I copied this list from a Protocol Browser on String:

asActionSequence     (Object)
asActionSequenceTrappingErrors     (Object)
asAlphaNumeric:extraChars:mergeUID:     (String)
asArray     (SequenceableCollection)
asBag     (Collection)
asByteArray     (String)
asByteString     (String)
asCharacter     (String)
asCharacterSet     (Collection)
asColorArray     (SequenceableCollection)
asCommaString     (Collection)
asCommaStringAnd     (Collection)
asCubic     (SequenceableCollection)
asDate     (String)
asDateAndTime     (String)
asDecomposedUnicode     (String)
asDigitsAt:in:do:     (SequenceableCollection)
asDigitsToPower:do:     (SequenceableCollection)
asDisplayText     (String)
asDraggableMorph     (Object)
asDuration     (String)
asExplorerString     (String)
asFileName     (String)
asFloatArray     (SequenceableCollection)
asFourCode     (String)
asHex     (String)
asHtml     (String)
asIdentifier:     (String)
asIdentitySet     (Collection)
asInteger     (String)
asIntegerArray     (SequenceableCollection)
asLegalSelector     (String)
asLowercase     (String)
asMorph     (String)
asNumber     (String)
asOctetString     (String)
asOop     (Object)
asOrderedCollection     (Collection)
asPacked     (String)
asParagraph     (String)
asPluralBasedOn:     (String)
asPointArray     (SequenceableCollection)
asPostscript     (String)
asPrecomposedUnicode     (String)
asSet     (Collection)
asSetElement     (Object)
asSignedInteger     (String)
asSmalltalkComment     (String)
asSortedArray     (ArrayedCollection)
asSortedCollection     (Collection)
asSortedCollection:     (Collection)
asSqueakPathName     (String)
asString     (String)
asStringMorph     (String)
asStringOn:delimiter:     (Collection)
asStringOn:delimiter:last:     (Collection)
asStringOrText     (String)
asStringWithCr     (SequenceableCollection)
asSymbol     (String)
asText     (String)
asTextMorph     (Object)
asTime     (String)
asTimeStamp     (String)
asTraitComposition     (SequenceableCollection)
asURI     (String)
asUVersion     (String)
asUnHtml     (String)
asUnsignedInteger     (String)
asUppercase     (String)
asUrl     (String)
asUrlRelativeTo:     (String)
asVersion     (String)
asVmPathName     (String)
asWideString     (String)
asWordArray     (SequenceableCollection)

To me, the little "as" prefix is not superfluous at all. It makes a selector visibly belong to a familiar class of methods.

I really really want to encourage you making Squeak easier to play with interactively. It's what makes Squeak special. But "as close to natural language as possible" is not the only criterium for that. Discoverability and consistency are important, too. And in that department, "asSound" wins, IMHO.

- Bert -



Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: Sound-wiz.17.mcz

Hannes Hirzel
Hello Jerome and Bert

If I remember well the point of departure for Jerome was that there is
no Beeper class anymore. And he wants to have a replacement for that.

There is the class side of SampledSound / category 'sound library' /
method 'playSoundNamed'.

The method returns nil in case the sound is not there. And that method
needs to be fixed.
If I want the computer to play a sound and it does not find a sound at
least I a 'beep' sound.

This is what Jerome implemented in the String library. I do not thing
that it belongs to that place. It belongs to SampledSound. I put in a
proposal in the inbox. It currently gives a visual feedback (a dialog
box) plus a beep sound if a sound is not found.

However I am not pleased with this solution actually.

I think we should have an easier interface for the Sound library.

Something like

    Sound play: 'mooh'

When I look at class AbstractSound I wonder if it is still abstract?

Could it be an idea for a refactoring exercise. Have AbstractSound and
then Sound as subclass and then SampledSound. As a beginner with
Squeak (a multimedia environment) I would expect a class 'Sound' to be
there.


--Hannes



SampledSoundPlaySoundNamed.PNG (79K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: Sound-wiz.17.mcz

Andreas.Raab
On 4/28/2010 8:27 AM, Hannes Hirzel wrote:
> If I remember well the point of departure for Jerome was that there is
> no Beeper class anymore. And he wants to have a replacement for that.

Not exactly. The method Object>>beep: was removed. Class Beeper is still
there. That's why my original recommendation was to implement
Beeper>>beep: and get on with it. It seems like Jerome got a bit
side-tracked in explorations of language :-) I would still say that the
best way to address the problem is to implement the idiomatic "Beeper
beep:" and leave the String protocol alone.

Cheers,
   - Andreas

>
> There is the class side of SampledSound / category 'sound library' /
> method 'playSoundNamed'.
>
> The method returns nil in case the sound is not there. And that method
> needs to be fixed.
> If I want the computer to play a sound and it does not find a sound at
> least I a 'beep' sound.
>
> This is what Jerome implemented in the String library. I do not thing
> that it belongs to that place. It belongs to SampledSound. I put in a
> proposal in the inbox. It currently gives a visual feedback (a dialog
> box) plus a beep sound if a sound is not found.
>
> However I am not pleased with this solution actually.
>
> I think we should have an easier interface for the Sound library.
>
> Something like
>
>      Sound play: 'mooh'
>
> When I look at class AbstractSound I wonder if it is still abstract?
>
> Could it be an idea for a refactoring exercise. Have AbstractSound and
> then Sound as subclass and then SampledSound. As a beginner with
> Squeak (a multimedia environment) I would expect a class 'Sound' to be
> there.
>
>
> --Hannes
>
>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: Sound-wiz.17.mcz

Chris Muller-3
In reply to this post by Hannes Hirzel
Sorry for a late reply, I've been struggling to keep up lately..  Just
one comment:

> The method returns nil in case the sound is not there. And that method
> needs to be fixed.
> If I want the computer to play a sound and it does not find a sound at
> least I a 'beep' sound.

Which sound plays _could_ be very important; think of a sight-disabled
person, for example.

In that case, I think if the application asks the system to play a
sound that does not exist, an exception should be signaled.  At that
point, the application can handle that exception and play a default
beep sound if that is the desired behavior.  That way test can catch
it easier too, so that mere 'beeps' do not end up replacing the proper
sound in an app simply because it was not caught by testing..

Regards,
  Chris