Pages

23.7.11

Digital Music Boxes: Random Music Or Simple Synthesizers Using Scratch

Last term we worked with our phase three students to Design and Make computer games using Scratch.  One of the Focussed Practical tasks I used emerged from a music session I taught with some of our younger students exploring pitch and composing musical phrases using the pentatonic scale. 

I knew that Scratch could be used to create music, and had used the pentatonic scale during impovisation and composition activities with students in my primary classes to great effect.  I wondered how it would pan out if I involved my Phase 3 students in programming a simple random music generator.

To begin two sprites were created.
  • A Musical Note: that was programmed to bounce around the screen randomlyish!
  • The second a musician sprite programmed as above but also to play a single musical note from the chosen scale, when it touched the note.

The Musical Note.
This was created using the paint a new sprite tool, and in my case looked like this.

Behind the musical note sprite I added the following pair of scripts.








When we set up the task the "when green flag is clicked" header block was was added from the control block to both scripts.  However before running the program the header block from one of the scripts was removed.

The first script, Script one in the image, allows some user control, with the musical note following the mouse pointer, in effect allowing the user to play notes in the order they choose.  A simple musical instrument or synthesiser.

The second script in the image. Script two has a very different effect setting the note moving under its own steam, when the gren flag is clicked, playing any note it comes into contact with in the order it meets it...  But not quite yet, as we don't have any musician sprites.


Musician Sprites
The first musician sprite and its scripts were created by choosing a character through the "insert sprite from file" option. and then adding the following script.  The musical elements of this coming in the form of elements from the "sound" blocks.


Completing My Digital Musical Box
So far I have one musical note and one musician.  I need 5 musicians and each need to be tuned to play one note from the pentatonic scale.  To achieve this I created 4 duplicates of my first musician sprite, by right clicking and selecting duplicate from the menu.

Next I changed the Sound script elements of each sprite.  I kept the instrument and duration or beat the same in each case but changed the note value, and renamed the sprite accordingly so

Musician Sprite 1 was renamed playc        Plays note number 60
Musician Sprite 2 was renamed playd        Plays note number 62
Musician Sprite 3 was renamed playe        Plays note number 64

Musician Sprite 4 was renamed playg        Plays note number 67
Musician Sprite 5 was renamed playa        Plays note number 69

Each Musician Sprite was also given a change of costume to uniquely identify them onscreen

Now on pressing the green flag each of the musician sprites begin moving randomlyish around the screen, as does the musical note.  Each time a musician meets the note it contributes its sound to the tune.

I have to say at this point each individual student loved this a lot more than those around them.  With the programming in place, I found now that the learning began through play and creativity.  The students extended this task for themselves, experimenting and asking what would happen if they
  • added more musical notes?
  • changed the speed of the sprites?
  • Altered the instruments being played?
What I like about this activity is that from very simple programing we have two possible outcomes.
  1. The random music generator
  2. A very simple synthesiser
The random music generator, digital windchime or music box, allowed the students space to experiment and explore the effects of editing scripts on output.  The Synthesiser option provided a possible extension opportunity, where using static musician sprites and mouse control they could create a simple game or activity to help younger students create music, with additional outcomes being possible use of graphical scoring.  I intend to use this activity again myself perhaps as part of our moving on moving up week with new intake students, or in involving our students in preparing sessions to work with younger students on the campus.  I would be interested to hear from anyone who tries out this task with students and what they made of it too. :o)

No comments: