Software Resources
Home Introduction Grading Reading Computing Resources Software Resources Syllabus Assignments Final Project

 

Most of the assignments will involve programming in Haskore, which is a Haskell library for computer music composition.  There are several steps to getting things running on your own machine, which are described below.  Although it looks complicated, it's really not so bad.  Alternatively, you can use the Zoo or CS computer music lab machines.

bulletInstalling GHC
bulletInstalling darcs
bulletInstalling Haskore
bulletSetting up MIDI
bulletUpdating Haskore

Installing GHC

We recommend using the Glasgow Haskell Compiler (GHC) version 6.8.2 or later for this course.  GHC 6.8.2 is already installed on the Zoo machines, so if you are using a Zoo computer you may skip this installation step.  If you wish to run GHC on your own machine, you may download version 6.8.3 for your platform here.  You can find the installation instructions here.

Installing darcs

You will need darcs version 2.0.0 or later to download the version of Haskore that we will be using in this course.  darcs is a version control system that will make it easy for us to provide software updates to you in a consistent manner.

bulletIf you are running Windows, download darcs-2.0.2+75.zip and put the darcs.exe file in one of your PATH directories.  (If you don't know which, C:\Windows is a good choice.)
bulletIf you using a Mac, open a Terminal and do the following:

curl -O http://exrae.com/darcs-2.0.2-i386-darwin.bz2
bunzip2 -c darcs-2.0.2-i386-darwin.bz2 > darcs
chmod a+x darcs
sudo mv darcs /usr/local/bin

You may use another directory instead of /usr/local/bin for the last step if you wish.

bulletFor Linux users, you can either compile darcs from the source, or install the binary package for your platform if it's available.  See here for more information.

Installing Haskore

For Linux users, first make sure that the ALSA development package (both header files and libraries) is already installed, since Haskore depends on it.

Open a command prompt. (On Windows, open the "Command Prompt" or execute cmd.exe; on a Mac, open the "Terminal" application.)  "cd" to the directory (folder) in which you wish to place Haskore.  Then do:

darcs get http://cathay.cs.yale.edu/Haskore
cd Haskore
runhaskell Setup.hs configure
runhaskell Setup.hs build
runhaskell Setup.hs install

You might need administrator privileges to complete the last step.  For MacOS and Linux users who don't have administrator privileges, you should instead use:
    runhaskell Setup.hs configure --user --path=$HOME
for the "configure" step (you may replace $HOME with another directory if you wish).

Assuming that the installation succeeds, you may enter the example directory and load/run the examples, as follows:

cd Haskore/example
ghci
:load HaskoreExamples.lhs
play childSong6

ghci is the command to start GHC interactively as an interpreter, where you may enter Haskell commands and load programs. You can type :help at its prompt for more instructions on how to use it.

If your MIDI device is working properly, you will hear a melody playing, otherwise please read the next section on how to set up MIDI output.

Note: On MacOS X, you will have to use the "EnableGUI trick" to run GUI programs for Haskore, as follows:

First compile EnableGUI.hs to binary as follows:

    cd Haskore/example/
    ghc -c -fffi EnableGUI.hs

Note: on some systems it is necessary to include a -framework option, like this:

    ghc -framework ApplicationServices -c -fffi EnableGUI.hs

Then run your Haskore GUI programs in GHCi like this:

    ghci UIExamples.hs EnableGUI
    *UIExamples> :m +EnableGUI
    *UIExamples EnableGUI> enableGUI >> main

Otherwise, GHCi will not be able to fully activate the Graphics Window.  (Fully compiled GUI programs do not suffer from this anomaly.)

Setting up MIDI

If you are using Mac or Linux and cannot hear anything, chances are your sound card does not have a hardware MIDI synthesizer built in.  If that is the case:

bulletIf you are using MacOS, download SimpleSynth and open it before you run ghci. It's a software MIDI synthesizer that plays MIDI output through the speaker.
bulletIf you use Linux, download and install Timidity++ as well as freepats. Before you attempt source compilation, you might want to check if your distribution already includes them as one of the pre-built packages for download.

After they are properly installed, you can start timidity like this before you run ghci:

timidity -iA -Os &

This will start timidity in the background to listen for MIDI output and play it.

bulletAternatively, instead of (for example) doing play childSong6, use test childSong6 instead.  Haskore will write the MIDI output to a file named test.mid, and you can then play it with timidity (Linux) or Quicktime (Mac).
bulletOr, if you have an external MIDI device, you can connect it to your computer and have MIDI signals sent to it.

Updating Haskore

Once GHC and darcs are installed, you should not have to reinstall or update them.  However, from time to time we may suggest that you update to a newer version of Haskore, which is still evolving.  To do this, open a command prompt, and do the following:

cd Haskore
darcs pull
runhaskell Setup.hs configure
runhaskell Setup.hs build
runhaskell Setup.hs install

Darcs will prompt you to answer whether you want a particular patch or not -- just answer y (for each of them) or a (for all of them).  This will update your Haskore implementation.

Note: For this to work properly, it is important that you not modify any of the Haskore files.  If you are creating a new program (for example a homework assignment), you should create a new file and import the necessary Haskore files into it.  Otherwise your changes will be lost!