The computer speakers can be loud. So, you may want to adjust the volume. For example, on the Mac keyboard you can use the F11 and F12 keys.

Similar documents
MUSC 1331 Lab 1 (Sunday Class) Basic Operations and Editing in Performer. Quantization in Performer

Classroom. Chapter 1: Lesson 6

Impro-Visor. Jazz Improvisation Advisor. Version 2. Tutorial. Last Revised: 14 September 2006 Currently 57 Items. Bob Keller. Harvey Mudd College

How to use EndNote? Training. Faculty of Fisheries and Protection of Waters USB Academic Library of USB March 26, 2015

Igaluk To Scare the Moon with its own Shadow Technical requirements

(Skip to step 11 if you are already familiar with connecting to the Tribot)

Go! Guide: The Notes Tab in the EHR

Lab experience 1: Introduction to LabView

Exercise #1: Create and Revise a Smart Group

EndNote Miscellany. 2 Backing Up an EndNote Library

Sibelius Projects for Students

VIDEOPOINT CAPTURE 2.1

A-ATF (1) PictureGear Pocket. Operating Instructions Version 2.0

Notes for Instructors Using MacGAMUT with The Musician s Guide Series (MGS)

Music Tech Lesson Plan

Notes for Instructors Using MacGAMUT with Listen and Sing

The. finale. Projects. The New Approach to Learning. finale. Tom Carruth

Away from home and realized you forgot to record a program, or want to see what is on TV tonight? No worries, just access MyTVs App!

***Please be aware that there are some issues of compatibility between all current versions of EndNote and macos Sierra (version 10.12).

Introduction to capella 8

INTRODUCTION TO ENDNOTE

Analyzing and Saving a Signal

Lab P-6: Synthesis of Sinusoidal Signals A Music Illusion. A k cos.! k t C k / (1)

Quick Start Guide Building and Scheduling a Show

Some features of children s composing in a computer-based environment. Figure 1. Screenshot of the MelodyMaker application

Period #: 2. Make sure that you re computer s volume is set at a reasonable level. Test using the keys at the top of the keyboard

Class Notes for Cite While You Write Basics. EndNote Training

Flute Warm-Up. Remember - When you practice at home START WITH A GOOD WARM-UP TO WORK ON YOUR TONE!!!

Creating Licks Using Virtual Trumpet

MyTVs App for Android TM

La Salle University. I. Listening Answer the following questions about the various works we have listened to in the course so far.

Rhythmic Dissonance: Introduction

Content Map For Fine Arts - Music

A BEGINNER'S GUIDE TO ENDNOTE ONLINE

OVERVIEW. 1. Getting Started Pg Creating a New GarageBand Song Pg Apple Loops Pg Editing Audio Pg. 7

PHY221 Lab 3 - Projectile Motion and Video Analysis Video analysis of flying and rolling objects.

Euphonium Warm-Up. Remember - When you practice at home START WITH A GOOD WARM-UP TO WORK ON YOUR TONE!!!

Experiment 2: Sampling and Quantization

Chapter 40: MIDI Tool

Arkansas High School All-Region Study Guide CLARINET

Primo Theory. Level 5 Revised Edition. by Robert Centeno

Meet Edison. This is Edison, the programmable robot. What is a robot? A robot is a machine that can be made to do a task on its own.

Make Music Cards. Choose instruments, add sounds, and press keys to play music. scratch.mit.edu. Set of 9 cards

Health Sciences Library System University of Pittsburgh. Instructors Andrea Ketchum, MS, MLIS / Patricia Weiss, MLIS /

1 Overview. 1.1 Nominal Project Requirements

Saxophone Warm-Up. Remember - When you practice at home START WITH A GOOD WARM-UP TO WORK ON YOUR TONE!!!

fxbox User Manual P. 1 Fxbox User Manual

Getting started with music theory

sonic pi / Jungle Doctor Who

Oak Bay Band MUSIC THEORY LEARNING GUIDE LEVEL IA

Study Guide. Solutions to Selected Exercises. Foundations of Music and Musicianship with CD-ROM. 2nd Edition. David Damschroder

Diamond Piano Student Guide

To complete this document, you will need the following file:

GarageBand Tutorial

Abigail S. Blair IMEC January 27, 2012

Amazon Account 3/14 TM 1

DSP First Lab 04: Synthesis of Sinusoidal Signals - Music Synthesis

Task-based Activity Cover Sheet

SmartScore Quick Tour

Music Ace Deluxe Contents

In this project you will learn how to code a live music performance, that you can add to and edit without having to stop the music!

RefWorks Using Write-N-Cite

EndNote. Version X3 for Macintosh and Windows

The Basics of Reading Music by Kevin Meixner

Footnotes and Endnotes

Sibelius In The Classroom: Projects Session 1

Smart Pianist Manual

Steps: Word Projects I. Hint. Hint. Word 8. Word 2010

Lab #10 Perception of Rhythm and Timing

Resources. Composition as a Vehicle for Learning Music

MyTVs Menu. Recordings. Search. What s Hot. Settings

What can EndNote do?

Introduction to EndNote Desktop

CSC475 Music Information Retrieval

Use Case Diagrams & Sequence Diagrams

SOUNDLIB: A MUSIC LIBRARY FOR A NOVICE JAVA PROGRAMMER

Northeast High School AP Music Theory Summer Work Answer Sheet

Trombone Warm-Up. Remember - When you practice at home START WITH A GOOD WARM-UP TO WORK ON YOUR TONE!!!

Eventide Inc. One Alsan Way Little Ferry, NJ

About Importance of Truth

Select Presentation from System Mode

MultiQ Digital signage template system for widescreen monitors

Essential Keyboard Skills Course Level 1 Extension Activity Workbook

Standard 1: Singing, alone and with others, a varied repertoire of music

Physics 105. Spring Handbook of Instructions. M.J. Madsen Wabash College, Crawfordsville, Indiana

Formatting Dissertations or Theses for UMass Amherst with MacWord 2008

Nodal. GENERATIVE MUSIC SOFTWARE Nodal 1.9 Manual

Mendeley Basics. Get Mendeley. Get Articles and Documents into Mendeley. Import Citations from a Website

X-Sign 2.0 User Manual

Members QUICK REFERENCE GUIDE

The Keyboard. An Introduction to. 1 j9soundadvice 2013 KS3 Keyboard. Relevant KS3 Level descriptors; The Tasks. Level 4

Copyright Jack R Pease - not to be reproduced without permission. COMPOSITION LIBRARY

Keeping a Bibliography using EndNote

Music Department Music Literacy Workbook Name

Release Notes. MTX100A MPEG Recorder & Player RTX100A ISDB-T RF Signal Generator RTX130A QAM & VSB RF Signal Generator *P *

y POWER USER MUSIC PRODUCTION and PERFORMANCE With the MOTIF ES Mastering the Sample SLICE function

Cite While You Write Plug-In for Microsoft Word. The Cite While You Write plug-in creates an EndNote Web tab in Microsoft Word 2007.

AVerTV 6. User Manual. English DISCLAIMER COPYRIGHT

Virtual instruments and introduction to LabView

WIDEX FITTING GUIDE PROGRAMMING ZEN FOR WIDEX ZEN THERAPY COMPASS GPS INTRODUCTION BASIC WIDEX ZEN THERAPY FITTING STEPS FOR THE BASIC FITTING

Transcription:

1 CS 105 Lab #12 Making music in Python To begin, please create a new folder on your USB drive or account, and call it lab12. Save all of today s work there. The class handout showing you the musical scale may be helpful for this lab! Setting up The computer speakers can be loud. So, you may want to adjust the volume. For example, on the Mac keyboard you can use the F11 and F12 keys. Next, we need to install the Python music system. Go to the class Web site, and download all of the files in the music folder into your lab12 folder. In particular, note the large file jythonmusic.zip. This is a ZIP file, representing a large folder that has been compressed. To uncompress it, you can double click on the icon, and a folder called jythonmusic is created. Verify that this new folder resides inside your lab12 folder. Double-click on this folder icon to go into the folder. Find the file called JEM2.jar. Hold down on the control key, and select Open. (You might get a warning that Apple does not recognize this program.) JEM will take the place of IDLE today. You will need to keep the JEM program open throughout the lab today because we will use it to run all of our music programs. In the top-left corner of the JEM window, you should see two buttons that will be useful to us today. The triangle-shaped button is used when we want to run a program. The square button next to it may be helpful if you want to exit a program while it s running. In a way, these buttons have the effect of play and stop. Now we re ready for some music! A dry run Let s make sure that we are able to play anything and that your speakers are adjusted to the proper volume. Download one of the pre-existing Python music programs from the class Web site. For example, one-note.py. Save it to your lab12 folder. Inside JEM, go to the File menu and choose Open. Open the one-note.py program you just downloaded. You should see the source code appear in the JEM editor window. Now, click the run button. Did you hear anything? Now that we are done with one-note.py, we can close the file. Go to the File menu, and select Close. It is best to close a file when you are finished with it, so that you are only working on one program at a time.

2 Structure of a Python music program Today s programs will be short and they will have a simple structure, as follows: # example_template.py from music import * # Our music will be put into a "phrase." p = Phrase() # Here you can set tempo and/or instrument # To insert a single note, use p.addnote like this p.addnote(c4, QN) # Or, to insert a list of notes, create a list of pitches # and a list of durations, and then use p.addnotelist pitch = [C4, E4, G4] duration = [EN, EN, HN] p.addnotelist(pitch, duration) # To insert a chord, use p.addchord. But note that the # first argument is a list of pitches. chord = [BF3, D4, F4] p.addchord(chord, HN] # At the end of the program, we tell Python to play the music. # Please not that this play command should only appear once. As you can see, there are basically 4 essential things you must put in your program. Tell Python to include everything from the music library. Create a new Phrase. Add musical notes and other attributes such as tempo to the phrase. I usually like to set the tempo because the default tempo is often too slow. Play the phrase. Your first program: scales Our first program will work with the C major scale. Inside JEM, create a new Python program and call it scale.py. Type the following code into the editor:

3 # scale.py Practice with musical scales. from music import * pitch = [C4, D4, E4, F4, G4, A4, B4, C5] duration = [QN, QN, QN, QN, QN, QN, QN, QN] p = Phrase() p.settempo(120) p.addnotelist(pitch, duration) # We ll add more music later... Save and run your program. You should hear the C major scale! Next, let s add some more music. We will play the C major scale in reverse. There is a straightforward way to do this without typing all the notes again. Notice that we have a list called pitch. In Python, it s easy to reverse the order of elements in a list. If L is a list, then you reverse the list with the statement: L.reverse(). With this in mind, enter the code necessary to reverse the pitch list, and then run the program. It should play the C major scale going down immediately after it goes up. 1. What code did you need to add to your program to accomplish the descending scale? Before we continue, please enter a statement in your program that will reverse the pitch list again so that it is going in ascending order. Next, let s raise the scale to C#. We do so by adding 1 to each note in the list of pitches. Copy the following code into your program: pitch2 = [] for note in pitch: pitch2.append(note + 1) p.addnotelist(pitch2, duration)

4 Save and run your program. Your program should now play 3 scales: the C major scale going up, the C major scale going down, and then the C# major scale going up. You should notice a slight uptick in pitch, because C# is the next note higher than C. Finally, let s play some chords. Specifically, we will play all 12 possible major chords, from C major, C# major, D major,, all the way up to B major. We will insert each new chord into the phrase using a loop. Copy the following code into your program after the three scales you just did: chord = [C4, E4, G4] for i in range(0, 12): newchord = [chord[0] + i, chord[1] + i, chord[2] + i] p.addchord(newchord, HN) Save and run your program. Count the chords that you hear to verify that there are 12 of them. If we can play major chords, why not minor chords too? A minor chord is almost exactly the same as a major chord. The only difference is that the second note is one half step lower. So, rather than starting with [C4, E4, G4], we would start with [C4, EF4, G4]. In other words, the E becomes E-flat. Insert the code to play the 12 minor chords immediately after the major chords. The way you write the minor chord loop is the same as with the major chord loop. Have the instructor or lab aide listen to your program, and then you may close the source file. Hee-Haw! Let s write a little program that plays the same pair of notes several times in order to imitate the sound of a mule. Hee-haw-hee-haw-hee-haw-hee-haw! Create a new source file, and call it mule.py. In it, create a phrase, and set its tempo to 120 beats per minute. You should select an instrument other than a piano. Now, on to the notes. Write a for-loop with 4 iterations. Inside the for-loop, add a high note (the hee ) followed by a low note (the haw ). 2. What instrument did you use? What two statements did you put inside the body of your for-loop?

5 Save and close mule.py. Jaws Another music effect we should experiment with is the infamous motif from the movie Jaws. The purpose of this experiment is to slowly accelerate the sound. It won t work by modifying the tempo. Instead we will do something a little unusual: we will reduce the length of the notes by 10% on each iteration of a loop. Inside JEM, create a new source file called jaws.py. In it, create a new phrase, and set its tempo to 120 and its instrument to a BASSOON. Then, copy the following code into your program: # establish a starting duration beats = 3.0 for i in range(0, 24): p.addnote(, beats) p.addnote(, beats) beats *= 0.9 Note that I did not specify the pitches in the addnote() function calls. You should determine what these notes should be by experimentation. They should be one half step apart. After you have played your program and scared your neighbor, save and close your program. 3. Which two note values did you select? Why those in particular? A simple song We are now ready to tackle a song. Maybe you will recognize it. Create a new source file called row.py. I am going to give you the correct pitches, but not the correct durations. You will need to figure out how to set the durations appropriately in the program. Copy the following code into your program.

6 from music import * p = Phrase() p.settempo(100) # 120 is too fast pitch = [C4, C4, C4, D4, E4, E4, D4, E4, F4, G4, C5, C5, C5, G4, G4, G4, E4, E4, E4, C4, C4, C4, G4, F4, E4, D4, C4] # these durations are not right, but will be a good start duration = [] for i in range(0, 27): duration.append(qn) p.addnotelist(pitch, duration) Save and run the program. You need to fix the durations of this song. It turns out that the notes are not all quarter notes. So, instead of using a loop, it will probably be necessary to list the 27 notes individually, although many of the notes will have the same length. Important hint: many of the notes will have a length of one-third of a QN, and others will have a length of two-thirds of a QN. When you are ready to play, save your program. Run your program, and get your neighbor to start his/her program after yours has played the first 5 notes! Transcribing sheet music It would be a very useful skill if you could take sheet music of an actual song, and transcribe the notes into a Python program. Give it a try! On a separate paper you will find the score for Moon River. You should write your code so that it is easy for you to find each of the notes that you are transcribing. For example, each staff can correspond to one list of notes. Otherwise, it will be more difficult for you to find and correct a mistake. Play your musical piece for the instructor or lab aide.