From 4cb434a1993fb2100acead230e6af6b1f0ed1e04 Mon Sep 17 00:00:00 2001 From: sternenseemann Date: Fri, 25 Aug 2017 19:00:44 +0200 Subject: [PATCH] Make Euterpea compatible with the latest PortMidi and stm versions --- Euterpea.cabal | 4 ++-- Euterpea/IO/MIDI/MidiIO.lhs | 13 +++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Euterpea.cabal b/Euterpea.cabal index c1ce7c8..c229da3 100644 --- a/Euterpea.cabal +++ b/Euterpea.cabal @@ -62,9 +62,9 @@ Library array>=0.5.0.0 && <=0.5.1.1, deepseq>=1.3.0.2 && <=1.4.2.0, random>=1.0.1.1 && <=1.1, - PortMidi==0.1.5.2, + PortMidi>=0.1.5.3 && < 1.7, HCodecs == 0.5, - stm==2.4.2, + stm>=2.4.2 && <2.5, containers>=0.5.5.1 && <=0.5.7.1, bytestring>=0.10.4.0 && <= 0.10.9, heap >= 1.0 && < 2.0, diff --git a/Euterpea/IO/MIDI/MidiIO.lhs b/Euterpea/IO/MIDI/MidiIO.lhs index 8bb417a..25a5e19 100644 --- a/Euterpea/IO/MIDI/MidiIO.lhs +++ b/Euterpea/IO/MIDI/MidiIO.lhs @@ -21,7 +21,8 @@ > openInput, openOutput, readEvents, > close, writeShort, getErrorText, terminate, initialize, > PMError (NoError, BufferOverflow), PMStream, -> PMEvent (..), PMMsg (PMMsg)) +> PMEvent (..), PMMsg (PMMsg), +> decodeMsg, encodeMsg) > import Control.Exception (finally) > import Control.Concurrent > import Control.Concurrent.STM.TChan @@ -272,7 +273,7 @@ DWC NOTE: Why is the time even used? All messages get the same time? > else reportError "pollMidiCB" e > Left l -> do > now <- getTimeNow -> case mapMaybe (msgToMidi . message) l of +> case mapMaybe (msgToMidi . decodeMsg . message) l of > [] -> return () > ms -> callback (now, ms) @@ -296,7 +297,7 @@ DWC NOTE: Why is the time even used? All messages get the same time? > else reportError "pollMIDI" e >> return Nothing > Left l -> do > now <- getTimeNow -> case mapMaybe (msgToMidi . message) l of +> case mapMaybe (msgToMidi . decodeMsg . message) l of > [] -> return Nothing > ms -> return $ Just (now, ms) @@ -421,7 +422,7 @@ use one and when to use the other. > if isTrackEnd msg > then return () > else case midiEvent msg of -> Just m -> writeMsg s t m +> Just m -> writeMsg s t $ encodeMsg m > Nothing -> return () > writeMsg s t m = do > e <- writeShort s (PMEvent m (round (t * 1e3))) @@ -486,7 +487,7 @@ use one and when to use the other. > process t msg = if isTrackEnd msg > then return True > else case midiEvent msg of -> Just m -> writeMsg t m +> Just m -> writeMsg t $ encodeMsg m > Nothing -> return False > writeMsg t m = do > e <- writeShort s (PMEvent m (round (t * 1e3))) @@ -650,7 +651,7 @@ A conversion function from PortMidi PMMsgs to Codec.Midi Messages. > sendEvts start now [] = loop start s fin > sendEvts start now (e@(PMEvent m t):l) = do > let t0 = maybe t id start -> case msgToMidi m of +> case msgToMidi (decodeMsg m) of > Just m' -> do > done <- callback (now + fromIntegral (t - t0) / 1E3, m') > if done then close s >> return () else sendEvts (Just t0) now l