Karya, built on 2023-08-29T07:47:28 (patch 7a412d5d6ba4968ca4155ef276a062ccdeb9109a)
Safe HaskellSafe-Inferred

Cmd.Perf

Description

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

Documentation

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.

mini_derive Source #

Arguments

:: 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.

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

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.

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.

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

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.

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.

get_realtimes :: Performance -> BlockId -> TrackId -> [ScoreTime] -> [(ScoreTime, RealTime)] Source #

Like get_realtime, but do multiple at once.

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.

find score times

sub_pos :: Cmd.M m => BlockId -> TrackId -> ScoreTime -> m [(BlockId, [(TrackId, ScoreTime)])] Source #

Give a block and score time, return the play position on sub-blocks. The block itself is filtered out of the result.