UMass Lowell Dept. of Computer Science
COMP 2120 / MUED 2120 — Sound Thinking
Spring 2016 Semester, Section 201
Prof. Jesse M. Heines and Prof. Gena Greher
Notes for Class No. 17
Lists Revisited and Introduction to Transposition and Assignment No. 6
Thursday, March 24, 2016
A video of this class is (or will be) posted at: http://echo360.uml.edu/heines2016/comp-mued2120.html
Handouts and Materials
Openings / Announcements / Reminders
Class Notes
List Examples
Harry Potter Theme — https://scratch.mit.edu/projects/25256909/#editor
- don’t forget to set Turbo Mode
- notice how the buttons work and how the messages appear and disappear
- notice the programming pattern we reviewd in our last class in Version 2
- notice what happens when you click the arrows in Version 2
Do Re Mi — https://scratch.mit.edu/projects/20127614/#editor
- what is different about the Notes and Durations lists in this example?
- how does the code deal with that difference?
Row, Row, Row Your Boat — https://scratch.mit.edu/projects/1237114/#editor
- don’t forget to set Turbo Mode
- using the technique introduced with Do Re Mi to play a round
- this version uses the built-in Scratch time to enhance synchronization
Different ways to code notes in lists — https://scratch.mit.edu/projects/54423380/#editor
- what are the differences in the three stacks in Sprite1?
- what are the differences in the offsets and HarMinor lists in Sprite2?
Review of List Concepts
- loops and how they can be used to play all the notes from a list
- “deltas” or “offsets”
- “delta” is the Greek letter Δ
- it is typically used to denote a change from one value to another
- in the context we’ve been talking about, a delta and an offset and a change are all the same thing
- different ways to play music from a list in different keys
- by adding a delta or offset to the note value read from the list
- by reprogramming the list itself to contain deltas (or intervals) rather than absolute note values
- different ways to use deltas in lists
- as offsets from the starting note (the first note of the piece)
- as offsets from the tonic note (the “key” note of the piece)
- as offsets from the previous note (the one that immediately precedes it in the list)
In-Class Exercise
Starter Program
http://scratch.mit.edu/projects/19994891/
- what’s going on here?
- what do we need to do to make the music better?
- how do you suggest that we approach the issue?
Here’s a link to the song
https://www.youtube.com/watch?v=A_MjCqQoLLA&t=0m55s
For those of you who read music, here is the score from which this was programmed
The important thing to look at is the list that plays the notes
- what do you notice about this list?
- what do you think of the coding scheme?
- why do you think it was done this way?
The final step is to understand how the list is processed
- the key is that lists can contain strings of characters (note designations in this case) and that one can use those strings in broadcast blocks
- notice how there is a when I receive block for every possible entry in the Notes list, including a rest
- also notice how the two sprites are used, and how an initialize stack is used to keep the main stack (the one that contains the loop) clean and short
What you are to do
- use my work as a template to add a list of note (and rest) durations (the rhythm of the song)
- use those list values inside the loop to set the BeatsToPlay variable before the broadcast block
- test your work thoroughly and compare it to your neighbors’ solutions