Karya, built on 2022-03-21T01:30:44 (patch 89d1651424c35e564138d93424a157ff87457245)

Derive.Eval

Description

Evaluate tracklang expressions.

Synopsis

# eval / apply

Apply a toplevel expression.

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

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

A list version of apply_transformer.

The same as eval_transformers, but get them out of a Quoted.

# lookup call

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.

Create the symbol to call a given block.

## relative calls

True if this is a relative block call.

Make a block name relative to a parent block.

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

# util

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

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.

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

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.

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.

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

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

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

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.