Difference between revisions of "Software Lab NMC"

From CCRMA Wiki
Jump to: navigation, search
 
(48 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
<font size=5>Lab 1: Making Music with Pd in Satellite CCRMA</font><br>
 
<font size=5>Lab 1: Making Music with Pd in Satellite CCRMA</font><br>
Lab write-up due on Tuesday, July 12 at 9AM
+
Lab write-up due on Tuesday at 10AM
  
(For the lab write-up, answer all the questions asked below, and include pd patches of your solutions.)
+
Most instructions by Edgar Berdahl, and lab patches for musical interaction description by Matt Wright and possibly others
  
<!--  After completing the lab, create a text-file answering questions from the lab, describing what you authored/modified and anything we need to know to test your patch. Put this file in your lab1 folder. Then zip up your lab1 folder and email it to music250a-aut1011-staff@lists.stanford.edu. Please make the subject of the email "Lab 1 - yourlastname" so that it gets sorted properly upon receipt.   -->
+
For this lab you need your [http://ccrma.stanford.edu/~eberdahl/Satellite Satellite CCRMA kit], a computer to program it, and some headphones with a mini 1/8" stereo jack.
  
<font size=5>Lab 3: Beagleboard and Firmware Programming</font><br>
 
Due on Wednesday, October 13th at 5PM
 
  
For this lab you need your [[MaxKit]], and Pd on a computer. During this lab, you will assemble your ccrma@satellite kit and start to use it.
 
  
 +
== The Satellite CCRMA Setup ==
 +
Included in your kit you should have
 +
- Satellite CCRMA Hardware (Beagle Board + microSDHC memory card + Arduino Nano + solderless breadboard)
 +
- One 5V power adaptor to plug into the Beagle Board
 +
- One Ethernet cable for external communication
 +
- Arduino Nano
 +
- One adjustable-length USB cable
  
== The ccrma@satellite setup ==
+
If you are missing something, please go get it before assembling your kit. Make sure you plug the micro SDHC memory card fully into its seat so that it looks as shown inside the red box:
First, you'll need to set up your beagleboard, USB hub, and breadboard on a foamcore base. Included in your kit, you should have:
+
- White USB hub with RJ45 Ethernet jack
+
- Beagleboard
+
- A 4GB SD card to plug into the beagleboard
+
- One 5V power adaptor (for the USB hub)
+
- One Ethernet cable
+
- Arduino Nano (from your kit)
+
- Two GT Max adjustable-length USB cables
+
  
If you are missing something, please go get it before assembling your kit. Use one USB cable to connect the Arduino to the hub, and use the other USB cable to connect the beagleboard to the hub (only to provide power).
+
[[Image:Kitblank.jpg]]
  
[[Image:SatellitePhoto3.JPG]]
 
  
== Powering Up For The First Time ==
 
Plug the power cable from the 5V supply into the hub. You will see some lights turn on, flickering every now and then. This means that ccrma@satellite is booting up.
 
  
=== Connect To ccrma@satellite ===
 
In order to see what your ccrma@satellite kit is doing, you need to log in to it. To do so, connect the USB hub to your laptop using the Ethernet cable and [https://ccrma.stanford.edu/wiki/CCRMA_Satellite_How_To_Connect remotely open an SSH window on ccrma@satellite].
 
  
=== Avoid Powering Down the Board Without Halting it First! ===
+
== Powering Up For The First Time ==
Would you take the battery out of your laptop and unplug its power adaptor without shutting down? ''I don't think so!'' The same goes for ccrma@satellite because it is a small computer running linux. If you power if off without shutting down, then you can corrupt the files on the SD card, which in the worst case could cause it to stop booting up anymore, and we would have to burn you a new SD card! So just remember this: '''HALT ccrma@satellite BEFORE DISCONNECTING IT FROM ITS POWER!'''
+
Plug the Ethernet port of the Satellite CCRMA into your laptop. Then plug in the 5V power supply into the Beagle as shown below. You should see some lights turn on, flickering every now and then. This means that Satellite CCRMA is booting up.
  
Now we will test the halt procedure. Run the halt command as superuser by typing ''sudo halt'' at the ccrma@satellite prompt. Then you will again have to type in the password ''temppwd'' in order to have the privilege to run this command. The SSH connection will be closed, but it will still be 20 seconds or so before ccrma@satellite has completely shut down. (Note: The command ''sudo reboot'' would instead have caused ccrma@satellite to reboot itself.)
+
[[Image:Kitplugged.jpg]]
  
Wait an extra entire minute to ensure that ccrma@satellite is shut down. However, it will not power itself off. To do this, you need to disconnect the 5V power adaptor from the hub.
 
  
=== Getting Comfortable With ccrma@satellite ===
 
Turn on ccrma@satellite again using the same procedure as before where you plug the power into the USB hub. After about 30 seconds, the board should be booted up again, so you can log in again by running the command
 
  
''ssh -X ccrma@192.168.1.105''
 
  
If you list the device directory, you can see which devices are attached to linux. Type
+
== Connect To Satellite CCRMA ==
 +
In order to see what your Satellite CCRMA kit is doing and program it, you need to log in to it. To do so, follow [https://ccrma.stanford.edu/wiki/CCRMA_Satellite_How_To_Connect_RevC these instructions].
  
''ls /dev''
+
After you login, you will see the prompt ''ccrma@satellite:~$'' This means that you are logged into a computer named "satellite" as the user "ccrma", and you are currently in the directory ~, which is the shortcut for your home directory.
  
to get an idea. Wow, there are so many! To list the devices with serial interfaces type
 
  
''ls /dev/tty*''
 
  
Once of these devices should be ''/dev/ttyUSB0'' for the Arduino Nano. If you do not see this one, then try rebooting using ''sudo reboot'' to see if that fixes this problem. (If you reboot, this will take about 45 seconds, and you will have to login again using ''ssh''. If that doesn't work, come talk to us. If you are a linux pro, you can try to debug the problem yourself by typing ''dmesg'' and looking at the result.)
 
  
== Firmware Programming On Arduino ==
+
== Avoid Powering Down the Board Without Halting it First! ==
=== Compiling and uploading firmware code in the Arduino Program ===
+
Would you take the battery out of your laptop and unplug its power adaptor without shutting down? ''I don't think so!'' The same goes for Satellite CCRMA, at least when you can avoid it, because it is a small computer running linux.
  
For this class, we assume that you will be adapting existing working code for your own applications. While this is certainly easier than writing firmware from scratch, it does require understanding how existing code functions.  
+
Now we will test the halt procedure. Run the halt command as superuser by typing ''sudo halt'' at the Satellite CCRMA prompt. Then you will again have to type in the password ''temppwd'' in order to have the privilege to run this command. Wait until about 15 seconds after you see the message "Connection to 192.168.105.106 closed by remote host," and then disconnect the 5V power adaptor from the Beagle Board.
  
Start the Arduino software by typing the command ''arduino &'' in the terminal. Please upload the following firmware programs from your Arduino program's Examples folders to your Arduino controller and see how they function. Do attach LEDs, buttons, as is appropriate:
 
  
* Examples->Digital->Blink
 
* Examples->Digital->BlinkWithoutDelay
 
* Examples->Digital->Button (Even though it works, there is a bug in this file. In the text file that you submit to us
 
* answering questions for this lab, tell us what the bug is.)
 
  
== Custom Communication ==
 
Another reason that you might want to program the Arduino microcontroller even if you are connected to a laptop or desktop computer is to enable greater control over the communications from the Arduino. In this segment of the laboratory, we learn a wider variety of ways to send data from the Arduino hardware to the computer than we have previously used.
 
  
=== Serial communication with the Arduino software ===
+
== Getting Comfortable With Satellite CCRMA ==
You might have noticed in the previous lab segment that it can be very hard to know what is going wrong when the Arduino hardware is in autonomous mode. Here, we send serial communications between the Arduino hardware and the Arduino software.
+
* Turn on Satellite CCRMA again using the same procedure as before where you plug the power into the Beagle Board. After about 30 seconds, the board should be booted up again, so you can log in again by running the command
  
* Examples->Analog->Smoothing: Use the Serial Monitor (icon on the far left on the Arduino software toolbar) to get data back from the Arduino.  
+
''ssh -XY ccrma@192.168.105.106''
* Examples->Communication->SerialCallandResponse.
+
  
=== Serial communication with PD ===
+
* Run the command ''pwd'' to find out the current directory. You will find that you are in the ''ccrma'' subdirectory of the directory ''/home''.
Now let's try using serial to communicate with PD.
+
  
First let's try outputting information to the Arduino hardware:
+
* Type the ''ls'' command to see what is in the current directory. The blue items are subdirectories of the current directory. You can change directories using the ''cd'' command. For instance, to change into the ''pd_lecture'' subdirectory, you should run the command
* Load Examples->Communication->PhysicalPixel
+
** The PD patch for communicating with this firmware is already stored in your ''~/250a/lab3'' directory (or you can try to get it from [http://ccrma.stanford.edu/courses/250a/labs/lab3/physicalpixel.pd here] and then upload it to ccrma@satellite using ''scp'', but that would be harder :)
+
  
Next let's try getting information from the Arduino hardware:
+
''cd pd_lecture''
* Load Examples->Communication->Graph
+
** The  PD patch for communicating with this firmware is already stored in your ''~/250a/lab3'' directory (or you can try to get it from [http://ccrma.stanford.edu/courses/250a/labs/lab3/Graph.pd here] and then upload it to ccrma@satellite using ''scp'', but that would be harder :)
+
  
 +
* Now again type ''pwd'' to make sure that you understand where you are! Run the ''ls'' command to see what files are in here.
  
 +
* Find out if you have successfully connected Satellite CCRMA to the Internet by running the command
  
== Low-latency sensing ==
+
''ping yahoo.com''
=== Encoder input ===
+
  
One final reason that you would want direct control over the Arduino firmware is that you might have very low-latency sensing needs. As an example of this, we show you here how to use encoder input with the Arduino.
+
* If you get responses that take about 100 ms to 200 ms, then your settings are correct.
  
Quit Pd to ensure that Pd isn't using the USB/serial connection to the Arduino. Change to the ''~/250a/lab3/encoder'' directory by typing
 
  
''cd ~/250a/lab3/encoder''
 
  
(If you are having problems with the Beagleboard and doing this lab on your laptop, download [https://ccrma.stanford.edu/courses/250a/labs/lab3/encoder.zip encoder.zip]).
 
  
in the terminal. Start up the Arduino software using the command ''arduino &'' and upload the sketch ''encoder.pde'' to the Arduino. Then quit the Arduino software and start up Pd by typing ''pd encoder.pd'' You will notice that the ''comport'' object, which controls the USB/serial connection, has a dotted red box around it and that a related error is shown in the Pd main window. To correct the error, you need to rename the object from ''flatspace/comport $1 9600'' to ''comport $1 9600''.
+
== Starting Audio And Pd ==
  
Now you need to build this schematic to interface the encoder: http://cm-wiki.stanford.edu/mediawiki/images/c/c1/Encoder_filter.png. 
+
* First we need to start up the audio connection kit. It's easiest to do so using the graphical interface, so execute the command '''start-jackd'''
Pin two is the middle pin on the rotary encoder, and pins 1 and 3 are the other directly adjacent pins. It can be a bit difficult to plug the encoder into the solderless protoboard, but you can do it if you straighten out the pins first.
+
  
Note: In the schematic, ''AVR Phase A'' is digital pin 2 or the Arduino, and ''AVR Phase B'' is digital pin 3. 
+
* In order to be able to hear audio, you will need to plug a pair of ear buds, headphones, or loudspeakers into the 1/8" (2.54mm) jack labeled AUDIO OUT on the Beagle Board. '''Be very careful when plugging the headphones in and not to pull too hard on the headphone cable! Unfortunately it comes off of the board very easily, that is you can break the board this way!!!'''
  
Now you're ready to send out the position of the encoder over the serial bus. The values should start near zero and increase or decrease, depending on which direction you turn the encoder.  How are negative numbers represented?  Why does the encoder always start near 0 when the program on the Arduino is restarted?
+
* Start pd now with the following command, where again we include &:
  
== Make A Musical Interaction ==
+
''pd &''
As the final main deliverable of the lab, you should cause your ccrma@satellite kit make some sound that depends on how you manipulate the sensors. For example, you could make a musical instrument, a music controller, a mock-up sound art installation, or some other sonic interaction. Now that you have had some experience synthesizing sound, your sound synthesis patch should involve more than just a few ''osc~''s. Think about what you want to design before you get started.
+
  
For your musical interaction, you can write your own firmware, or you can use Firmata. If you choose to use Firmata, then you need to re-flash Firmata to the beagleboard. To do so, first load the Arduino software. Then load the StandardFirmata sketch by choosing File|Examples|Firmata|StandardFirmata. Make sure that you have the correct Serial Port and Board selected. Then upload StandardFirmata to your Arduino Nano by clicking on the ''Upload'' button. Check that there were no errors with uploading StandardFirmata before you quit the Arduino software.
+
* Choose ''Open'' from the ''File'' menu and select the patch ''4_algorithmic_music.pd''. In the main ''pd-extended'' window, click on the ''compute audio'' button. Then go back to the patch, move the speed and width sliders slightly to the right, and bring up the volume. You should now hear some sound in your headphones. Play around with the parameters to see what new sounds you can discover.
  
Start up the Jack audio server by executing the command ''qjackctl &'' at the terminal and clicking on the ''Start'' button. In order to be able to hear audio, you will need to plug a pair of ear buds, headphones, or loudspeakers into the 1/8" (2.54mm) jack labeled AUDIO OUT on the beagleboard.  
+
Troubleshooting: If you still do not here any sound, then probably you missed one of the steps so far. If you look at the messages in the main ''pd'' window, you might find a clue.
  
It is probably easiest to make your patch by modifying ''~/on-startup/windy-day.pd'', which Edgar demonstrated in class. To start it up, first change to the directory ''~/on-startup'' by typing ''cd ~/on-startup'' in the terminal. Then type ''pd windy-day.pd &'' to startup ''pd''.
 
  
  
  
== Optional: Autonomous ccrma@satellite ==
+
== The Patches Are Already On The Board==
By this point you should be done with your musical interaction. If you would like to go the extra mile, we will now show you how to make your musical interaction autonomous in the sense that it can operate all by itself, free from any external laptop computer. We will show you how to do this using the example ''windy-day.pd''.
+
  
=== To Enable A Default Patch On Boot ===
+
*  You can find the main patch at /home/ccrma/pd/labs-Music-250a-2011/lab1/myinstrument.pd
In the terminal, change to the ''on-startup'' directory by typing
+
  
''cd ~/on-startup''
 
  
and type ''ls -la'' to see what files are in there. You can see that the link (aka alias) ''default_patch.pd'' points to ''windy-day.pd''. In order to enable the default patch to load on boot, rename the file ''load_default_patch_disabled'' to ''load_default_patch'' using the command
 
  
''mv load_default_patch_disabled load_default patch''
 
  
The ''cat'' command can be used to display the contents of any ASCII file. To look at the contents of ''load_default_patch'', type ''cat load_default_patch''. As you can see, it starts up Jack using the text-based ''jackd'' instead of ''qjackctl'', and then it loads ''default_patch.pd'' in pd with the graphical user interface (GUI) disabled.
+
== Play Around With the Patches ==
  
Now your kit should be ready for autonomous ccrma@satellite. To test it, just reboot the kit by typing ''sudo reboot'' and entering the password ''temppwd''. As it is rebooting, plug a pair of ear buds, headphones, or loudspeakers into the 1/8" (2.54mm) jack labeled AUDIO OUT on the beagleboard. Within about a minute, your kit should be fully rebooted. To check this, you can try logging in with SSH. Either way, it should start running ''windy_day.pd'' upon startup.  
+
* Go back to ''pd'' and open the patch labeled ''myinstrument.pd'' inside ''software_lab_pd''. Make sure that ''compute audio'' is set to on and ''qjackctl'' is still open and running. Play around with the patch. You should be able to exhaust its musical potential in a matter of minutes; reflect on its strengths and limitations.
  
Once your kit is fully rebooted, if you touch the anaog input pins on the Arduino A0-A7, it should start making some sound. However, unless you connect up a sensor circuit to some of the analog inputs, the exact behavior may be complicated. In particular, it will depend on the electrical properties of your body (how much sweat is on your fingers, whether you are touching a grounded device such as a laptop with any part of your body. Ask for help if you cannot get any sound.
+
* Also try to understand how it works as a piece of software. (But please don't get hung up on the arcana - as always, if you get stuck, ask for help rather than waste time.)
  
Finally, log back into ccrma@satellite using the same command as always ''ssh -X ccrma@192.168.1.105''. Type ''ps -A'' at the prompt to get a list of the currently running processes. ''jackd'' is the Jack audio sound server, and ''pdextended'' is the pd process. To stop the default patch from running, type ''./stop_default''. To see how ''stop_default'' works, type ''cat stop_default''. (The ./ was necessary in order to run the script ''stop_default'' because the current user directory ~ is not in the user path, so linux needs the ./ to indicate to look for ''stop_default'' in the current directory.)
 
  
  
  
== Optional: Programming Linux ==
+
==Documentation==
'''We don't actually expect you to do anything here, we are just providing some more information that is maybe helpful for you linux gurus.''' Since ccrma@satellite runs ubuntu linux on an OMAP chip, many standard software packages have been compiled for it. This is why we were easily able to install software such as Jack, [http://audacity.sourceforge.net/ Audacity], [http://chuck.cs.princeton.edu/ ChucK], [http://faust.grame.fr/ Faust], [https://ccrma.stanford.edu/groups/soundwire/software/jacktrip/ Jacktrip], and the Arduino software.
+
  
If you are lucky, you can install your favorite software using the ''apt-get'' utility. To get a list of packages available on the OMAP's ARM architecture, type
+
* Right-click or option-click on any object to get a contextual menu including "help," which opens that object's help patch. (If you are using a Mac and don't have a right mouse button, then go to the ''X11'' pull-down menu, select ''Preferences'', and make sure that ''Emulate three button mouse'' is checked in the ''Input'' pane. Now, you should be able to right-click by clicking while holding down the Command key.)
  
''sudo apt-cache pkgnames''
+
* Right-click on a blank portion of a Pd patch. Now when you select "help" you get a list of Pd's built-in objects, arranged by category.
  
You will notice that this list is way too long to look at. You can pipe it to the text file using the command
+
* In the upper right hand corner of each Pd window is a "help" menu. This accesses the Pd tutorials as well as some online reference documentation.
  
''sudo apt-cache pkgnames > packages.txt''
 
  
and then look at it using ''emacs packages.txt'', or you search for a particular package, such as
 
  
''sudo apt-cache pkgnames | grep emacs''.
 
  
Or, you can compile linux software yourself on the Beagleboard. The gcc, g++ tools etc. are already installed.
+
==Short questions==
 +
Why is the following patch a bad idea?
  
Type the ''df'' command. You can see that there is not a whole lot more than 1GB available on the SD card, so you should only install software if you decide that you need it.
+
[[Image:badidea.gif]]
  
 +
Make a patch that shows how to connect some objects together to calculate the function ''1-x'' where ''x'' is an input number.  Save the patch in a file called ''OneMinus''.
  
  
== Halt Your Board Properly When Finished! ==
 
'''Remember to shut down your board when you are done before powering it off!''' (Of course as Spencer pointed out, if you are operating ''truly'' autonomously, of course you cannot login and run the halt command. Nevertheless, if it is not too inconvenient please try to shut down properly if you can. If you do not, then you may find that your SD memory card becomes corrupted.) As described above, you can do this by executing the command ''sudo halt'' and then waiting 30 seconds before disconnecting the power cables.
 
  
  
 +
== Design a different musical interaction ==
  
== Wrap-Up ==
+
Here are some ideas of changes that might make the patch more interesting:
Instead of submitting your actual pd patch (because this is a little bit involved), it is okay to simply include some text in your email to Ed and Wendy describing what your patch did. Also please write a few sentences about what part of the lab was the most difficult, and please document any bugs that you find so that we can fix them! In fact, we may add some troubleshooting sections to the bottom of this Wiki.
+
  
Thanks so much! We are looking forward to seeing demos of your musical interactions at the beginning of the next lab session!
+
* Involve more QWERTY keys
 +
* Involve the mouse (see the [MouseState] object)
 +
* Load in a larger collection of samples.
 +
** Implement a mechanism to switch among banks of samples
 +
* Multiple gestures to one result: design a way for the parameters of each triggered note to depend on multiple key presses. For example, maybe only the space bar triggers notes, and all the other keys determine parameters of notes.
 +
** Make your patch automatically generate a bassline as a function of the key presses
 +
** Set multiple parameters modally, as volume works in the sample patch
 +
** Use chording: keep track of all the keys that are currently pressed, and use only that information to set the parameters for each note.
 +
* One gesture to multiple results
 +
** Use the "metro" object to trigger a steady stream of notes. Now you have two new parameters: repetition rate, and whether the metro is on or off.
 +
** Use the "counter" object to step through a cycle (of samples, parameter settings, etc.)
 +
** You could combine "metro" and "counter" to build a rudimentary sequencer that can step through a rhythmic pattern
 +
** Invent a mechanism to record short sequences of keypresses and play them back in time.
 +
* Incorporate looping or other interactive controls over the soundfile playback
 +
* Use Pd's "spigot" object to route control information to different parts of your patch at different times
 +
* Use some additional signal processing such as a filter, delay line, reverb, tremolo, etc. This gives you more parameters to control.
 +
* Polyphony: make it so the patch can play multiple samples at the same time. (Hint: put multiple copies of "play-sample" in your patch)
 +
* Use a totally different form of sound synthesis, such as FM, granular, or physical modeling.
  
 +
We recommend that you pick '''only one or a small number''' of these and work on it in depth, iterating on both the program/test/debug cycle as well as the design/implement/play cycle to craft something that has actual musical potential or is at least more fun to play. If you have an existing idea for your class project, you could use this lab to start thinking about implementing some of the modes and mappings. By all means, if you're inspired to try something else, go for it. If you'd rather spend today getting more of a broad sense of Pd's capabilities, feel free to work on many of these suggestions.
  
  
  
  
 +
== The Community ==
  
<center>[[250a 2009]]</center>
+
There is a large, dedicated, and very generous community of Pd users on the Internet. Do some web searching (e.g., with a search engine, or else starting from some more specific resources) and look for interesting externals and/or patches. '''Optional:''' Download, install, and play with at least one. Can you incorporate it into what you programmed in the previous part?
[[Category:250a]][[Category:PID]]
+
  
 +
For more help in finding resources, don't forget to look on the [[PID Links]] page.
  
  
  
  
 +
== Appendix: Troubleshooting ==
 +
Tips:
 +
* Type <tt>dmesg</tt> to see if there are any relevant messages that look like error messages.
 +
* Check if the Jack audio server has crashed. If so, then restart it.
  
 +
Solutions:
 +
* If you are running out of space on the SD card, you can free up some space by deleting items in <tt>/usr/src</tt>. For instance, all of the files needed for building Pure Data Extended are rather large.
 +
* If you are unable to access the internet from Satellite CCRMA, and you are not at CCRMA, then you may need to change the DNS nameserver specified in <tt>/etc/resolv.conf</tt> You could do this using the <tt>set-DNS-server</tt> command.
  
  
  
  
 +
== Optional: Programming Linux ==
 +
'''We don't actually expect you to do anything here, we are just providing some more information that is maybe helpful for you linux gurus.''' Since ccrma@satellite runs ubuntu linux on an OMAP chip, many standard software packages have been compiled for it. This is why we were easily able to install software such as Jack, [http://audacity.sourceforge.net/ Audacity], [http://chuck.cs.princeton.edu/ ChucK], [http://faust.grame.fr/ Faust], [https://ccrma.stanford.edu/groups/soundwire/software/jacktrip/ Jacktrip], and the Arduino software.
  
 +
If you are lucky, you can install your favorite software using the ''apt-get'' utility. To get a list of packages available on the OMAP's ARM architecture, type
  
==Install==
+
''sudo apt-cache pkgnames''
If you will use your own laptop, install [http://sourceforge.net/projects/pure-data/files/pd-extended/ Pd extended v0.41.4].  Make sure that you install the ''extended'' version so that you have all of the objects that you need.
+
  
If you're running Pd using a desktop machine on the CCRMA network, make sure that you followed the instructions [http://ccrma.stanford.edu/courses/250a/lectures/pd/ in this lecture] for configuring Pd.
+
You will notice that this list is way too long to look at. You can pipe it to the text file using the command
  
== Download the Lab Patches to Your Home Directory==
+
''sudo apt-cache pkgnames > packages.txt''
  
* Download the patches into your 250a directory and uncompress the archive: [http://ccrma.stanford.edu/courses/250a/workshop/software_lab_pd.zip software_lab_pd.zip]
+
and then look at it using ''emacs packages.txt'', or you search for a particular package, such as
  
== Play Around With the Patches ==
+
''sudo apt-cache pkgnames | grep emacs''.
  
* Open the patch labeled myinstrument. Play around with this patch. You should be able to exhaust its musical potential in a matter of minutes; reflect on its strengths and limitations.
+
Or, you can compile linux software yourself on the Beagleboard. The gcc, g++ tools etc. are already installed.
  
* Also try to understand how it works as a piece of software. (But please don't get hung up on the arcana - as always, if you get stuck, ask for help rather than waste time.)
+
Type the ''df'' command. You can see that there is not a whole lot more than 1GB available on the SD card, so you should only install software if you decide that you need it.
  
===Documentation===
 
  
* Right-click or option-click on any object to get a contextual menu including "help," which opens that object's help patch.
 
  
** Right-click on a blank portion of a Pd patch. Now when you select "help" you get a list of Pd's built-in objects, arranged by category.
 
** In the upper right hand corner of each Pd window is a "help" menu. This accesses the Pd tutorials as well as some online reference documentation.
 
  
==Short questions==
+
== Halt Your Board Properly When Finished! ==
Why is the following patch a bad idea?
+
'''Remember to shut down your board when you are done before powering it off!''' (Of course, if you are operating ''truly'' autonomously, of course you cannot login and run the halt command. Nevertheless, if it is not too inconvenient please try to shut down properly if you can. If you do not, then you may find that your memory card becomes corrupted.)
  
[[Image:badidea.gif]]
 
  
Make a patch that shows how to connect some objects together to calculate the function ''1-x'' where ''x'' is an input number.  Save the patch in a file called ''OneMinus''.
 
  
==Key Repeat==
 
* What happens when you hold down a key? The behavior may depend on what operating system you are running.
 
* Is the behavior desirable on your system?  What operating system are you running?
 
  
== Design a different musical interaction ==
+
== Copying Files To and From Your Kit ==
 +
* Alternatively, if you would like to use software with a nice GUI for copying files back and forth from your kit, you can install additional special software on your laptop.  For Windows, install [https://itservices.stanford.edu/service/ess/pc/securefx Secure FX], or for Mac OS X, install [https://itservices.stanford.edu/service/ess/mac/fetch Fetch].  These programs actually use scp, but they hide the details of the pathnames from you.
  
Here are some ideas of changes that might make the patch more interesting:
 
  
* Involve more QWERTY keys
 
* Involve the mouse (see the [MouseState] object)
 
* Load in a larger collection of samples.
 
** Implement a mechanism to switch among banks of samples
 
* Multiple gestures to one result: design a way for the parameters of each triggered note to depend on multiple key presses. For example, maybe only the space bar triggers notes, and all the other keys determine parameters of notes.
 
** Make your patch automatically generate a bassline as a function of the key presses
 
** Set multiple parameters modally, as volume works in the sample patch
 
** Use chording: keep track of all the keys that are currently pressed, and use only that information to set the parameters for each note.
 
* One gesture to multiple results
 
** Use the "metro" object to trigger a steady stream of notes. Now you have two new parameters: repetition rate, and whether the metro is on or off.
 
** Use the "counter" object to step through a cycle (of samples, parameter settings, etc.)
 
** You could combine "metro" and "counter" to build a rudimentary sequencer that can step through a rhythmic pattern
 
** Invent a mechanism to record short sequences of keypresses and play them back in time.
 
* Incorporate looping or other interactive controls over the soundfile playback
 
* Use Pd's "spigot" object to route control information to different parts of your patch at different times
 
* Use some additional signal processing such as a filter, delay line, reverb, tremolo, etc. This gives you more parameters to control.
 
* Polyphony: make it so the patch can play multiple samples at the same time. (Hint: put multiple copies of "play-sample" in your patch)
 
* Use a totally different form of sound synthesis, such as FM, granular, or physical modeling.
 
  
We recommend that you pick one or a small number of these and work on it in depth, iterating on both the program/test/debug cycle as well as the design/implement/play cycle to craft something that has actual musical potential or is at least more fun to play. If you have an existing idea for your class project, you could use this lab to start thinking about implementing some of the modes and mappings. By all means, if you're inspired to try something else, go for it. If you'd rather spend today getting more of a broad sense of Pd's capabilities, feel free to work on many of these suggestions.
 
  
== The Community ==
+
== More Pd resources ==
 +
* Here are some lists of pd objects that you can use to discover new object names: [http://protman.com/content/list-puredata-objects-and-extended-objects http://protman.com/content/list-puredata-objects-and-extended-objects] [http://www.umatic.nl/workshop/objects.txt http://www.umatic.nl/workshop/objects.txt]
  
There is a large, dedicated, and very generous community of Pd users on the Internet. Do some web searching (e.g., with a search engine, or else starting from some more specific resources) and look for interesting externals and/or patches. Download, install, and play with at least one. Can you incorporate it into what you programmed in the previous part?
 
  
For more help in finding resources, don't forget to look on the [[PID Links]] page.
 
  
<center>[[NMC 2011]]</center>
+
<center>[[PID 2010]]</center>
[[Category:NMC_2011]][[Category:NMC]]
+
[[Category:PID_2010]][[Category:PID]]

Latest revision as of 06:47, 11 June 2012

Lab 1: Making Music with Pd in Satellite CCRMA
Lab write-up due on Tuesday at 10AM

Most instructions by Edgar Berdahl, and lab patches for musical interaction description by Matt Wright and possibly others

For this lab you need your Satellite CCRMA kit, a computer to program it, and some headphones with a mini 1/8" stereo jack.


The Satellite CCRMA Setup

Included in your kit you should have

- Satellite CCRMA Hardware (Beagle Board + microSDHC memory card + Arduino Nano + solderless breadboard)
- One 5V power adaptor to plug into the Beagle Board
- One Ethernet cable for external communication
- Arduino Nano
- One adjustable-length USB cable

If you are missing something, please go get it before assembling your kit. Make sure you plug the micro SDHC memory card fully into its seat so that it looks as shown inside the red box:

Kitblank.jpg



Powering Up For The First Time

Plug the Ethernet port of the Satellite CCRMA into your laptop. Then plug in the 5V power supply into the Beagle as shown below. You should see some lights turn on, flickering every now and then. This means that Satellite CCRMA is booting up.

Kitplugged.jpg



Connect To Satellite CCRMA

In order to see what your Satellite CCRMA kit is doing and program it, you need to log in to it. To do so, follow these instructions.

After you login, you will see the prompt ccrma@satellite:~$ This means that you are logged into a computer named "satellite" as the user "ccrma", and you are currently in the directory ~, which is the shortcut for your home directory.



Avoid Powering Down the Board Without Halting it First!

Would you take the battery out of your laptop and unplug its power adaptor without shutting down? I don't think so! The same goes for Satellite CCRMA, at least when you can avoid it, because it is a small computer running linux.

Now we will test the halt procedure. Run the halt command as superuser by typing sudo halt at the Satellite CCRMA prompt. Then you will again have to type in the password temppwd in order to have the privilege to run this command. Wait until about 15 seconds after you see the message "Connection to 192.168.105.106 closed by remote host," and then disconnect the 5V power adaptor from the Beagle Board.



Getting Comfortable With Satellite CCRMA

  • Turn on Satellite CCRMA again using the same procedure as before where you plug the power into the Beagle Board. After about 30 seconds, the board should be booted up again, so you can log in again by running the command

ssh -XY ccrma@192.168.105.106

  • Run the command pwd to find out the current directory. You will find that you are in the ccrma subdirectory of the directory /home.
  • Type the ls command to see what is in the current directory. The blue items are subdirectories of the current directory. You can change directories using the cd command. For instance, to change into the pd_lecture subdirectory, you should run the command

cd pd_lecture

  • Now again type pwd to make sure that you understand where you are! Run the ls command to see what files are in here.
  • Find out if you have successfully connected Satellite CCRMA to the Internet by running the command

ping yahoo.com

  • If you get responses that take about 100 ms to 200 ms, then your settings are correct.



Starting Audio And Pd

  • First we need to start up the audio connection kit. It's easiest to do so using the graphical interface, so execute the command start-jackd
  • In order to be able to hear audio, you will need to plug a pair of ear buds, headphones, or loudspeakers into the 1/8" (2.54mm) jack labeled AUDIO OUT on the Beagle Board. Be very careful when plugging the headphones in and not to pull too hard on the headphone cable! Unfortunately it comes off of the board very easily, that is you can break the board this way!!!
  • Start pd now with the following command, where again we include &:

pd &

  • Choose Open from the File menu and select the patch 4_algorithmic_music.pd. In the main pd-extended window, click on the compute audio button. Then go back to the patch, move the speed and width sliders slightly to the right, and bring up the volume. You should now hear some sound in your headphones. Play around with the parameters to see what new sounds you can discover.

Troubleshooting: If you still do not here any sound, then probably you missed one of the steps so far. If you look at the messages in the main pd window, you might find a clue.



The Patches Are Already On The Board

  • You can find the main patch at /home/ccrma/pd/labs-Music-250a-2011/lab1/myinstrument.pd



Play Around With the Patches

  • Go back to pd and open the patch labeled myinstrument.pd inside software_lab_pd. Make sure that compute audio is set to on and qjackctl is still open and running. Play around with the patch. You should be able to exhaust its musical potential in a matter of minutes; reflect on its strengths and limitations.
  • Also try to understand how it works as a piece of software. (But please don't get hung up on the arcana - as always, if you get stuck, ask for help rather than waste time.)



Documentation

  • Right-click or option-click on any object to get a contextual menu including "help," which opens that object's help patch. (If you are using a Mac and don't have a right mouse button, then go to the X11 pull-down menu, select Preferences, and make sure that Emulate three button mouse is checked in the Input pane. Now, you should be able to right-click by clicking while holding down the Command key.)
  • Right-click on a blank portion of a Pd patch. Now when you select "help" you get a list of Pd's built-in objects, arranged by category.
  • In the upper right hand corner of each Pd window is a "help" menu. This accesses the Pd tutorials as well as some online reference documentation.



Short questions

Why is the following patch a bad idea?

Badidea.gif

Make a patch that shows how to connect some objects together to calculate the function 1-x where x is an input number. Save the patch in a file called OneMinus.



Design a different musical interaction

Here are some ideas of changes that might make the patch more interesting:

  • Involve more QWERTY keys
  • Involve the mouse (see the [MouseState] object)
  • Load in a larger collection of samples.
    • Implement a mechanism to switch among banks of samples
  • Multiple gestures to one result: design a way for the parameters of each triggered note to depend on multiple key presses. For example, maybe only the space bar triggers notes, and all the other keys determine parameters of notes.
    • Make your patch automatically generate a bassline as a function of the key presses
    • Set multiple parameters modally, as volume works in the sample patch
    • Use chording: keep track of all the keys that are currently pressed, and use only that information to set the parameters for each note.
  • One gesture to multiple results
    • Use the "metro" object to trigger a steady stream of notes. Now you have two new parameters: repetition rate, and whether the metro is on or off.
    • Use the "counter" object to step through a cycle (of samples, parameter settings, etc.)
    • You could combine "metro" and "counter" to build a rudimentary sequencer that can step through a rhythmic pattern
    • Invent a mechanism to record short sequences of keypresses and play them back in time.
  • Incorporate looping or other interactive controls over the soundfile playback
  • Use Pd's "spigot" object to route control information to different parts of your patch at different times
  • Use some additional signal processing such as a filter, delay line, reverb, tremolo, etc. This gives you more parameters to control.
  • Polyphony: make it so the patch can play multiple samples at the same time. (Hint: put multiple copies of "play-sample" in your patch)
  • Use a totally different form of sound synthesis, such as FM, granular, or physical modeling.

We recommend that you pick only one or a small number of these and work on it in depth, iterating on both the program/test/debug cycle as well as the design/implement/play cycle to craft something that has actual musical potential or is at least more fun to play. If you have an existing idea for your class project, you could use this lab to start thinking about implementing some of the modes and mappings. By all means, if you're inspired to try something else, go for it. If you'd rather spend today getting more of a broad sense of Pd's capabilities, feel free to work on many of these suggestions.



The Community

There is a large, dedicated, and very generous community of Pd users on the Internet. Do some web searching (e.g., with a search engine, or else starting from some more specific resources) and look for interesting externals and/or patches. Optional: Download, install, and play with at least one. Can you incorporate it into what you programmed in the previous part?

For more help in finding resources, don't forget to look on the PID Links page.



Appendix: Troubleshooting

Tips:

  • Type dmesg to see if there are any relevant messages that look like error messages.
  • Check if the Jack audio server has crashed. If so, then restart it.

Solutions:

  • If you are running out of space on the SD card, you can free up some space by deleting items in /usr/src. For instance, all of the files needed for building Pure Data Extended are rather large.
  • If you are unable to access the internet from Satellite CCRMA, and you are not at CCRMA, then you may need to change the DNS nameserver specified in /etc/resolv.conf You could do this using the set-DNS-server command.



Optional: Programming Linux

We don't actually expect you to do anything here, we are just providing some more information that is maybe helpful for you linux gurus. Since ccrma@satellite runs ubuntu linux on an OMAP chip, many standard software packages have been compiled for it. This is why we were easily able to install software such as Jack, Audacity, ChucK, Faust, Jacktrip, and the Arduino software.

If you are lucky, you can install your favorite software using the apt-get utility. To get a list of packages available on the OMAP's ARM architecture, type

sudo apt-cache pkgnames

You will notice that this list is way too long to look at. You can pipe it to the text file using the command

sudo apt-cache pkgnames > packages.txt

and then look at it using emacs packages.txt, or you search for a particular package, such as

sudo apt-cache pkgnames | grep emacs.

Or, you can compile linux software yourself on the Beagleboard. The gcc, g++ tools etc. are already installed.

Type the df command. You can see that there is not a whole lot more than 1GB available on the SD card, so you should only install software if you decide that you need it.



Halt Your Board Properly When Finished!

Remember to shut down your board when you are done before powering it off! (Of course, if you are operating truly autonomously, of course you cannot login and run the halt command. Nevertheless, if it is not too inconvenient please try to shut down properly if you can. If you do not, then you may find that your memory card becomes corrupted.)



Copying Files To and From Your Kit

  • Alternatively, if you would like to use software with a nice GUI for copying files back and forth from your kit, you can install additional special software on your laptop. For Windows, install Secure FX, or for Mac OS X, install Fetch. These programs actually use scp, but they hide the details of the pathnames from you.



More Pd resources


PID 2010