=== Top of the Swiki === Attachments ===

Playing Via Note-Names

(PluckedSound namedNoteSequenceFrom: #( (c4 1 500)
(d4 1 500) (e4 1 500) (f4 1 500) (g4 1 500)
(a4 1 500) (b4 1 500) (c5 1 500)))
play

Purpose:
Anybody remember the old PLAY command in early BASICs, where you could enter a tune encoded in a string and it would play it through the scratchy speaker? This is similar. namedNoteSequenceFrom: expects an array of either:
* Triplets of note (a-g, optionally b or s for flat or sharp, and a number indicating octave), duration, and loudness. The loudness range is 0..1000; 100 is too soft to hear on my PowerMac, and 1000 is full volume.
* Or a double of #rest and a duration.

Sending this to a subclass of AbstractSound will create the sound. Tell the sound to play to hear it.

Why This is Interesting:
Squeak has some powerful music capabilities: sound synthesis, stereo sound, etc. This is a starting point into them. If you look at the class method examples in AbstractSound, you'll find a lot more.



I couldn't get Mark's code to run, but here is what
I got to work (Sq 2.6 on windows) :
|scale|

scale := OrderedCollection new.

scale addAll: #( (c4 1 500) (d4 1 500) (e4 1 500) (f4 1 500) (g4 1 500) (a4 1 500) (b4 1 500) (c5 1 500) ).

(AbstractSound noteSequenceOn: PluckedSound new from: scale) play
Craig Anderson