Karya, built on Mon Jul 24 11:39:07 PDT 2017 (patch 33511aca01257b76b88de7c7a2763b7a965c084e)

Safe HaskellNone

Derive.Call

Contents

Description

Utilities for calls.

The convention for calls is that there is a function c_something which is type NoteCall or ControlCall or whatever. It then extracts what is needed from the PassedArgs and passes those values to a function something which is of type NoteDeriver or ControlDeriver or whatever. The idea is that PassedArgs is a large dependency and it should be reduced immediately to what is needed.

Synopsis

signals

control_at :: BaseTypes.ControlRef -> RealTime.RealTime -> Deriver Signal.Y Source #

To accomodate both normal calls, which are in score time, and post processing calls, which are in real time, these functions take RealTimes.

function and signal

to_typed_signal :: BaseTypes.ControlRef -> Deriver TypedControl Source #

Convert a ControlRef to a control signal. If there is a BaseTypes.ControlFunction it will be ignored.

to_transpose_function Source #

Arguments

:: Typecheck.TransposeType 
-> BaseTypes.ControlRef 
-> Deriver (Typecheck.Function, Control)

(signal, appropriate transpose control)

Version of to_function specialized for transpose signals. Throws if the signal had a non-transpose type.

to_time_function :: Typecheck.TimeType -> BaseTypes.ControlRef -> Deriver (Typecheck.Function, Typecheck.TimeType) Source #

Version of to_function that will complain if the control isn't a time type.

dynamic

transposed :: RealTime.RealTime -> Deriver (Maybe BaseTypes.Transposed) Source #

Unlike pitch_at, the transposition has already been applied.

get_pitch :: RealTime.RealTime -> Deriver BaseTypes.Pitch Source #

Pitch without the transposition applied. You have to use this if you create an event with a pitch based on this pitch, otherwise the transposition will be applied twice.

get_parsed_pitch Source #

Arguments

:: (Pitch.Note -> Maybe Pitch.Pitch)

Parse pitch function, as returned by get_pitch_functions. It's passed separately to avoid the overhead of calling get_pitch_functions multiple times.

-> RealTime.RealTime 
-> Deriver Pitch.Pitch 

Get the symbolic version of the transposed pitch. Since it's transposed, if you turn it back to a BaseTypes.Pitch, you should use with_transposed_pitch.

with_dynamic :: Signal.Y -> Deriver a -> Deriver a Source #

Replace the dynamic with the given one.

environ

parsing pitches

get_pitch_functions :: Deriver (Pitch.Note -> Maybe Pitch.Pitch, Pitch.Pitch -> Maybe Pitch.Note, Transposition -> Pitch.Step -> Pitch.Pitch -> Maybe Pitch.Pitch) Source #

Get symbolic pitch manipulating functions for the current scale. This is for calls that want to work with symbolic pitches.

note

eval_pitch :: (Pitch.Pitch -> Maybe Pitch.Note) -> ScoreTime.ScoreTime -> Pitch.Pitch -> Deriver BaseTypes.Transposed Source #

Evaluate a Pitch.Pitch. It returns a transposed pitch since a Pitch.Pitch is assumed to have been transposed (e.g. get_parsed_pitch uses a transposed pitch so range calculation works).

eval_note :: ScoreTime.ScoreTime -> Pitch.Note -> Deriver BaseTypes.Transposed Source #

Evaluate a symbolic pitch. Like eval_pitch, I assume the Note was Transposed, or at least should be an absolute pitch.

note :: NoteDeriver Source #

Generate a single note, from 0 to 1.

reapply_note :: NoteArgs -> NoteDeriver Source #

Like note, but the note reuses the Context, which means it will inherit the caller's start and duration as well as sub-tracks and thus may apply inversion.

This is appropriate when adding a wrapper around the default note call, but not if you don't want to be overridden by sub-tracks. See placed_note if you want to inherit the time, but not the rest.

pitched_note :: BaseTypes.Pitch -> NoteDeriver Source #

Override the pitch signal and generate a single note.

attribute_note :: Attrs.Attributes -> NoteDeriver Source #

Add an attribute and generate a single note.

transformer notes

with_attributes :: (Attrs.Attributes -> Attrs.Attributes) -> Deriver d -> Deriver d Source #

Derive with transformed Attributes.

random

class Random a where Source #

Get an infinite list of random numbers. These are deterministic in that they depend only on the random seed, but the random seed is hashed with each stack entry. So if you fix the random seed at a certain point, you should get consistent results below it.

It's a class because both Doubles and Ints are useful and I'd like to use the same function name for both.

Minimal complete definition

randoms, randoms_in

Methods

randoms :: Deriver [a] Source #

Infinite list of random numbers. These are deterministic in that they depend on the current track, current call position, and the random seed.

randoms_in :: a -> a -> Deriver [a] Source #

Infinite list of random numbers in the given range.

random_in :: (Random a, Real a) => a -> a -> Deriver a Source #

chance :: Double -> Deriver Bool Source #

If the chance is 1, return true all the time, if it's 0.5, return it half of the time.

shuffle :: [a] -> Deriver [a] Source #

pick :: NonEmpty a -> Double -> a Source #

Like pick_weighted when all the weights are equal.

time

real_duration :: (Internal.Time t1, Internal.Time t2) => t1 -> t2 -> Deriver RealTime.RealTime Source #

Get the real duration of time val at the given point in time. RealTime is linear, so 1 second is always 1 second no matter where it is, but ScoreTime will map to different amounts of RealTime depending on where it is.

score_duration :: (Internal.Time t1, Internal.Time t2) => t1 -> t2 -> Deriver ScoreTime.ScoreTime Source #

Like real_duration, but get the duration in ScoreTime. If you are manipulating deriver abstractly instead of directly emitting events then you will place them via Internal.at and family, which are in ScoreTime.

duration_from_start Source #

Arguments

:: Internal.Time t 
=> PassedArgs d 
-> t 
-> Deriver (RealTime.RealTime, RealTime.RealTime)

(start, start+dur)

A time range from the event start until a given duration.

duration_from_end Source #

Arguments

:: Internal.Time t 
=> PassedArgs d 
-> t 
-> Deriver (RealTime.RealTime, RealTime.RealTime)

(end-dur, end)

Like duration_from_start, but subtract a duration from the end.

timestep

timestep Source #

Arguments

:: ScoreTime.ScoreTime 
-> TimeStep.TimeStep 
-> [Int]

pick the first steps that return Just

-> Deriver ScoreTime.ScoreTime 

Take the given number of steps. Negative means step back.

meter_duration :: ScoreTime.ScoreTime -> Meter.RankName -> Double -> Deriver ScoreTime.ScoreTime Source #

Get the timestep duration from the given point. This tries first to step forward, and then back. This is because typically you use this to configure duration for a call, and it's confusing when the call stops working at the end of the block.

general purpose types