Skip to content

Commit

Permalink
etc
Browse files Browse the repository at this point in the history
  • Loading branch information
ejconlon committed Dec 20, 2024
1 parent ee58e89 commit 438cc18
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
20 changes: 19 additions & 1 deletion minipat-midi/src/Minipat/Midi/Boot.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ module Minipat.Midi.Boot
, PortName
, port
, midi
, control
, program
, allNotesOff
, allSoundOff
, module Minipat.Live.Boot
)
where
Expand All @@ -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)

Expand All @@ -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))

2 changes: 1 addition & 1 deletion minipat-midi/src/Minipat/Midi/Impl.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 438cc18

Please sign in to comment.