Sec 9-12 Scribbler Music

advertisement
• Your robot can play a note by “beeping”
• Every note in music has a “frequency”
– Physics of Frequencies:
(http://www.phy.mtu.edu/~suits/notefreqs.html)
• Notes can be controlled by beeping the
correct frequency.
– beep(1, 440) -- Beep note A4 (That’s an “A” in the
4th octave)
• Programming music by frequency is difficult!
– It’s a lot of numbers!
• Scribbler has set of functions that help go
from notes to frequencies.
• Scribbler has a range of 8 octaves (same as a
piano)
• Scribbler has all the notes. They are denoted:
C C#/Db D D#/Eb E F F#/Gb G G#/Ab A A#/Bb B
• That is also the
default octave
which is the 5th
octave.
• You can create a
song in
python/scribbler
by simply giving
the note and
length of the
note:
e .25
d .25
c .25
d .25
e .25
e .25
e .25
d .25
d .25
d .25
e .25
g .25
g .25
e .25
d .25
c .25
d .25
e .25
e .25
e .25
e .25
d .25
d .25
e .25
d .25
c .25
F G .25
F G .25
F G .25
F G .25
F G .25
F G .25
Scribbler Robots
can play 2 notes
simultaneously.
Simply list the 2
notes on the
line.
E G .25
E G .25
E G .25
E G .25
E G .25
E G .25
D B .25
D B .25
D B .25
D B .25
D B .25
D B .25
C C6 .5
C C6 .25
C C6 .25
D B .25
E A .25
C C6 .25
F G .25
F G .25
F G .25
F G .25
F G .25
F G .25
C1 .25
C1 .25
C6 E6 .25
B D6 .50
A C6 .25
G B .50
F A .25
E G .25
E G .25
E G .25
E G .25
F A .25
E G .25
D F .25
D F .25
D F .25
D F .25
E G .25
D F .25
C E .25
D F .25
E G .25
E G .25
E G .25
E G .25
E G .25
E G .25
E G .25
D B .25
D B .25
D B .25
D B .25
E A .35
D B .25
C C6 .25
F G .25
REST .50
C6 E6 .25
B D6 .50
A C6 .25
G B .50
F A .25
E G .25
E G .25
E G .25
E G .25
F A .25
E G .25
D F .25
D F .25
D F .25
D F .25
E G .25
D F .25
C E .25
F G .25
F G .25
F G .25
F G .25
F G .25
F G .25
E G .25
E G .25
E G .25
E G .25
E G .25
E G .25
D B .25
D B .25
D B .25
D B .25
D B .25
D B .25
C C6 .5
C C6 .5
C C6 .5
D B .25
E A .25
F G .25
F G .25
F G .25
F G .25
F G .25
F G .25
E G .25
E G .25
E G .25
E G .25
E G .25
E G .25
D B .25
D B .25
D B .25
D B .25
E A .35
D B .25
C C6 .25
F G .25
C C6 .50
• Once you have the notes you need to add the
timing. A whole note is 1 and half note is .5,
etc.
• Normally a whole note is about .5 secs. You
can change the tempo but sending a
parameter in playSong() function.
• Now take the notes and the timing and you
create a song!
• Listen…
from myro import *
robot=Scribbler()
s=readSong("chariots of fire.txt")
robot.playSong(s)
• Find a song. You need the music to the song!
• Code a minute of the song correctly in
“scribbler” music
• Everyone needs to do their own song! There
are enough robots for everyone.
Whole note/rest
Half note/rest
Quarter note/rest
Eighth note/rest
• If you don’t
understand K’s
and H’s, talk to
me and I’ll try
and explain!
Download