Safe Haskell | Safe-Inferred |
---|
This module is for Cmds that want to peek into the derived score for whatever reason. Normally the flow of information goes from Cmd -> Derive -> Perform, but this module is for those cases when Cmd wants to know about the results of later stages.
Synopsis
- get :: Cmd.M m => BlockId -> m Performance
- get_current :: Cmd.M m => BlockId -> m Performance
- lookup_root :: Cmd.M m => m (Maybe Performance)
- get_root :: Cmd.M m => m Performance
- derive_note_call :: Cmd.M m => BlockId -> TrackId -> TrackTime -> Expr.Symbol -> m (Either Text [Score.Event], [Log.Msg])
- derive_expr :: (Cmd.M m, CallableExpr d) => BlockId -> TrackId -> TrackTime -> DeriveT.Expr -> m (Either Text [d], [Log.Msg])
- derive_at :: Cmd.M m => BlockId -> TrackId -> Deriver a -> m (Either Text a, [Log.Msg])
- derive_at_exc :: Cmd.M m => BlockId -> TrackId -> Deriver a -> m (Either Error a, [Log.Msg])
- mini_derive :: Ui.State -> Cmd.Config -> Builtins -> InstrumentAliases -> Deriver a -> (Either Error a, [Log.Msg])
- derive_at_throw :: Cmd.M m => BlockId -> TrackId -> Deriver a -> m a
- lookup_note_deriver :: Cmd.M m => BlockId -> TrackId -> Event.Event -> m (Maybe NoteDeriver)
- derive_event :: CallableExpr d => EvalTrack.TrackInfo d -> Event.Event -> Deriver (Stream.Stream d)
- find_track :: Cmd.M m => BlockId -> TrackId -> m TrackTree.EventsNode
- global_environ :: Cmd.M m => m DeriveT.Environ
- smuggle_environ :: NoteDeriver
- derive :: Cmd.M m => Deriver a -> m (Either Text a)
- perform :: Cmd.M m => [Score.Event] -> m ([Midi.WriteMessage], [Log.Msg])
- type Track = (BlockId, Maybe TrackId)
- get_scale_id :: Cmd.M m => Track -> m Pitch.ScaleId
- lookup_scale2 :: Cmd.M m => Track -> m (Maybe Scale)
- find_scale_id :: Cmd.M m => Track -> m (Maybe Pitch.ScaleId)
- get_scale :: Cmd.M m => Track -> m Scale
- lookup_scale :: Cmd.M m => Track -> Pitch.ScaleId -> m (Maybe Scale)
- lookup_scale_env :: Cmd.M m => DeriveT.Environ -> Pitch.ScaleId -> m (Maybe Scale)
- scale_from_titles :: Ui.M m => BlockId -> TrackId -> m (Maybe Pitch.ScaleId)
- lookup_instrument :: Cmd.M m => Track -> m (Maybe ScoreT.Instrument)
- lookup_val :: (Cmd.M m, Typecheck.Typecheck a) => Track -> EnvKey.Key -> m (Maybe a)
- lookup_environ_val :: (Ui.M m, Typecheck.Typecheck a) => EnvKey.Key -> DeriveT.Environ -> m (Maybe a)
- lookup_environ :: Cmd.M m => Track -> m (Maybe DeriveT.Environ)
- get_environ :: Cmd.M m => Track -> m DeriveT.Environ
- find_dynamic :: Cmd.M m => Track -> m (Maybe Dynamic)
- lookup_root_dynamic :: Cmd.M m => Track -> m (Maybe Dynamic)
- lookup_dynamic :: Cmd.M m => BlockId -> Track -> m (Maybe Dynamic)
- muted_im_instruments :: Cmd.M m => BlockId -> m (Set ScoreT.Instrument)
- get_muted_instrument_tracks :: Cmd.M m => BlockId -> m (Set ScoreT.Instrument)
- infer_instrument :: Cmd.M m => TrackId -> m (Maybe ScoreT.Instrument)
- lookup_default_environ :: (Typecheck.Typecheck a, Cmd.M m) => EnvKey.Key -> m (Maybe a)
- get_default_environ :: (Typecheck.Typecheck a, Cmd.M m) => EnvKey.Key -> m a
- default_scale_id :: Cmd.M m => m Pitch.ScaleId
- get_realtime :: Cmd.M m => Performance -> BlockId -> Maybe TrackId -> ScoreTime -> m RealTime
- lookup_realtime :: Cmd.M m => Performance -> BlockId -> Maybe TrackId -> ScoreTime -> m (Maybe RealTime)
- get_realtimes :: Performance -> BlockId -> TrackId -> [ScoreTime] -> [(ScoreTime, RealTime)]
- get_inverse_tempo :: Cmd.M m => BlockId -> m Transport.InverseTempoFunction
- find_play_pos :: Ui.M m => Transport.InverseTempoFunction -> RealTime -> m [(ViewId, [(TrackNum, ScoreTime)])]
- block_pos_to_play_pos :: Ui.M m => [(BlockId, [(TrackId, ScoreTime)])] -> m [(ViewId, [(TrackNum, ScoreTime)])]
- convert :: Ui.M m => (BlockId, [(TrackId, ScoreTime)]) -> m [(ViewId, [(TrackNum, ScoreTime)])]
- tracknums_of :: Block.Block -> (TrackId, ScoreTime) -> [(TrackNum, ScoreTime)]
- sub_pos :: Cmd.M m => BlockId -> TrackId -> ScoreTime -> m [(BlockId, [(TrackId, ScoreTime)])]
Documentation
get_current :: Cmd.M m => BlockId -> m Performance Source #
lookup_root :: Cmd.M m => m (Maybe Performance) Source #
get_root :: Cmd.M m => m Performance Source #
derive
derive_note_call :: Cmd.M m => BlockId -> TrackId -> TrackTime -> Expr.Symbol -> m (Either Text [Score.Event], [Log.Msg]) Source #
Specialized version of derive_expr
for note calls with no arguments.
derive_expr :: (Cmd.M m, CallableExpr d) => BlockId -> TrackId -> TrackTime -> DeriveT.Expr -> m (Either Text [d], [Log.Msg]) Source #
Derive an expression.
derive_at :: Cmd.M m => BlockId -> TrackId -> Deriver a -> m (Either Text a, [Log.Msg]) Source #
Run an ad-hoc derivation in the context of the given track.
derive_at_exc :: Cmd.M m => BlockId -> TrackId -> Deriver a -> m (Either Error a, [Log.Msg]) Source #
:: Ui.State | for instrument allocations and because derivers have access to Ui.State |
-> Cmd.Config | for instrument db and builtins |
-> Builtins | |
-> InstrumentAliases | from parsed ky |
-> Deriver a | |
-> (Either Error a, [Log.Msg]) |
This is like derive_at_exc
, except with the minimal dependencies
needed to run a derive.
derive_at_throw :: Cmd.M m => BlockId -> TrackId -> Deriver a -> m a Source #
Like derive_at
, but write logs and throw on a Left.
lookup_note_deriver :: Cmd.M m => BlockId -> TrackId -> Event.Event -> m (Maybe NoteDeriver) Source #
Return the NoteDeriver of a particular event on a particular track, or Nothing if the track isn't a NoteTrack.
derive_event :: CallableExpr d => EvalTrack.TrackInfo d -> Event.Event -> Deriver (Stream.Stream d) Source #
find_track :: Cmd.M m => BlockId -> TrackId -> m TrackTree.EventsNode Source #
global_environ :: Cmd.M m => m DeriveT.Environ Source #
Get the environment established by config_global_transform
.
smuggle_environ :: NoteDeriver Source #
Smuggle the environ out in an event. It's annoying to require such shennanigans, rationale in NOTE [transform-without-derive-callable].
derive :: Cmd.M m => Deriver a -> m (Either Text a) Source #
A cheap quick derivation that sets up the correct initial state, but runs without the cache and throws away any logs.
perform
perform :: Cmd.M m => [Score.Event] -> m ([Midi.WriteMessage], [Log.Msg]) Source #
environ
type Track = (BlockId, Maybe TrackId) Source #
Functions that look in the saved Dynamic use this as a key.
If the TrackId is Nothing, take any old Dynamic found on the given block.
get_scale_id :: Cmd.M m => Track -> m Pitch.ScaleId Source #
Get the scale in scope in a certain track on a certain block.
This tries really really hard to find a ScaleId. The reason is that pitch
track entry uses it to insert pitch names, and if it gets the scale wrong
it inserts bogus pitches. I can't rely on lookup_val
because a new
track has never been derived and thus has no Dynamic.
find_scale_id :: Cmd.M m => Track -> m (Maybe Pitch.ScaleId) Source #
lookup_scale :: Cmd.M m => Track -> Pitch.ScaleId -> m (Maybe Scale) Source #
lookup_scale_env :: Cmd.M m => DeriveT.Environ -> Pitch.ScaleId -> m (Maybe Scale) Source #
scale_from_titles :: Ui.M m => BlockId -> TrackId -> m (Maybe Pitch.ScaleId) Source #
Try to get a scale from the titles of the parents of the given track.
lookup_instrument :: Cmd.M m => Track -> m (Maybe ScoreT.Instrument) Source #
Find the instrument in scope.
lookup_val :: (Cmd.M m, Typecheck.Typecheck a) => Track -> EnvKey.Key -> m (Maybe a) Source #
Lookup value from the deriver's EnvKey at the given block and (possibly)
track. See TrackDynamic
for details on the limitations here.
The value is taken first from the root performance, and then the given block's performance if not present in the root performance. This is so that blocks which are not called from the root at all will still have environ values.
lookup_environ_val :: (Ui.M m, Typecheck.Typecheck a) => EnvKey.Key -> DeriveT.Environ -> m (Maybe a) Source #
lookup_environ :: Cmd.M m => Track -> m (Maybe DeriveT.Environ) Source #
get_environ :: Cmd.M m => Track -> m DeriveT.Environ Source #
find_dynamic :: Cmd.M m => Track -> m (Maybe Dynamic) Source #
Try to find the Dynamic for the given block and track, first looking in the root performance, and then in the block's performance.
muted instruments
muted_im_instruments :: Cmd.M m => BlockId -> m (Set ScoreT.Instrument) Source #
get_muted_instrument_tracks :: Cmd.M m => BlockId -> m (Set ScoreT.Instrument) Source #
infer_instrument :: Cmd.M m => TrackId -> m (Maybe ScoreT.Instrument) Source #
This is like perf_track_instruments
, except it uses the track titles
instead of the performance. This means it's less accurate, but can work
even before there's a performance and might be faster.
default
lookup_default_environ :: (Typecheck.Typecheck a, Cmd.M m) => EnvKey.Key -> m (Maybe a) Source #
Get global defaults.
get_default_environ :: (Typecheck.Typecheck a, Cmd.M m) => EnvKey.Key -> m a Source #
default_scale_id :: Cmd.M m => m Pitch.ScaleId Source #
The default scale established by config_global_transform
, or
Config.default_scale_id
if there is none.
play
get_realtime :: Cmd.M m => Performance -> BlockId -> Maybe TrackId -> ScoreTime -> m RealTime Source #
Given a block, track, and time, find the realtime at that position. If the track is Nothing, use the first track that has tempo information. This is necessary because if a track is muted it will have no tempo, but it's confusing if playing from a muted track fails.
lookup_realtime :: Cmd.M m => Performance -> BlockId -> Maybe TrackId -> ScoreTime -> m (Maybe RealTime) Source #
get_realtimes :: Performance -> BlockId -> TrackId -> [ScoreTime] -> [(ScoreTime, RealTime)] Source #
Like get_realtime
, but do multiple at once.
get_inverse_tempo :: Cmd.M m => BlockId -> m Transport.InverseTempoFunction Source #
find_play_pos :: Ui.M m => Transport.InverseTempoFunction -> RealTime -> m [(ViewId, [(TrackNum, ScoreTime)])] Source #
Take a RealTime to all the ScoreTimes it corresponds to, if any.
block_pos_to_play_pos :: Ui.M m => [(BlockId, [(TrackId, ScoreTime)])] -> m [(ViewId, [(TrackNum, ScoreTime)])] Source #
Do all the annoying shuffling around to convert the deriver-oriented blocks and tracks to the view-oriented views and tracknums.
This function has to be careful to not throw on non-existent IDs, because it's called from the monitor_loop.
convert :: Ui.M m => (BlockId, [(TrackId, ScoreTime)]) -> m [(ViewId, [(TrackNum, ScoreTime)])] Source #
tracknums_of :: Block.Block -> (TrackId, ScoreTime) -> [(TrackNum, ScoreTime)] Source #