Euterpea

Euterpea is a domain-specific language, embedded in the functional language Haskell, for computer music development. It is a descendant of Haskore and HasSound, and is intended for both educational purposes as well as serious computer music applications. Euterpea is a wide-spectrum language, suitable for high-level music representation, algorithmic composition, and analysis; mid-level concepts such as MIDI; and low-level audio processing, sound synthesis, and instrument design. It also includes a “musical user interface,” a set of computer-music specific GUI widgets such as keyboards, pushbuttons, sliders, and so on. The performance of Euterpea is intended to be as good as any existing computer music language, with the goal of being able to develop real-time applications, using both MIDI and a high-performance back-end for real-time audio.

Research topics in the Euterpea Project include, on the computer science side, language design and implementation issues, formal methods and verification techniques, and concurrent and parallel computation; and on the computer music side, algorithmic composition and analysis, physical modeling and instrument design, and audio processing. Euterpea is a key component of the Music Track in Yale’s new Computing and the Arts major, in which Hudak teaches a two-term computer music sequence using Euterpea, and is developing considerable pedagogical material, including a new textbook titled The Haskell School of Music — From Signals to Symphonies. The name Euterpea is derived from Euterpe, who was one of the nine Greek Muses (goddesses of the arts), specifically the Muse of Music.

40 Responses to Euterpea

  1. Forrest says:

    Please consider updating the Haskell Wiki at http://www.haskell.org/haskellwiki/CSound . The links for Haskore and HasSound are broken, and there is no information about Euterpea. (I was going to update it myself, but I don’t really know enough.)

  2. xhevahir says:

    When I first run Euterpea I get the following: ”
    ChildSong6.lhs:24:10: Parse error in pattern: n + 1
    Failed, modules loaded: SelfSim, Ssf.”
    It then returns a prompt of *SelfSim>

    I gave up on this software a year ago when it hung on the AudioRender error; hopefully I won’t have to wait another year for this one to get cleared up.

  3. xhevahir says:

    P.S. I’m using Win7 64-bit, with whatever the current Haskell Platform is.

  4. xhevahir says:

    Googling around, I see that somebody else solved this problem(though not with respect to Euterpea specifically) by adding {-# LANGUAGE NPlusKPatterns #-} to I-know-not-what file in order to enable the offending pattern. What do I need to change?

  5. xhevahir says:

    OK, so apparently I need to pass this argument to ghci at the same time I invoke the interpreter. Is there any way I can add the option somewhere as default?

    • paul says:

      This error arose because the latest version of GHC doesn’t allow n+k patterns by default. The error doesn’t arise in Euterpea itself, which doesn’t use n+k patterns, but only in one of the example files, namely Euterpea/example/ChildSong6.lhs. The easiest fix is to change the line:

      > times (n+1) m = m :+: (times n m)

      in that file to:

      > times n m = m :+: (times (n-1) m)

      Sorry for the inconvenience. A newer version of Euterpea that fixes this bug and also has many other improvements will be released shortly.

      -Paul Hudak

  6. xhevahir says:

    Thank you for your work. Euterpea and the Haskell book have been very interesting.

  7. Franklin says:

    Somebody knows how to solve this error:

    Loading package GLFW-0.5.0.1 … linking … : /home/franklin/.cabal/lib/GLFW-0.5.0.1/ghc-7.0.3/HSGLFW-0.5.0.1.o: unknown symbol `atexit’
    ghc: unable to load package `GLFW-0.5.0.1′

    I reinstaled the package GLFW-0.5.0.1 but the error continue.

  8. George Colpitts says:

    I’m very excited about Euterpea but there are some errors on your download page.

    I can’t see a way to post comments there so I am posting comments here.

    You write there:

    Note for Mac OS users: The current GHC release does not support OS X Snow Leopard or OS X Lion.

    Not sure what you mean by current. I have been running Haskell Platform 2011.4 .0.0 on 10.6.8 and 10.7.3 for about the past year. 2012.2 release candidates (rcs) are also working for me.

    I have no problems yet with euterpea and 32 bit Haskell 2012.2 rc4 but with 64 bit when I try
    play childSong6
    I get

    Loading package Euterpea-1.0.0 … linking … done.
    *** Exception: PortMidi: toEnum out of bound
    but maybe that is expected? (foreign code??) If so it would be good to document that you require 32 bit Haskell.

  9. George Colpitts says:

    I see above that somebody is using Win7 64-bit so my problem is either unique to the Mac and/or Haskell 2012.2 64 bit rc4. I’m glad that Haskell 2012.2 32 bit rc4 works on my Mac.

  10. George says:

    If your servers are in the Eastern US then judging from the timestamps of posts looks like they are still on EST rather than EDT :)

  11. George says:

    I have really been enjoying playing around with Euterpea on the Mac.

    On your download page you have:

    Note for Mac OS users: The current GHC release does not support OS X Snow Leopard or OS X Lion.

    As the above implies this is no longer true. The Haskell Platform 2012.2.0.0 is now available and Euterpea works with the 32 bit version on the Mac although you may have to type “cabal install” twice.

    Unfortunately this is not true of the 64 bit version where “play childSong6″ gets a segmentation fault. It would be great if you could fix this.

    I’m not sure what the right way for Euterpea users to move to new versions of the Haskell Platform or to switch back and forth between the 32 bit and 64 bit versions but I have been doing the following:

    ghc-pkg unregister Euterpea
    /bin/rm -fr Euterpea
    /bin/rm ~/Library/Haskell/bin
    # (the last line because that directory contains ccap and cpphs)
    uninstall-hs

    fwiw the previous version of the Haskell platform 2011.4.0.0 also worked on OS X Snow Leopard or OS X Lion if you edit /usr/bin/ghc and change “/Developer/usr/bin/ghc” to “/usr/bin/ghc”. Similar to the latest Haskell Platform, Euterpea works fine with the 32 bit version but not with the 64 bit version.

  12. Alexander says:

    Is it possible to create a midi file with multiple instruments playing simultaneously? This program http://ideone.com/JRxUh does generate a midi file, but when i try to play it with timidity it first plays bass line only and then just stops without quiting. I guess the resulting file is somehow messed up, but I don’t know if it’s a bug in a library or just me doing something wrong.

    Thanks.

    • Paul Hudak says:

      Hi Alexander. Yes, it is possible to create a midi file with multiple instruments playing simultaneously. When I loaded your file, however, I got a type error saying:

      Couldn’t match expected type `Codec.Midi.Midi’
      with actual type `HCodecs-0.2:Codec.Midi.Midi’
      In the second argument of `Codec.Midi.exportFile’, namely
      `(testMidi $ tempo (100 / 120) $ drumBeat :=: bassLine)’
      In the expression:
      Codec.Midi.exportFile “duet.mid” (testMidi $ tempo (100 / 120) $ drumBeat :=: bassLine)

      I don’t understand why this is happening, since clearly it must have worked for you. It’s as if there are two version of Codec.Midi.Midi. I will look into this further.

      In any case, I have rewritten your code slightly:

      import Euterpea

      tonic = c 5 qn
      dmnt = g 4 qn
      sdmnt = f 5 qn

      noteList = concatMap (replicate 4) [sdmnt, tonic, dmnt, tonic]
      bassLine = instrument ElectricBassPicked $ line1 noteList

      chh = perc ClosedHiHat
      drumBeat = instrument Percussion $ timesM (8*4) (chh en)
      song = drumBeat :=: bassLine

      You can play this directly from the GHCi command prompt with “play song”. Or you can have it written to a file called “test.mid” using “test song”. Both methods work for me (i.e. I hear both the bass line and drum beat), although I use QuickTime to play test.mid, not Timidity. If you want to write it out using a file name of your own choosing, you will have to go in the direction that you were going, but as I said, right now I’m getting a type error on that.

      I hope this helps.

      -Paul

      • Alexander says:

        Thank you very much for your reply.

        >When I loaded your file, however, I got a type error saying:…

        Yes, I had the same error. As I understand it is caused by the fact that Euterpea specifies exactly this version of the library in its dependency list. This error can be eliminated by specifying the package version to be used while compilation:

        ghc -package HCodecs-0.2 Duet.hs

        >You can play this directly from the GHCi command prompt with “play song”. Or you can have it written to a file called “test.mid” using “test song”. Both methods work for me (i.e. I hear both the bass line and drum beat)

        I forgot to mention that I’m using Linux. I wonder if this could be a reason – perhaps some libraries on which Euterpea depends are not very cross-platform?

        • Frederick says:

          Euterpea doesn’t terminate creating a midi with two or more different instruments. When i tried to play the .mid file, only perform one instrument and in a bad way.
          If i try to test a music with only one instrument (can be n instruments but have to be the same type), i can hear the melody.
          Why this is happening? I think is a midi problem! But why?
          Other thing i can’t use is the play function. I have to test the music and open it with timidity.

          Help!!

          Thank you again!!

  13. NMP says:

    Hello — Does any one have luck using Euterpea with Haskell-mode in emacs? On both OS X Lion/Haskell 32 bit and Windows 7, I can run “play childSong6″ fine from within ghci, but when I try to load (C-c C-l) EuterpiaSample.lhs within emacs into the ghci interpereter I get the following error:

    Euterpea/IO/Audio/Types.hs:73:6:
    Illegal datatype context (use -XDatatypeContexts): (Unlifted a,
    Unlifted b) =>
    Failed, modules loaded: Control.CCA.ArrowP, Control.SF.SF, Control.SF.AuxFunctions, Control.SF.MSF, Euterpea.IO.MIDI.MidiIO, Euterpea.IO.MIDI.FromMidi, Euterpea.IO.MIDI.GeneralMidi, Euterpea.IO.MIDI.ToMidi, Euterpea.IO.MUI.SOE, Euterpea.IO.MUI.UIMonad, Euterpea.Music.Note.MoreMusic, Euterpea.Music.Note.Music, Euterpea.Music.Note.Performance.
    *Control.SF.AuxFunctions>

    A similar thing happens in either Windows or Mac, and haskell-mode is working fine in both of these environments for simple haskell code — I image there is some flag that haskell-mode is passing to ghci which is causing problems.

    thanks,

    • Manuel Bärenz says:

      You can work around it by starting ghci as “ghci -XDatatypeContexts”. But in principle someone should replace the offending lines in the code according to this link.

  14. NMP says:

    hmm.. never mind – it has nothing to do with emacs/haskell mode, the cwd of ghci launched by emacs was not set to the Examples directory causing compilation issues when loading the file. All works fine now.

  15. Francis says:

    I use Lion 10.7.4 on a iMac Core 2 Duo and I choose to install “Haskell Platform 2012.2.0.0 64bit”. Then I could install Euterpea with success after adding the path for “ccap” which was not found in my PATH environment.

    Now I “have to use the EnableGUI trick” – and then it fails :
    <q cite="Examples ghc -framework ApplicationServices -c -fffi EnableGUI.hs
    on the commandline:
    Warning: -fffi is deprecated: use -XForeignFunctionInterface or pragma {-# LANGUAGE ForeignFunctionInterface #-} instead
    : does not exist: EnableGUI.hs”>

    So file EnableGUI.hs does not exist, and looking back at the previous Euterpea installation ends with :

    File EnableGUI.hs does not exist in folder Examples.

    Many thanks before tasting for this music software.

  16. Francis says:

    Sorry … : anyway the Euterpea installation had finished (with success) with this “parse error ” which doesn’t seem significant to my problem:

    “[...]
    dist/build/tmp-4650/Control/SF/AuxFunctions.hs:26:1:
    parse error on input `import’
    Installing library in
    /Users/fdiMac/Library/Haskell/ghc-7.4.1/lib/Euterpea-1.0.0/lib
    Registering Euterpea-1.0.0…
    ➜ Euterpea “

  17. Francis says:

    I moved to 32 bit Haskell, with the same result :

    “Examples ghc -framework ApplicationServices -c -XForeignFunctionInterface EnableGUI.hs
    : does not exist: EnableGUI.hs
    ➜ Examples ”

    … Thanks for helping.

  18. Carlo Nucera says:

    Hi, I get the following error when trying to install Euterpea:

    setup: Preprocessor ccap not found. Please make sure the CCA library is already installed, and ccap is in your PATH environment.
    cabal: Error: some packages failed to install:
    Euterpea-1.0.0 failed during the building phase. The exception was:
    ExitFailure 1

    Could you tell me what the CCA library is and how should I install it?

    Thank you!
    Carlo Nucera

    • donya says:

      The ccap file is an executable that comes from the CCA library. Sometimes, even though the CCA library is installed, the folder with the ccap executable isn’t added to the path. Try searching your computer for the file “ccap” (it can be installed in some weird places on different operating systems) and then add the folder it’s in to your system path.

    • Vijay Natarajan says:

      Carlos, I was struggling with the same error. What worked for me is this:
      I added the ccap path to my $PATH environment variable using:

      $ export PATH=$PATH:~/.cabal/bin/

      and then install using

      $ cabal install

      See if this works for you

      Cheers!

      Vijay

    • Yuye says:

      Met the same problem, reinstalled the ccap by:
      $ cabal install CCA –reinstall
      the default path for ccap is:
      ~/Library/Haskell/ghc-7.6.3/lib/CCA-0.1.4/bin

      Then, I add the path:
      $ export PATH=$PATH:~/Library/Haskell/ghc-7.6.3/lib/CCA-0.1.4/bin

      And installed using:
      $ cabal install

  19. donya says:

    This sounds like a MIDI problem on your machine, since Euterpea supports multi-track output. Are you able to play any other multi-track MIDI files made by other programs using timidity? Does timidity give any kind of warning or error message when you play Euterpea-made files?

    • Alexander says:

      Donya, I have the same problem with playing midi-files generated by Euterpea.
      timidity gives this warning:
      Warning: test.mid: Too shorten midi file.

      midi files downloaded from the internet are played without any problems.

      • Greg Martin says:

        I got the same message. A little research showed me that a midi file is expected to end with the bytes FF 2F 00 which I added using ghex. It made the error message go away. I would suggest that Euterpea should be adding them to the end of the file.

  20. Joey says:

    The makeMidi function (and, by extension, the test functions) don’t seem to be working properly for me when the Music value contains multiple instruments. For example, if ex.midi is a MIDI file with multiple instrument tracks, this code will produce an output file that only contains the last track:
    do
    (m,c,upm) <- readMidi "ex.midi"
    exportFile "test.mid" $ makeMidi (m,c,upm)

    Similarly, this code will output a file only containing the tuba note:
    test $ Modify (Instrument AcousticGrandPiano) (c 4 hn) :=: Modify (Instrument Tuba) (e 4 hn)

    Am I doing something wrong, or is this an issue in the library?

    • Joey says:

      Actually, I can open up the MIDI file in an editor and see both parts there, so it’s just that timidity doesn’t play the file back correctly. It does play back other multi-track MIDI files that I have, though, so I guess the binary output of the Codec.Midi functions isn’t working with timidity for me somehow.

  21. Fab HK says:

    I’ve tried installing Euterpea on a Mac (Mountain Lion 10.8.5) with 64 bit Haskell. After running into the problem with the ccap executable from the CAA library mentioned above (fixed by adding the path to ccap to the $PATH), I encountered the problem that the midi would not play:

    *Euterpea.Examples.EuterpeaExamples> play childSong6
    *** Exception: PortMidi: toEnum out of bound

    A workaround was to use “test childSong6″ instead of “play”, then take the test.mid file and play it in QuickTime Player 7 (the current version of QuickTime Player, version 10.2, offers to download that old version when you drag the midi file onto it).

    (Note: I have not tried to install 32bit Haskell to see whether that would work, I’ll try to move along with this workaround for now)

  22. Stuart says:

    I second Fab HK: same setup, same error. His test workaround is what I am doing.

  23. Greg Martin says:

    I am able to play the file created using test childSong6 with timidity – as I mentioned in an earlier thread the file is missing the last three bytes ff 2f 00 but plays with a warning. When I using the function play howyever I don’t get any audio or indication why although I am running timidity. Euterpea seems to be playing the file but I’m guessing isn’t sending the stream to Timidity. I haven’t seen any reference to another step that is required to get them to communicate. Is anyone aware of something that needs to occur for this to happen?

    Thanks.

  24. Mark Edwards says:

    For those concerned about installing Euterpea on a Mac, maybe this is good news. On Mavericks and with the latest version of the Haskell Platform (64-bit), I just installed Euterpea, ran the installation test (play childSong6), and everything seems to work fine.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>