Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arbitrary Tempo Callback #1048

Open
mindofmatthew opened this issue Nov 4, 2023 · 1 comment
Open

Arbitrary Tempo Callback #1048

mindofmatthew opened this issue Nov 4, 2023 · 1 comment

Comments

@mindofmatthew
Copy link
Contributor

Following up on a discussion in the Discord, it seems to me like there's value in being able to schedule callbacks that run synchronously with the clock. In particular, it strikes me as a little weird that StreamReplace and Transition are synced to the clock while all the other functions that modify the PlayMap are not, leading to unintuitive results like this:

do
  d1 $ s "bd sn"
  mute 1 -- Won't have an effect if d1 hasn't been previously called

I'd propose something like the following:

--  Tempo.hs --

data TempoAction =
  SetCycle P.Time
  | SingleTick P.ControlSignal
  | SetNudge Double
  | SyncIO (Time -> IO())

----

syncIO :: MVar [TempoAction] -> (Time -> IO ()) -> IO ()

This moves all of the PlayMap code into the Stream module (which also might mean that StreamTypes.hs isn't necessary any more), and generally opens up a hook for implementing custom stream/clock extensions.

I can submit a PR along these lines, but I wanted to know what you all (though mostly @Zalastax) think.

@Zalastax
Copy link
Collaborator

Zalastax commented Nov 4, 2023

I like it a lot! But do we perhaps want two different action types? One for triggering the callback once (on a specific time) and another for triggering the callback repeatedly? And do we want the ability to de-register the callback? From inside or outside the callback? Both?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants