links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
Playing music with note names
Last updated at 1:20 pm UTC on 10 November 2015
(AbstractSound noteSequenceOn: PluckedSound default from: #((c4 1 500) (d4 1 500) (e4 1 500) (g4 1 500) (a4 1 250)(a4 1 250) (c5 1 500))) play

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:
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. – Mark Guzdial

Remark: #( () () () ) is the syntax for building an array of literals. Here it is an array of arrays. The notes are defined as symbols.

Retested with 3.5-5168 on 12-FEB-2003 hjh

The following modification on Squeak v3.4 #5170 works,
(AbstractSound noteSequenceOn: PluckedSound default from: #((c4 1 500) (d4 1 500) (e4 2 500) (g4 1 500) (a4 1 500)(a4 1 550) (c5 1 500))) play.

a little movie madness:
(AbstractSound noteSequenceOn: FMBassoonSound default from: #((d4 0.5 500) (e4 0.5 500) (c4 0.5 500) (c2 0.5 500) (g2 2 500))) play.

mike reavey