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.
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.)
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.
P.S. I’m using Win7 64-bit, with whatever the current Haskell Platform is.
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?
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?
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
Thank you for your work. Euterpea and the Haskell book have been very interesting.
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.
Same error here
I’m having this exact same issue. Have you been able to resolve this?
I am getting the same error as well.
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.
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.
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
This has been fixed.
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.
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.
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
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?
You could fix it? I am having the same error !!
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!!
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,
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.
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.
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 “
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.
One question. Why i can’t hear well multitracks midi pieces?
For example,
test (line [Modify (Instrument AcousticGrandPiano) (c 4 4)] :+: line [Modify (Instrument AcousticGuitarSteel) (g 5 4)])
On the other side, this works:
test (line [Modify (Instrument AcousticGrandPiano) (c 4 4)] :+: line [Modify (Instrument AcousticGrandPiano) (g 5 4)])
Euterpea doesn’t admit multitracks performances, or is a Midi problem?
I play the .mid files with timidity, this way: timidity test.mid.
Thank you!
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?
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.
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
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.
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