Euterpea library to create music with Haskell

Hey guys,

I’m currently trying to play some notes with the Haskell Euterpea library. I’m using yoshimi as a synthesizer software. My Problem is, for some odd reason the first note gets skipped, only the second, third and so on are played. No matter what melody I try to play, its always the same. Someone has the same problem or an idea how to fix it?


module Main (main) where                                                                                                                                                                                                                                                                                                                                                             

import Euterpea  

hNote          :: Dur -> Pitch -> Int -> Music Pitch                                                                                                                                       
hNote d p h = note d p :=: note d (trans (-h) p)                                                                                                                
                                                                                                                                                                                             
mel :: Music Pitch                                                                                                                                                                    
mel = hNote qn (F,4) 3 :+: hNote qn (A,4) 4 :+: hNote qn (F,4) 3                                                                                                             
                                                                                                                                                                                                                                                                                                                                    
main :: IO()                                                                                                                                                                                 
main = do                                                                                                                                                                                                                                                                                                                                                                 
     play mel

Thank u for any help :slight_smile:

2 Likes

If you sandwich your code block between ```, your post will be easier to read.

I have a similar problem when I dabble with ABC notation. The first note of the resulting .midi does not get played on some synthesizers.

I work around it by adding a very small pause at the beginning of the piece. Maybe this will work with Euterpea too?

Thank u for your suggestion, I just edited the post :slight_smile:

I also thought about some workaround like adding a small pause or a dummy note in front of my melody.
Was just wondering if there’s a more elegant way to fix this, but maybe its a problem with yoshimi then.

1 Like

Just tried to add a small pause at the beginning of my melody, but actually that’s not working. The next note will also be skipped and only the third and fourth note will be played. That’s fairly weird.

Here’s my code with the pause (I also added the same pause in between the third and fourth note just for testing if the pause works).


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

Can Euterpea export a .midi?