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

Derive.Eval

Description

Evaluate tracklang expressions.

Synopsis

eval / apply

eval_toplevel :: CallableExpr d => Context d -> DeriveT.Expr -> Deriver (Stream.Stream d) Source #

Apply a toplevel expression.

eval_quoted_normalized :: CallableExpr d => Context d -> DeriveT.Quoted -> Deriver (Stream.Stream d) Source #

This is like eval_quoted, except that the ctx_event is set to (0, 1) normalized time. This is important if you want to place the resulting deriver. Otherwise, you can use eval_quoted and the event's position will fall through to the callee.

TODO this awkwardness is because events evaluate in track time, not in normalized time. Details in Derive.EvalTrack.

eval_expr_val :: CallableExpr d => Context d -> Expr.Expr Expr.MiniVal -> Deriver (Stream.Stream d) Source #

Eval a Expr MiniVal, which is produced by Expr.ToExpr.

generator

apply_generator :: Context d -> Generator d -> [DeriveT.Val] -> Deriver (Stream.Stream d) Source #

Like eval_generator, but for when the args are already parsed and evaluated. This is useful when one generator wants to dispatch to another.

transformer

eval_transform_expr :: (Callable (Transformer d), Taggable d) => Text -> Text -> Deriver (Stream.Stream d) -> Deriver (Stream.Stream d) Source #

Parse and apply a transformer expression.

apply_transformer :: Context d -> Transformer d -> [DeriveT.Val] -> Deriver (Stream.Stream d) -> Deriver (Stream.Stream d) Source #

The transformer version of apply_generator. Like eval_transformers, but apply only one, and apply to already evaluated DeriveT.Vals. This is useful when you want to re-apply an already parsed set of vals.

val calls

lookup call

call_to_block_id Source #

Arguments

:: Id.Namespace 
-> Maybe Id.BlockId

If the symbol starts with -, this block is prepended to it.

-> Expr.Symbol 
-> Maybe Id.BlockId 

Given a Symbol, try to come up with the BlockId of the block it could be a call for.

block_id_to_call :: Bool -> Id.BlockId -> Id.BlockId -> Text Source #

Create the symbol to call a given block.

relative calls

is_relative :: Expr.Symbol -> Bool Source #

True if this is a relative block call.

make_relative :: Id.BlockId -> Text -> Text Source #

Make a block name relative to a parent block.

parse_relative_id :: Id.BlockId -> Maybe (Id.BlockId, Id.Id) Source #

If it's a relative BlockId, return the parent and relative call.

util

eval_one :: CallableExpr d => Bool -> DeriveT.Expr -> Deriver (Stream.Stream d) Source #

Evaluate a single note as a generator. Fake up an event with no prev or next lists.

eval_event :: CallableExpr d => Event.Event -> Deriver (Either Text (Stream.Stream d)) Source #

Like derive_event but evaluate the event outside of its track context. This is useful if you want to evaluate things out of order, i.e. evaluate the next pitch.

reapply_generator :: Callable (Generator d) => PassedArgs d -> Expr.Symbol -> Deriver (Stream.Stream d) Source #

Evaluate a generator, reusing the passed args but replacing the Symbol. Generators can use this to delegate to other generators.

reapply_generator_normalized :: Callable (Generator d) => PassedArgs d -> Expr.Symbol -> Deriver (Stream.Stream d) Source #

Like reapply_generator, but the note is given normalized time, 0--1, instead of inheriting the start and duration from the args. This is essential if you want to shift or stretch the note.

reapply :: CallableExpr d => Context d -> DeriveT.Expr -> Deriver (Stream.Stream d) Source #

Apply an expr with an explicit Context. You can use this to reuse the current call's Context, but be careful because it will also inherit the ctx_sub_tracks, which means if inversion hasn't happened yet, which may be what you want or may be surprising. For instance, it will likely override any pitch you try to set.

eval_pitch :: ScoreTime -> DeriveT.PitchCall -> Deriver (DeriveT.RawPitch a) Source #

A version of eval specialized to evaluate pitch calls. It's unknown if this pitch has been transposed or not.

eval_note :: Scale -> Pitch.Note -> Deriver (DeriveT.RawPitch a) Source #

Get a Pitch from in a given scale. Like eval_pitch, it's unknown if this pitch has been transposed or not.

apply_pitch :: ScoreTime -> ValCall -> Deriver (DeriveT.RawPitch a) Source #

This is like eval_pitch when you already know the call, presumably because you asked scale_note_to_call.

eval_expr Source #

Arguments

:: CallableExpr d 
=> Bool

See catch. This should be True for evals that generate notes for eventual output.

-> Context d 
-> DeriveT.Expr 
-> Deriver (Stream.Stream d) 

Evaluate a single expression, catching an exception if it throws.