Virtual Musical Instrument with Scratch
Christopher Michaud, Marist School
Lesson Overview
Learning Objectives and Evidence Statements
1.2.1 Use computing tools and techniques for creative expression. [P2]
1.3.1a Programs can be developed for creative expression or to satisfy personal curiosity. [P2]
5.1.1a Programming instructions are processed during program execution.
5.2.1.a Functions are reusable programming abstractions.
5.2.1c Container abstract data types (ADTs), such as set or list, enable programming.
Evidence Statements:
Students will create a virtual musical instrument with Scratch.
Students will create event driven actions to respond to user input such as clicking or typing on a
keyboard character.
Students will use a variable to control settings such as instrument timbre in a music simulation.
Students will design a user interface that will provide graphic feedback to user events.
Prerequisite knowledge
Students will know how to start, save, and name a Scratch Project
Essential/Guiding Question(s)
How do computer programs simulate real world objects?
How do we create a user interface that provides feedback to user events such as clicking on an
object or touching a keypad character?
How can variables and Lists store data and settings in a computer program?
Lesson Summary
This lesson uses Scratch to model the visual and sound aspects of creating a computer simulation of a
musical instrument.
Outline of lesson
Demonstrate real world instrument (such as xylophone, percussion, piano). Students identify the
“parts” of the instrument and their functions. (20 minutes)
As a class, develop procedure to model what happens when a xylophone bar, piano key, or
instrument is struck or played. Translate this into an action on the computer keyboard and result
on screen and sound. (20 minutes)
Demonstrate with Scratch how to create a Sprite and assign a sound and event. Teacher may use
the attached instructions to guide students through creating the first part of the Scratch xylophone
project. (30 minutes)
Students work on finishing Scratch instrument project. (40 minutes)
Students customize their xylophone project to add features such as recording, or changing to a
different type of musical instrument. (40 minutes)
Lesson Details
Student Activities
As a group, students will identify and components and procedures for modeling a musical instrument.
Individually, students will design graphics and select sounds to create their virtual instrument in Scratch.
Students will also use variables to store settings for their instrument and lists to give recording
functionality to their programs. Finally, students will combine these elements to create their own version
of an electronic virtual instrument.
Teaching and Learning Strategies
Provide a detailed description of what teachers will be doing in all parts of the lesson, and suggestions on
instructional and classroom practices. This should include:
Class discussion on components and function of real and electronic instruments.
o How is sound produced?
o What controls the pitch and volume?
o How do electronic instruments differ from acoustic instruments?
Individual and class work on creating the first bars of a Scratch virtual xylophone. Teacher can
use attached directions, or students may work from directions.
Students who finish may modify their instruments to ‘record’ using the attached directions as a
guide.
Students create their own version of an electronic instrument using variables, lists, images, and
sounds that they select.
Appendices
Materials and Resources
Attached: Directions for Scratch xylophone and Scratch playback xylophone.
Directions available online at:
http://nebomusic.net/scratchxylophone.html
http://nebomusic.net/scratchxylophone2.html
Supplemental Resources
Optional Handout: Directions for Creating a Virtual Xylophone
in Scratch
Working Sample:
1. Start Scratch. Delete the Cat. Name the project “lastname xylophone”
2. Create a Variable Called "Instrument"
a. Click Orange Data Block
b. Click "Make a variable"
c. Type "Instrument"
d. Click "OK"
3. Double Click on Instrument Variable to get a slider. (You can use this to change instrument sounds in
your program.)
4. Click Paint a New Sprite.
a. Draw a Large Rectangle and fill with a color.
b. Use text tool and put a "C" in the lower part of the "Bar."
c. Click OK
d. Name this Sprite "LowC"
5. Click "Costumes" Tab on "LowC"
6. Right click on costume and select “duplicate”
7. Click on “Costume 2”
8. Use Flood Fill to make the outline of the Bar white.
9. Click "OK"
10. Click on "Stage"
11. Click on "Backgrounds" Tab.
12. Click "Edit"
13. Flood Fill the stage so it is a solid color.
14. Click Ok
15. Your Stage should look like:
16. Add this Script to "LowC" Sprite (to play when clicked)
17. Add this Script to "LowC" Sprite (to play when 1 key is pressed)
18. The entire Script should look like:
19. Click the Green Flag and Test - it should play 1 note)
20. Use stamp tool to copy the "LowC" Sprite
21. Make the Following Changes to new Sprite
a. Use Shrinker Tool to make it smaller
b. Change the "Go To" to a the new x and y position
c. Change the "play note" to 62 (Pitch name D) in when LowC clicked
d. Change when 1 key pressed to when 2 key pressed
e. Change the "play note" to 72 (Pitch name D) in when 2 key pressed
f. Edit the Costumes so "D" is on the Bar
22. Finished Script for D Bar should look like:
23. Click the Green Flag and test the scripts. You should be able to play two pitches.
24. Use the copy tool and create the rest of the Xylophone. The finished stage should look like
25. Modify the scripts so the xylophone can play all eight notes.
Optional Handout: Directions for Creating a Playback
Xylophone in Scratch
Working Example
Requirements
1. Add a Red button that starts recording the user playing. Notes are stored in a list.
2. Add a Square button that stops the recording.
3. Add a Green Triangle that triggers the Program to play back what the user had recorded.
Instructions for Adapting Xylophone Project to Playback Xylophone
1. Start with a completed Xylophone Scratch Project.
2. Add the following variables and list to the Xylophone Project.
Variables:
Instrument
NoteListItem
RecordOn
List:
NoteList
3. Draw three additional Sprites:
-Green Play Triangle
-Red Circle for Record
-Grey Square for Stop
4. Add the scripts for the "Stop Button" Sprite.
5. Add the scripts for the "Record Button" Sprite.
6. Add the scripts for the "Playback Button" Sprite.
7. Change the scripts for the Low C Sprite.
8. Change the scripts for the D Sprite.
9. Change the scripts for the E Sprite.
10. Change the scripts for the rest of the bars in the program.
11. Put these scripts on the stage to control recording and playback.
12. Save and test your program!
Scratch Virtual Instrument Project
Grading Rubric
Maximum Points: 100
1. Complete project from directions with following capabilities
a. Pitched Instrument capable of playing complete 8 note scale from click events. (20
points)
b. Keyboard events (ex 1, 2, 3, 4) also allow for playing of pitches. (20 points)
c. A Variable and controls to change instrument or timbre. (20 points)
d. Visual feedback to user indicating that note has been played. (20 points)
Total: 80 Points
2. Pitched Instrument project with recording function
a. Modify the pitch instrument project to store user notes in list.
b. Provide recording and playback controls to replay user input.
Total: 15 Points
3. Additional virtual instrument
a. Create a non-pitched or sound effect instrument with sounds and graphics of your
choosing.
b. Must have at least 6 different graphics and sounds.
c. Must have a variable to control an aspect of the sound (volume, instrument type, tempo,
duration)
d. Provide the capability for user to record sounds for playback.
Total: Up to 20 Points