External Publication
Visit Post

Euterpea library to create music with Haskell

Haskell Community [Unofficial] June 4, 2026
Source

in ghci : - I played the file (i.e. saved in music.hs) using my piano (BlueTooth MIDI #7),

  • saved to a midi file called music.midi and

  • opened the file using MuseScore

    Loaded package environment from /Users/me/.ghc/aarch64-darwin-9.6.6/environments/default GHCi, version 9.6.6: :? for help ghci> :l music.hs [1 of 2] Compiling Main ( music.hs, interpreted ) Ok, one module loaded. ghci> devices Input devices: InputDeviceID 0 IAC Driver Bus 1 InputDeviceID 1 Network RTP Session 1 InputDeviceID 2 UMP Network Network MIDI 2.0 Session 1 InputDeviceID 3 FP-30 Bluetooth Output devices: OutputDeviceID 4 IAC Driver Bus 1 OutputDeviceID 5 Network RTP Session 1 OutputDeviceID 6 UMP Network Network MIDI 2.0 Session 1 OutputDeviceID 7 FP-30 Bluetooth ghci> playDev 7 mel ghci> writeMidi "music.midi" mel ghci> :q Leaving GHCi.

    % open music.midi

This is what is displayed in MuseScore


Toxypiks:

import Euterpea

hNote          :: Dur -> Pitch -> Int -> Music Pitch
hNote d p h = note d p :=: note d (trans (-h) p)

mel :: Music Pitch
mel = wnr :+: hNote qn (F,4) 3 :+: hNote qn (A,4) 4 :+: wnr :+: hNote qn (F,4) 3

main :: IO()
main = do
     play mel

Discussion in the ATmosphere

Loading comments...