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

Derive.Call

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

dynamic

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

Unlike pitch_at, the transposition has already been applied.

get_pitch :: RealTime.RealTime -> Deriver DeriveT.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 DeriveT.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 DeriveT.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 DeriveT.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 :: DeriveT.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.

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.

Instances

Instances details
Random Double Source # 
Instance details

Defined in Derive.Call

Random Int Source # 
Instance details

Defined in Derive.Call

random :: Random a => Deriver a Source #

Get a random Double or Int. Ints will lose precision if converted to double!

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.

make_normal :: Double -> [Double] -> Double Source #

Approximation to a normal distribution between 0 and 1, inclusive. I can't use an actual normal distribution because I need it to be bounded.

conditional

if_env :: (Eq val, Typecheck.Typecheck val) => EnvKey.Key -> Maybe val -> Deriver a -> Deriver a -> Deriver a Source #

when_env :: (Eq val, Typecheck.Typecheck val) => EnvKey.Key -> Maybe val -> (Deriver a -> Deriver a) -> Deriver a -> Deriver a Source #

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

timestep_duration :: PassedArgs a -> Meter.Rank -> Deriver ScoreTime.ScoreTime Source #

Duration of a single timestep, starting here.

general purpose types

data UpDown Source #

This is for arguments which can be high or low.

Constructors

Up 
Down 

Instances

Instances details
Bounded UpDown Source # 
Instance details

Defined in Derive.Call

Enum UpDown Source # 
Instance details

Defined in Derive.Call

Show UpDown Source # 
Instance details

Defined in Derive.Call

Eq UpDown Source # 
Instance details

Defined in Derive.Call

Methods

(==) :: UpDown -> UpDown -> Bool #

(/=) :: UpDown -> UpDown -> Bool #

Ord UpDown Source # 
Instance details

Defined in Derive.Call

ShowVal.ShowVal UpDown Source # 
Instance details

Defined in Derive.Call

Methods

show_val :: UpDown -> Text Source #

Typecheck.ToVal UpDown Source # 
Instance details

Defined in Derive.Call

Typecheck.Typecheck UpDown Source # 
Instance details

Defined in Derive.Call

Pretty UpDown Source # 
Instance details

Defined in Derive.Call

data Hand Source #

Constructors

L 
R 

Instances

Instances details
Bounded Hand Source # 
Instance details

Defined in Derive.Call

Enum Hand Source # 
Instance details

Defined in Derive.Call

Methods

succ :: Hand -> Hand #

pred :: Hand -> Hand #

toEnum :: Int -> Hand #

fromEnum :: Hand -> Int #

enumFrom :: Hand -> [Hand] #

enumFromThen :: Hand -> Hand -> [Hand] #

enumFromTo :: Hand -> Hand -> [Hand] #

enumFromThenTo :: Hand -> Hand -> Hand -> [Hand] #

Show Hand Source # 
Instance details

Defined in Derive.Call

Methods

showsPrec :: Int -> Hand -> ShowS #

show :: Hand -> String #

showList :: [Hand] -> ShowS #

Eq Hand Source # 
Instance details

Defined in Derive.Call

Methods

(==) :: Hand -> Hand -> Bool #

(/=) :: Hand -> Hand -> Bool #

Ord Hand Source # 
Instance details

Defined in Derive.Call

Methods

compare :: Hand -> Hand -> Ordering #

(<) :: Hand -> Hand -> Bool #

(<=) :: Hand -> Hand -> Bool #

(>) :: Hand -> Hand -> Bool #

(>=) :: Hand -> Hand -> Bool #

max :: Hand -> Hand -> Hand #

min :: Hand -> Hand -> Hand #

ShowVal.ShowVal Hand Source # 
Instance details

Defined in Derive.Call

Methods

show_val :: Hand -> Text Source #

Typecheck.ToVal Hand Source # 
Instance details

Defined in Derive.Call

Typecheck.Typecheck Hand Source # 
Instance details

Defined in Derive.Call

Pretty Hand Source # 
Instance details

Defined in Derive.Call