Project 3: Multi-player Rhythms
Due midnight, Monday 1 March, 2010
In lab we made a function playtune that let us define a tune as a sequence of pitches and durations. By calling the function twice with different arguments, we enabled two simultaneous players. For this assignment, the goal is to end up with a 4-part rhythm sound machine where you control the speed of the sound machine in Max.
For this assignment, continue to use the same patcher and python file from lab.
- Create two more tune variables, similar to the ones we created in lab. Each tune variable should be a list with three elements. Set the first two elements to zero, and put your list of pitch/duration pairs in the third element. The easiest thing to do is copy one of the tunes from lab and then edit the sequence of pitch/duration values. Make sure you have four different sequences. When you are done with this step, you should have four variables, tune1 through tune4.
- Edit your patcher so that the script engine has eight outputs. Duplicate the makenote/noteout objects so there are four copies. You can set each noteout t a different channel if you wish. Connect them appropriately to the script engine outputs.
- Edit your play function so that it calls the playtune function for all four of your tune variables. Make sure you send each tune to a different pair of outputs. Then load your script and try running it with the four rhythm sections.
Edit your patcher so that you can control the speed of the metronome
with a slider. Create the slider, connect its output to the
metronome's right input. Then use the inspector window on the slider
to set its minimum value to 100 and range to 900. Does it work?
Next, add a new object under the slider and give it the text prepend play. Route the slider's output to its input, and then route the prepend output to the right input of the play message box. Now the time unit sent to the metronome should also go to the python engine.
Create a new python function called solo, that calls playtune for just
one tune (pick your favorite). It should have two lines in it. One
global statement, and one call to playtune.
In Max, create a message box for calling the solo function. Then create a gswitch2 object to route the metronome to either the play message box or the solo message box. Use a checkbox to control the switch. Now you should be able to switch between one tune and all the tunes.
Pick one of your tunes to be the lead ( or make a new one), letting
the rest be conceptually rhythm and/or accompaniment. In other words,
the lead should be the most interesting player. Make the lead do two
things differently than the other tunes. First, make it louder.
Second, make the lead pattern move between different base pitches.
One way to implement the lead is to copy your playtune function, rename it playlead, and then edit it to implement the changes. The key change in the python function is to generate a random offset to the pitch that should change once per loop through the pattern. You will need to store it in a new global variable, or better as a value at the end of the list holding the tune data. The change in volume you can implement by editing the makenote object that is playing the lead tune.
Here are some suggested extensions
- Each tune or rhythm is stored as a list of pitch/duration pairs. This list is the third element of each tunedata list. In the random package, there is a function called random.shuffle(). It takes one argument, which must be a list, and shuffles the ordering of its elements. Try using the random.shuffle() function to change around your patterns. For example, you could create a function that does the shuffling when you call it using a message box in Max.
- Can you set up your sound machine so you can turn each tune on and off individually?
- Have some of your tunes be rhythm, and some be melody.
- Make really cool rhythms/tunes. Put some effort into it.
- In the first lab, we parameterized tunes with a base pitch. Try adding a base pitch to a tunedata list and then enable Max to change it. I would suggest doing this with a copy of your python and patcher files and working with a single tune structure until you have it working.
Once you are finished with your work, put the python and Max files, and anything else you want to hand in, into your handin folder on the Academic server.
Each of you should create your own wiki page for your writeup.
The title of your page should be something appropriate, like Project 3 and your name. Please put the label cs198s10proj3 on your writeup page (labels are down below the editing window on the edit tab).
For this week, your writeup should consist of your answers to the following questions.
- What effect(s) were you trying to achieve with your rhythms?
- The function playtwo we made in lab, and the function playtune implement the same algorithm. The playtune function, however, is much more general. What is the difference between the two?
- How are we representing all of the information needed to play a tune? What information are we storing? How are we storing it?
- How could we represent a collection of rhythms or tunes?
- Include a description of any extensions you completed.