last day (19 days later) » 

11:24 AM
0
A: Installing Euterpea for computer music applications and Haskell

hnefatlUsing Stack with LTS 12.26 on Linux, the following project configuration seems to work: Make a new Stack project: stack new euter-test cd euter-test Edit stack.yaml and set the LTS to 12.26 and extra-deps to specify the versions of packages that aren't present in the LTS but are present on Ha...

 
Thanks, but I am not using Linux (I am using the terminal on a Mac).
 
@user65526 The Stack setup should be the same regardless of OS, so try the above: if you get any Mac-specific errors while running the above then edit those into your question.
 
@hnefati The problem is, I don't understand what you mean by In stack.yaml, set the LTS to 12.26 and extra-deps to specify the versions of packages that aren't present in the LTS but are present on Hackage.. I don't have enough knowledge to understand what this means.
 
@user65526 I've added a step for making a new Stack project: each step in the above is followed by the commands to run to perform the step, or the relevant contents of the mentioned file: you just need to update your project's config files to look similar to the above. You might want to skim the Stack user manual.
 
@hnefati Ok, I wrote ` stack new euter-test` and it seemed to do something. Now I will try stack install Euterpea
@hnefati stack install Euterpea did not work, and produced Error: While constructing the build plan, the following exceptions were encountered: In the dependencies for Euterpea-2.0.6: PortMidi must match ==0.1.6.1, but the stack configuration has no specified version (latest matching version is 0.1.6.1) arrows must match >=0.4 && <0.5, but the stack configuration has no specified version (latest matching version is 0.4.4.2) needed since Euterpea is a build target. Some different approaches to resolving this:
* Consider trying 'stack solver', which uses the cabal-install solver to attempt to find some working build configuration. This can be convenient when dealing with many complicated constraint errors, but results may be unpredictable. * Recommended action: try adding the following to your extra-deps in /Users/Mo/.stack/global-project/stack.yaml: - PortMidi-0.1.6.1 - arrows-0.4.4.2
 
11:24 AM
@user65526 Yeah, running stack install Euterpea isn't going to work: it's the same as what you've already tried in your question. Edit stack.yaml and package.yaml as described in the answer, then run stack build.
 
@hnefati thanks. Sorry, I don't know how to edit a program configuration (and don't know what one is). Could you possibly include all the relevant steps in your answer?
 
@user65526 stack.yaml and package.yaml are just ordinary files on your system: you can edit them using TextEdit or any mac text editing program.
 
Ok, thanks! :)
So to edit stack,yaml I have to open them.
that would be by typing stack.yaml at the terminal?
 
apple.stackexchange.com/questions/16593/… might be useful in this case
open -t stack.yaml is probably enough. The file should be in a directory called euter-test in your home directory though, you should be able to navigate to it using the file explorer.
 
open -t stack.yaml on the terminal produces The file /Users/Mo/stack.yaml does not exist.
 
11:29 AM
Looks like you didn't run cd euter-test as described in the answer.
 
When I add the information in extra deps am I supposed to add it between the brackets []?
Because extra deps appears as # extra-deps: []
 
You can, but it'd be easier to just copy the snippet from the answer and overwrite the # extra-deps: [] line with it.
 
It all seems to work. However, the simple test you propose is to save a file as app/Main.hs (the / automatically appears as a colon when I save it). And then I am supposed to load the file on GHCI, by using :l app/Main.hs?
 
11:45 AM
Not sure what's up with the colon: if you run open -t /Users/Mo/euter-test/app/stack.yaml do you get the same file?
Sorry, open -t /Users/Mo/euter-test/app/Main.hs
That's the main source file for the executable in the Stack project: you run it by running stack exec euter-test-exe. I've updated the answer with that last bit.
 
Yes, I do get the same file.
So typing `stack exec euter-test-exe` produces
`someFunc`.
Do I then just write on the terminal `ghci
import Euterpea
play $ c 4 qn` (as suggested http://www.euterpea.com)
 
Okay, that's a weird mac issue: looks like you're not actually editing app/Main.hs. Try running cd app, then ls to check that Main.hs exists, then open -t Main.hs.
 
This produces: `Mo-MacBook-Pro:euter-test Mo$ cd app
Mo-MacBook-Pro:app Mo$ ls
Main.hs
Mo-MacBook-Pro:app Mo$ -t Main.hs
-bash: -t: command not found`
 
You're missing the open
 
Yes, that opens the file.
And so now I just write on the terminal `ghci
import Euterpea
play $ c 4 qn` (as suggested euterpea.com)?
 
11:53 AM
Ah, you probably need to run stack build to recompile the executable
Then stack exec euter-test-exe. If you want to use the interactive prompt (ghci) then use stack ghci instead of just ghci: then import Euterpea and play $ c 4 qn should work.
 
Mo-MacBook-Pro:app Mo$ stack exec euter-test-exe
someFunc
is produced again
 
Any errors produced by stack build?
 
stack build produces nothing
before when I tried it
I got a long piece of code, which I thought had meant I had succeeded in installing Euterpea.
 
Okay, try:

stack ghci
import Euterpea
play $ c 4 qn
 
Then I tried `:l app/Main.hs
[1 of 1] Compiling Main ( app/Main.hs, interpreted )

app/Main.hs:3:1: error:
Could not find module ‘Lib’
Use -v to see a list of the files searched for.
|
3 | import Lib
| ^^^^^^^^^^
Failed, no modules loaded.
Prelude> :l app:Main.hs`
What is the difference between stack ghci and just typing ghci at the terminal?
 
12:00 PM
stack ghci invokes ghci with awareness of the Stack project it's being run in
Plain ghci isn't aware of any of the project around it
 
ok
So I get
`Mo-MacBook-Pro:app Mo$ stack ghci
The following GHC options are incompatible with GHCi and have not been passed to it: -threaded
Configuring GHCi with the following packages: euter-test
Using main module: 1. Package `euter-test' component exe:euter-test-exe with main-is file: /Users/Mo/euter-test/app/Main.hs
GHCi, version 8.6.3: http://www.haskell.org/ghc/ :? for help
[1 of 2] Compiling Lib ( /Users/Mo/euter-test/src/Lib.hs, interpreted )
[2 of 2] Compiling Main ( /Users/Mo/euter-test/app/Main.hs, interpreted )
 
Okay, the Euterpea library is installed successfully
But you've not set up a MIDI synthesiser
That should be described on euterpea.com
 
Ah yes, but it says do that before installing it. I hope that doesn't lead to problems
 
Should be fine, good luck setting up the synthesiser. If you run into issues with that, you should probably ask a follow-up question on apple.stackexchange.com
 
I am trying brew install fluidsynth pkg-config on a seperate terminal tab.
Done. So then I should try `stack ghci
import Euterpea
play $ c 4 qn` again?
 
12:09 PM
Looks like you need to have fluidsynth running at the same time
 
12:23 PM
How do I do that?
stack fluidsynth
stack ghci
import Euterpea?
 
If you installed it using brew then it'll probably be available as a binary. You only need to use stack to run haskell things compiled with stack
Just running fluidsynth should start it up
Maybe fluidsynth -s to run it in server mode
You should ask on apple.stackexchange.com. I don't have a mac and haven't used MIDI software synthesisers before, so can't help here.
It's also sufficiently off-topic from your original question (how to set up Euterpea) that it should be asked as a distinct question.
 
 
1 hour later…
1:56 PM
but after running fluidsynth how do I get Euterpea up and running concurrently?
I get
Prelude Euterpea> :l Main.hs
[1 of 2] Compiling Lib ( /Users/Mo/euter-test/src/Lib.hs, interpreted )
[2 of 2] Compiling Main ( Main.hs, interpreted )
Ok, two modules loaded.
*Main Euterpea> play $ c 4 qn
*** Exception: No MIDI outputs!
CallStack (from HasCallStack):
error, called at ./Euterpea/IO/MIDI/Play.lhs:133:54 in Euterpea-2.0.6-3D1WakAVYqXEJrbg0DJApV:Euterpea.IO.MIDI.Play
 
 
2 hours later…
4:22 PM
Try running devices in stack ghci to get the list of available MIDI devices (hackage.haskell.org/package/Euterpea-2.0.6/docs/…)
Then if there are any, use playDev x $ c 4 qn where x is the number of the output device (hackage.haskell.org/package/Euterpea-2.0.6/docs/…)
 

  last day (19 days later) »