View this PageEdit this PageAttachments to this PageHistory of this PageHomeRecent ChangesSearch the SwikiHelp Guide
Hotspots: Admin Pages | Turn-in Site |
Current Links: Cases Final Project Summer 2007

Sp01 Final Exam Review: Multimedia Programming in Squeak

See Final Exam Review - Sp2001

Comments? Answers? Criticisms?

Write the Squeak code to draw a box, where you play C in the fourth octave during the first line, D in the second, E in the third, and F in the fourth – as a clarinet.

I don't understand this question. What has playing a note got to do with drawing a box? As a clarinet???

Thanks.
chok
Squeak can play notes. Do the drawing of the box as you're doing the playing. That's all. Mark Guzdial
should we pause the sound so you hear each note individually? Squeak does everything so quickly that it is playing mine as one ugly chord.
~Amy Hurst
There are a lot of methods that sounds respond to which can help you out....

a.
p _ Pen new.
p place: (100@200).

p go: 100.
p turn: 90.
(AbstractSound noteSequenceOn:
(FMSound soundNamed: 'clarinet')
from: #((c4 0.5 500))) playAndWaitUntilDone.

p go: 100.
p turn: 90.
(AbstractSound noteSequenceOn:
(FMSound soundNamed: 'clarinet')
from: #((d4 0.5 500))) playAndWaitUntilDone.

p go: 100.
p turn: 90.
(AbstractSound noteSequenceOn:
(FMSound soundNamed: 'clarinet')
from: #((e4 0.5 500))) playAndWaitUntilDone.

p go: 100.
p turn: 90.
(AbstractSound noteSequenceOn:
(FMSound soundNamed: 'clarinet')
from: #((f4 0.5 500))) playAndWaitUntilDone.

b.
m _ EllipseMorph new.
m color: Color red.
World addMorph: m.
m bounds: (0@0 extent: (50@50)); refreshWorld.
(AbstractSound noteSequenceOn:
(FMSound soundNamed: 'brass1')
from: #((c4 1.0 500))) playAndWaitUntilDone.

m bounds: (0@100 extent: (50@50)); refreshWorld.
(AbstractSound noteSequenceOn:
(FMSound soundNamed: 'brass1')
from: #((d4 1.0 500))) playAndWaitUntilDone.

m bounds: (100@100 extent: (50@50)); refreshWorld.
(AbstractSound noteSequenceOn:
(FMSound soundNamed: 'brass1')
from: #((e4 1.0 500))) playAndWaitUntilDone.

m bounds: (100@0 extent: (50@50)); refreshWorld.
(AbstractSound noteSequenceOn:
(FMSound soundNamed: 'brass1')
from: #((f4 1.0 500))) playAndWaitUntilDone.

Doug Powers



a.
p _ Pen new. p place: (200@200).
d := Delay forMilliseconds: 10.
(AbstractSound noteSequenceOn:
(FMSound soundNamed: 'clarinet')
from: #((c4 1 500) (d4 1 500) (e4 1 500) (f4 1 500)) ) play.

4 timesRepeat: [ 100 timesRepeat: [ p go: 1. d wait. ]. p turn: 90. ].

b.
xpos := 200. ypos := 200. mSize := 7@7.
m _ EllipseMorph new. m color: Color red.
m bounds: ( xpos @ ypos extent: mSize ). World addMorph: m.
d := Delay forMilliseconds: 10.

index := 1. dxArray := #( 1 0 -1 0 ). dyArray := #( 0 1 0 -1 ).

(AbstractSound noteSequenceOn:
(FMSound soundNamed: 'clarinet')
from: #((c4 1 500) (d4 1 500) (e4 1 500) (f4 1 500)) ) play.

4 timesRepeat: [
dx := dxArray at: index. dy := dyArray at: index.
index := index + 1.
100 timesRepeat: [
xpos := xpos + dx. ypos := ypos + dy.
m bounds: ( xpos @ ypos extent: mSize ); refreshWorld.
d wait.
].
].

chok (arghh.. can't get the indentation to display right)


Chok, you can use "& nbsp"(with no space) to force the html to display a space.
Doug Powers


yeah i know, i saw how you did the indentation for the Sensor Mgmt Sys, just put everything in one same line. never mind though.

chok



a.
notes := #(((c4 1.0 500)) ((d4 1.0 500)) ((e4 1.0 5000))).

p := Pen new.
p place: 200@200.
p down.
1 to: 3 do: [:i|
(AbstractSound noteSequenceOn: (FMSound soundNamed: 'brass1')
from: (notes at: i)) playAndWaitUntilDone.
p go: 100.
p turn: 90.
]

b. notes := #(((c4 1.0 500)) ((d4 1.0 500)) ((e4 1.0 5000)) ((f4 1.0 5000))).
locales := { 0@0 . 100@0 . 100@100 . 0@100 }.

e := EllipseMorph new.
e color: Color red.
e bounds: ( (locales at: 1) extent: 30@30).
e openInWorld.
1 to: 4 do: [:i |
e bounds: ( (locales at: i) extent: 30@30 ).
Transcript show: (e bounds printString).
(AbstractSound noteSequenceOn: (FMSound soundNamed: 'brass1')
from: (notes at: i)) playAndWaitUntilDone.
].





Link to this Page