Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installation issues on macOS Sonoma 14.5 with GHC 9.4.8 and Cabal 3.10.3.0 #59

Open
Quarkstar opened this issue Jul 16, 2024 · 5 comments

Comments

@Quarkstar
Copy link

Hi! I'm experiencing issues while installing the Euterpea Haskell package on my macOS Sonoma 14.5 system with GHC 9.4.8 and Cabal 3.10.3.0.

The initial issue is a compilation error in the PortMidi 0.2.0.0 package, specifically in the portmidi/pm_mac/pmmacosxcm.c:60:22 file. The error is:

error: incompatible pointer to integer conversion initializing 'MIDIClientRef' (aka 'unsigned int') with an expression of type 'void *' [-Wint-conversion]

To resolve this, I followed the instructions in the PortMidi (https://github.com/PortMidi/portmidi/blob/8efac0cfe6c245aeb2ce5122aa2b82fb79e91463/pm_mac/pmmacosxcm.c#L187), downloaded the PortMidi-Haskell package, and added #define NULL 0 to the portmidi/pm_mac/pmmacosxcm.c file. After doing this, I was able to successfully install the PortMidi-Haskell and Euterpea using cabal v1-install.

However, when I try to import the Euterpea package in GHCi, I encounter a different issue:

λ> import Euterpea

<interactive>:1:1: error:
    attempting to use module ‘main:Euterpea’ (./Euterpea.lhs) which is not loaded
λ> :l Euterpea.lhs
[ 1 of 18] Compiling Control.Arrow.ArrowP ( Control/Arrow/ArrowP.lhs, interpreted )
[ 2 of 18] Compiling Control.SF.SF    ( Control/SF/SF.lhs, interpreted )
[ 3 of 18] Compiling Euterpea.IO.Audio.Types ( Euterpea/IO/Audio/Types.hs, interpreted )
[ 4 of 18] Compiling Euterpea.IO.Audio.IO ( Euterpea/IO/Audio/IO.hs, interpreted )
[ 5 of 18] Compiling Euterpea.IO.MIDI.ExportMidiFile ( Euterpea/IO/MIDI/ExportMidiFile.lhs, interpreted )
[ 6 of 18] Compiling Euterpea.IO.MIDI.MidiIO ( Euterpea/IO/MIDI/MidiIO.lhs, interpreted )

Euterpea/IO/MIDI/MidiIO.lhs:327:5: error:
    parse error (possibly incorrect indentation or mismatched brackets)
    |
327 | >   case m of
    |     ^
[ 7 of 18] Compiling Euterpea.Music   ( Euterpea/Music.lhs, interpreted )
[ 8 of 18] Compiling Euterpea.IO.MIDI.MEvent ( Euterpea/IO/MIDI/MEvent.lhs, interpreted )
[ 9 of 18] Compiling Euterpea.IO.MIDI.GeneralMidi ( Euterpea/IO/MIDI/GeneralMidi.hs, interpreted )
[14 of 18] Compiling Euterpea.IO.Audio.Basics ( Euterpea/IO/Audio/Basics.hs, interpreted )
[15 of 18] Compiling Euterpea.IO.Audio.Render ( Euterpea/IO/Audio/Render.hs, interpreted )
[16 of 18] Compiling Euterpea.IO.Audio.BasicSigFuns ( Euterpea/IO/Audio/BasicSigFuns.lhs, interpreted )
[17 of 18] Compiling Euterpea.IO.Audio ( Euterpea/IO/Audio.hs, interpreted )
Failed, 12 modules loaded.
> deliverMidiEvent :: OutputDeviceID -> MidiEvent -> IO ()
> deliverMidiEvent devId (t,m) = do
>   (pChan, out, _stop) <- getOutDev devId
>   now <- getTimeNow
>   let deliver t m = do
>       if t == 0
>         then out (now,m)
>         else push pChan (now+t) m
>
>   case m of
>     Std m -> deliver t m
>     ANote c k v d -> do
>         deliver t     (NoteOn c k v)
>         deliver (t+d) (NoteOff c k v)

I'm new to Haskell and I found this parse error in the Euterpea/IO/MIDI/MidiIO.lhs file really confusing. Any advice or suggestions would be greatly appreciated.

@donya
Copy link
Member

donya commented Jul 16, 2024

This is a new error to me. Unfortunately it will be a bit before I can dig into this. At a glance this looks like it may be outside the scope of Euterpea's code base and therefore might not be something I can fix directly. Since it's a failure within PortMidi I would suggest also creating an issue here: https://github.com/PortMidi/PortMidi-haskell

In the mean time, I don't know if this will help or not with what you're trying to do with Euterpea, but if you don't mind writing MIDI files and playing them through another program (like MuseScore or a DAW) instead of using the "play" function to do it directly through a synth, you can try EuterpeaLite instead and avoid the whole PortMidi installation.

Also it's unclear to me if you used the --allow-newer flag? If not, give that a try.

@ludflu
Copy link

ludflu commented Aug 6, 2024

I actually just fixed this issue in PortMidi, and my PR has been approved, but its not merged yet. PortMidi/PortMidi-haskell#21

@amordahl
Copy link

@ludflu Were you able to fix this? I am experiencing the same issue.

@charleswaddell
Copy link

I also ran into this issue running MacOS Sonoma 14.6.1, Cabal 3.12.1.0, and GHC 9.4.8. After reading the Euterpea website, the Cabal docs, and the issues on this repo I think I found a solution for my use case and figured I would share it in the case it may be useful to others.

In order to get up and running I did the following.



  1. Installed a Haskell developer environment using GHCup.

  2. I made a project directory and ran cabal init --interactive inside it to create a Cabal project that would be my Euterpea playground.
  3. I added a custom cabal.project file to that directory to allow for the use of forks of the Euterpea and HSoM packages. Without these forks I would run into issues trying to build the project. See contents below.
  4. Finally, I added Euterpea == 2.0.8, HSoM == 1.0.0 to the build-depends: section in my project’s .cabal file.



This all allowed me to run cabal repl to get me an interpreter. I could import Euterpea and play sounds - play $ c 4 qn - once I had a MIDI Synthesizer setup.

All the changes in the Euterpea and HSoM forks are related to either expanding the allowed versions for dependencies or changing the build type in the Cabal file. All that being said my solution has been very lightly tested on only one machine.

I am planning to work my way through the Haskell School of Music textbook so I wanted to have the HSoM package available in my project. If you just want to use Euterpea you can remove the fork and build dependency for HSoM.

Once PortMidi/PortMidi-haskell#22 is merged and a new version released we should no longer need the fork for PortMidi-haskell in cabal.project.

Perhaps some of the above is helpful to @amordahl @Quarkstar.

Contents of 
cabal.project

packages: .

source-repository-package
    type: git
    location: https://github.com/georgefst/Euterpea2
    tag: 3bbb079bf95f9c36da0bd8850313ae4a8fbee0cf

source-repository-package
    type: git
    location: https://github.com/ninioArtillero/HSoM
    tag: abac8cbd4e18381ee1d10d247521af770c4e3010

source-repository-package
    type: git
    location: https://github.com/dpwiz/PortMidi-haskell
    tag: 170187c0829283affeaffd805163d60186fb727c

@amordahl
Copy link

@charleswaddell Thank you so much! This worked for me on an M4 Macbook Pro.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants