diff --git a/minipat-midi/src/Minipat/Midi/Boot.hs b/minipat-midi/src/Minipat/Midi/Boot.hs index 51d9bab..05688cc 100644 --- a/minipat-midi/src/Minipat/Midi/Boot.hs +++ b/minipat-midi/src/Minipat/Midi/Boot.hs @@ -13,6 +13,10 @@ module Minipat.Midi.Boot , PortName , port , midi + , control + , program + , allNotesOff + , allSoundOff , module Minipat.Live.Boot ) where @@ -24,7 +28,8 @@ import Minipat.Live.Datum (DatumProxy (..)) import Minipat.Live.Extra (Note, parseDatum, parseMidiNote, parseNote) import Minipat.Midi.Convert (Vel (..)) import Minipat.Midi.Impl qualified as I -import Minipat.Midi.Midi (PortMsg, PortName (..), PortSel) +import Minipat.Midi.Midi (PortMsg (..), PortName (..), PortSel) +import Dahdit.Midi.Midi (Channel, ControlNum, ControlVal, ProgramNum, LiveMsg (..), ChanData (..), ChanVoiceData (..), ChanModeData (..)) type MidiLiveSt = (LiveSt, LiveBackend ~ I.MidiBackend) @@ -50,3 +55,16 @@ port = fmap PortName . parseDatum DatumProxyString midi :: (MidiLiveSt) => Seq PortMsg -> IO () midi ms = readLiveSt >>= \st -> I.sendMsgs st ms + +control :: PortSel -> Channel -> ControlNum -> ControlVal -> PortMsg +control ps ch cn cv = PortMsg ps (LiveMsgChan ch (ChanDataVoice (ChanVoiceControlChange cn cv))) + +program :: PortSel -> Channel -> ProgramNum -> PortMsg +program ps ch pn = PortMsg ps (LiveMsgChan ch (ChanDataVoice (ChanVoiceProgramChange pn))) + +allNotesOff :: PortSel -> Channel -> PortMsg +allNotesOff ps ch = PortMsg ps (LiveMsgChan ch (ChanDataMode ChanModeAllNotesOff)) + +allSoundOff :: PortSel -> Channel -> PortMsg +allSoundOff ps ch = PortMsg ps (LiveMsgChan ch (ChanDataMode ChanModeAllSoundOff)) + diff --git a/minipat-midi/src/Minipat/Midi/Impl.hs b/minipat-midi/src/Minipat/Midi/Impl.hs index fd0727f..b847a08 100644 --- a/minipat-midi/src/Minipat/Midi/Impl.hs +++ b/minipat-midi/src/Minipat/Midi/Impl.hs @@ -59,7 +59,7 @@ type MidiSt = St MidiBackend mkTimedMsgs :: WithPlayMeta M.PortData -> Seq M.TimedMsg mkTimedMsgs (WithPlayMeta pm pd@(M.PortData ps cd)) = let Arc t1 t2 = pmRealArc pm - c = fromInteger (pmOrbit pm - 1) + c = fromInteger (pmOrbit pm) m1 = M.PortMsg ps (LiveMsgChan c cd) s1 = Seq.singleton (M.TimedMsg t1 (M.SortedMsg m1)) in case M.mkNoteOff c pd of