Skip to content

Commit

Permalink
etc
Browse files Browse the repository at this point in the history
  • Loading branch information
ejconlon committed Dec 19, 2024
1 parent 3703fa0 commit ee58e89
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 33 deletions.
58 changes: 28 additions & 30 deletions minipat-midi/src/Minipat/Midi/Setup.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,34 @@ import Minipat.Midi.Mpk
import Minipat.Midi.SC
import Nanotime (timeDeltaFromFracSecs)

portBackend :: Text -> Double -> MidiBackend
portBackend name delay =
def
{ mbDefOut = Just name
, mbDelay = Just (timeDeltaFromFracSecs delay)
}

withPort :: Text -> Double -> Seq LiveMsg -> IO ()
withPort name delay = connectAndSendMsgs (portBackend name delay)

mpkBackend :: MidiBackend
mpkBackend = portBackend "MPK mini" 0.5

withMpk :: Seq LiveMsg -> IO ()
withMpk = connectAndSendMsgs mpkBackend

scBackend :: MidiBackend
scBackend = portBackend "U2MIDI Pro" 0.05

withSc :: Seq LiveMsg -> IO ()
withSc = connectAndSendMsgs scBackend

fluidBackend :: MidiBackend
fluidBackend = portBackend "fluid" 0.05

withFluid :: Seq LiveMsg -> IO ()
withFluid = connectAndSendMsgs fluidBackend

-- Mpk config for Sc control
mkMpkCfg :: Int -> ProgConfig
mkMpkCfg i = c
Expand All @@ -48,36 +76,6 @@ mkMpkCfg i = c
]
}

mpkBackend :: MidiBackend
mpkBackend =
def
{ mbDefOut = Just "MPK mini"
, mbDelay = Just (timeDeltaFromFracSecs @Double 0.5)
}

withMpk :: Seq LiveMsg -> IO ()
withMpk = connectAndSendMsgs mpkBackend

scBackend :: MidiBackend
scBackend =
def
{ mbDefOut = Just "U2MIDI Pro"
, mbDelay = Just (timeDeltaFromFracSecs @Double 0.05)
}

withSc :: Seq LiveMsg -> IO ()
withSc = connectAndSendMsgs scBackend

busBackend :: MidiBackend
busBackend =
def
{ mbDefOut = Just "Bus"
, mbDelay = Just (timeDeltaFromFracSecs @Double 0.05)
}

withBus :: Seq LiveMsg -> IO ()
withBus = connectAndSendMsgs busBackend

-- Send mpk config
sendMpkCfgs :: IO ()
sendMpkCfgs = withMpk (Seq.fromList [sendProgConfig (ProgBank i) (mkMpkCfg i) | i <- [0 .. 7]])
Expand Down
7 changes: 4 additions & 3 deletions minipat/src/Minipat/Quant.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ module Minipat.Quant
where

import Bowtie (Anno (..))
import Data.IntMap.Strict (IntMap)
import Data.Ratio ((%))
import Minipat.Classes (Flow (..))
import Minipat.Stream (Ev (..), Stream, streamChop)
import Minipat.Time (Arc (..), CycleArc, CycleSpan, CycleTime (..), Span (..), arcIntersect, CycleDelta (..))
import Data.IntMap.Strict (IntMap)
import Minipat.Time (Arc (..), CycleArc, CycleDelta (..), CycleSpan, CycleTime (..), Span (..), arcIntersect)

data TimeStrat
= TimeStratRound
Expand Down Expand Up @@ -104,7 +104,8 @@ quantTrig strat steps = streamChop f
data Block a = Block
{ blockSteps :: !Int
, blockEvs :: !(IntMap a)
} deriving stock (Eq, Ord, Show)
}
deriving stock (Eq, Ord, Show)

blockStepLen :: Block a -> CycleDelta
blockStepLen (Block steps _) = CycleDelta (1 % fromIntegral steps)
Expand Down

0 comments on commit ee58e89

Please sign in to comment.