Skip to content

Commit

Permalink
panbus seems to work now ref #762
Browse files Browse the repository at this point in the history
  • Loading branch information
yaxu committed Jan 21, 2021
1 parent c09e7bb commit 43872dc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 5 additions & 0 deletions src/Sound/Tidal/Params.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ module Sound.Tidal.Params where
import qualified Data.Map.Strict as Map

import Sound.Tidal.Pattern
import Sound.Tidal.Core ((#))
import Sound.Tidal.Utils
import Data.Maybe (fromMaybe)
import Data.Word (Word8)
Expand Down Expand Up @@ -330,6 +331,10 @@ overshape = pF "overshape"
-- | a pattern of numbers between 0 and 1, from left to right (assuming stereo), once round a circle (assuming multichannel)
pan :: Pattern Double -> ControlPattern
pan = pF "pan"

panbus :: Pattern Int -> Pattern Double -> ControlPattern
panbus busid pat = (pF "pan" pat) # (pI "^pan" busid)

-- | a pattern of numbers between -inf and inf, which controls how much multichannel output is fanned out (negative is backwards ordering)
panspan :: Pattern Double -> ControlPattern
panspan = pF "span"
Expand Down
8 changes: 4 additions & 4 deletions src/Sound/Tidal/Stream.hs
Original file line number Diff line number Diff line change
Expand Up @@ -306,10 +306,11 @@ playStack pMap = stack $ map pattern active
toOSC :: Double -> [Int] -> Event ControlMap -> T.Tempo -> OSC -> [(Double, Bool, O.Message)]
toOSC latency busses e tempo osc@(OSC _ _)
= catMaybes (playmsg:busmsgs)
where (busmap, playmap) = Map.partitionWithKey (\k _ -> null k || head k /= '^') $ value e
where (playmap, busmap) = Map.partitionWithKey (\k _ -> null k || head k /= '^') $ value e
-- swap in bus ids where needed
playmap' = Map.union (Map.mapKeys tail $ Map.map (\(VI i) -> VS ('c':(show i))) busmap) playmap
playmsg | eventHasOnset e = do vs <- toData osc addExtra
addExtra = Map.union playmap' extra
playmsg | eventHasOnset e = do vs <- toData osc (e {value = addExtra})
mungedPath <- substitutePath (path osc) playmap'
return (ts,
False, -- bus message ?
Expand All @@ -331,12 +332,11 @@ toOSC latency busses e tempo osc@(OSC _ _)
off = sched tempo $ stop $ wholeOrPart e
delta = off - on
-- If there is already cps in the event, the union will preserve that.
addExtra = (\v -> (Map.union v extra)) <$> e
extra = Map.fromList [("cps", (VF (T.cps tempo))),
("delta", VF delta),
("cycle", VF (fromRational $ start $ wholeOrPart e))
]
nudge = fromJust $ getF $ fromMaybe (VF 0) $ Map.lookup "nudge" $ value e
nudge = fromJust $ getF $ fromMaybe (VF 0) $ Map.lookup "nudge" $ playmap
ts = on + nudge + latency
tsPart = onPart + nudge + latency

Expand Down

0 comments on commit 43872dc

Please sign in to comment.