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

Sp00 Final Exam Review: Multimedia Programming in Squeak

See Final Exam Review - Sp2000

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'm not sure what this means. What lines are you talking about? Lines of code? Lines within a box? Do you mean for us to use something like PluggableButtonMorphs that are lined up in a Pen-drawn box that respond by playing appropriate notes when clicked on??? What duration should the synthesized sound playback take? Matthew Wolenetz
Lines of the box. This is much simpler than you're interpeting it as. A box has four sides. Draw a line, play a note, draw a second line, draw the second note, etc. 1.0 seconds duration. Mark Guzdial

Here is my solution to how I interpereted the problem for part (a):

myPen := Pen new.
myPen up.
myPen goto: 300@300.
myPen down.
myPen north.
myPen goto: 300@200.
(AbstractSound noteSequenceOn: (FMSound soundNamed: 'clarinet') from: #((c4 1.0 500)))play.
(Delay forSeconds: 2)wait.
myPen turn: 90.
myPen goto: 400@200.
(AbstractSound noteSequenceOn: (FMSound soundNamed: 'clarinet') from: #((d2 1.0 500)))play.
(Delay forSeconds: 2)wait.
myPen turn: 90.
myPen goto: 400@300.
(AbstractSound noteSequenceOn: (FMSound soundNamed: 'clarinet') from: #((e3 1.0 500)))play.
(Delay forSeconds: 2)wait.
myPen turn: 90.
myPen goto: 300@300.
(AbstractSound noteSequenceOn: (FMSound soundNamed: 'clarinet') from: #((f4 1.0 500)))play.

Ryan Blane


I also noticed there was a FMClarinetSound, but I couldn't use it, I kept getting errors. How do you use that?

And for the second part, is there a simpler way to move the ellipse? Setting the bounds keeps resizing it when I am trying to move it.

Here is my code for the second part:

m := EllipseMorph new.
m color: (Color red).
m openInWorld.

(AbstractSound noteSequenceOn: (FMSound soundNamed: 'flute1') from: #((c4 1.0 500)))play.
(Delay forSeconds: 2)wait.
m bounds: (Rectangle left: 50 right: 100 top: 0 bottom: 50).

(AbstractSound noteSequenceOn: (FMSound soundNamed: 'flute1') from: #((d4 1.0 500)))play.
(Delay forSeconds: 2)wait.
m bounds: (Rectangle left: 50 right: 100 top: 50 bottom: 100).

(AbstractSound noteSequenceOn: (FMSound soundNamed: 'flute1') from: #((e4 1.0 500)))play.
(Delay forSeconds: 2)wait.
m bounds: (Rectangle left: 0 right: 50 top: 50 bottom: 100).

(AbstractSound noteSequenceOn: (FMSound soundNamed: 'flute1') from: #((f4 1.0 500)))play.


The problem I am having with this is that it will play the notes, but it doesn't show the ellipse until all the movements and the music is done. Ideas?

Susi Rathmann

p. 246 in the book: "World doOneCycle" Mark Guzdial

Thanks! So, here is my updated and working code:

m _ EllipseMorph new.
m color: (Color red).
m openInWorld.

World doOneCycle.
(AbstractSound noteSequenceOn: (FMSound soundNamed: 'flute1') from: #((c4 1.0 500)))play.
(Delay forSeconds: 2)wait.
m bounds: (Rectangle left: 50 right: 100 top: 0 bottom: 40).

World doOneCycle.
(AbstractSound noteSequenceOn: (FMSound soundNamed: 'flute1') from: #((d4 1.0 500)))play.
(Delay forSeconds: 2)wait.
m bounds: (Rectangle left: 50 right: 100 top: 40 bottom: 80).

World doOneCycle.
(AbstractSound noteSequenceOn: (FMSound soundNamed: 'flute1') from: #((e4 1.0 500)))play.
(Delay forSeconds: 2)wait.
m bounds: (Rectangle left: 0 right: 50 top: 40 bottom: 80).

World doOneCycle.
(AbstractSound noteSequenceOn: (FMSound soundNamed: 'flute1') from: #((f4 1.0 500)))play.



here's my code. it's mostly the same, but makes the bounds: calls a bit nicer...

e _ EllipseMorph new.
e openInWorld.
e color: Color red.

e bounds: ( 0@0 corner: 50@40 ).
(AbstractSound noteSequenceOn: (FMSound soundNamed: 'brass1') from: #((c4 1.0 500))) play.

e bounds: ( 0@100 corner: 50@140 ).
(AbstractSound noteSequenceOn: (FMSound soundNamed: 'brass1') from: #((d4 1.0 500))) play.

e bounds: ( 100@100 corner: 150@140 ).
(AbstractSound noteSequenceOn: (FMSound soundNamed: 'brass1') from: #((e4 1.0 500))) play.

e bounds: ( 100@0 corner: 150@40 ).
(AbstractSound noteSequenceOn: (FMSound soundNamed: 'brass1') from: #((f4 1.0 500))) play.


[Four times almost the same chunk of code?!
"Once and only once ..."
mailto:A.Kuckartz@ping.de]

Link to this Page