Safe Haskell | Safe-Inferred |
---|
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
- transposed :: RealTime.RealTime -> Deriver (Maybe DeriveT.Transposed)
- get_transposed :: RealTime.RealTime -> Deriver DeriveT.Transposed
- get_pitch :: RealTime.RealTime -> Deriver DeriveT.Pitch
- get_pitch_here :: PassedArgs a -> Deriver DeriveT.Pitch
- get_parsed_pitch :: (Pitch.Note -> Maybe Pitch.Pitch) -> RealTime.RealTime -> Deriver Pitch.Pitch
- get_symbolic_pitch :: RealTime.RealTime -> Deriver Pitch.Note
- dynamic :: RealTime.RealTime -> Deriver Signal.Y
- with_pitch :: DeriveT.Pitch -> Deriver a -> Deriver a
- with_transposed_pitch :: DeriveT.Transposed -> Deriver a -> Deriver a
- without_transpose :: Deriver a -> Deriver a
- with_symbolic_pitch :: DeriveT.PitchCall -> ScoreTime.ScoreTime -> Deriver a -> Deriver a
- with_dynamic :: Signal.Y -> Deriver a -> Deriver a
- multiply_dynamic :: Signal.Y -> Deriver a -> Deriver a
- with_constant :: ScoreT.Control -> Signal.Y -> Deriver a -> Deriver a
- add_control :: ScoreT.Control -> ScoreT.Typed Signal.Control -> Deriver a -> Deriver a
- multiply_control :: ScoreT.Control -> ScoreT.Typed Signal.Control -> Deriver a -> Deriver a
- add_constant :: ScoreT.Control -> Signal.Y -> Deriver a -> Deriver a
- multiply_constant :: ScoreT.Control -> Signal.Y -> Deriver a -> Deriver a
- get_srate :: Deriver RealTime.RealTime
- get_scale :: Deriver Scale
- lookup_scale :: Deriver (Maybe Scale)
- get_scale_id :: Deriver Pitch.ScaleId
- lookup_key :: Deriver (Maybe Pitch.Key)
- get_instrument :: Deriver ScoreT.Instrument
- lookup_instrument :: Deriver (Maybe ScoreT.Instrument)
- get_attributes :: Deriver Attrs.Attributes
- get_pitch_functions :: Deriver (Pitch.Note -> Maybe Pitch.Pitch, Pitch.Pitch -> Maybe Pitch.Note, Transposition -> Pitch.Step -> Pitch.Pitch -> Maybe Pitch.Pitch)
- parse_pitch :: (Pitch.Note -> Maybe a) -> DeriveT.Transposed -> Deriver a
- nn_difference :: RealTime.RealTime -> DeriveT.Pitch -> DeriveT.Pitch -> Deriver Pitch.NoteNumber
- eval_pitch_ :: ScoreTime.ScoreTime -> Pitch.Pitch -> Deriver DeriveT.Transposed
- eval_pitch :: (Pitch.Pitch -> Maybe Pitch.Note) -> ScoreTime.ScoreTime -> Pitch.Pitch -> Deriver DeriveT.Transposed
- eval_note :: ScoreTime.ScoreTime -> Pitch.Note -> Deriver DeriveT.Transposed
- note :: NoteDeriver
- reapply_note :: NoteArgs -> NoteDeriver
- pitched_note :: DeriveT.Pitch -> NoteDeriver
- transposed_pitched_note :: DeriveT.Transposed -> NoteDeriver
- attribute_note :: Attrs.Attributes -> NoteDeriver
- triggered_note :: NoteDeriver
- place :: PassedArgs d -> Deriver a -> Deriver a
- placed_note :: PassedArgs d -> NoteDeriver
- with_attributes :: (Attrs.Attributes -> Attrs.Attributes) -> Deriver d -> Deriver d
- add_attributes :: Attrs.Attributes -> Deriver d -> Deriver d
- add_flags :: Flags.Flags -> NoteDeriver -> NoteDeriver
- class Random a where
- randoms :: Deriver [a]
- randoms_in :: a -> a -> Deriver [a]
- random :: Random a => Deriver a
- random_in :: (Random a, Real a) => a -> a -> Deriver a
- chance :: Double -> Deriver Bool
- shuffle :: [a] -> Deriver [a]
- _make_randoms :: (PureMT -> (a, PureMT)) -> Deriver [a]
- _random_generator :: Deriver PureMT
- pick_weighted :: NonEmpty (Double, a) -> Double -> a
- pick :: NonEmpty a -> Double -> a
- normal :: Double -> Deriver Double
- make_normal :: Double -> [Double] -> Double
- if_env :: (Eq val, Typecheck.Typecheck val) => EnvKey.Key -> Maybe val -> Deriver a -> Deriver a -> Deriver a
- when_env :: (Eq val, Typecheck.Typecheck val) => EnvKey.Key -> Maybe val -> (Deriver a -> Deriver a) -> Deriver a -> Deriver a
- real_duration :: (Internal.Time t1, Internal.Time t2) => t1 -> t2 -> Deriver RealTime.RealTime
- score_duration :: (Internal.Time t1, Internal.Time t2) => t1 -> t2 -> Deriver ScoreTime.ScoreTime
- duration_from_start :: Internal.Time t => PassedArgs d -> t -> Deriver (RealTime.RealTime, RealTime.RealTime)
- duration_from_end :: Internal.Time t => PassedArgs d -> t -> Deriver (RealTime.RealTime, RealTime.RealTime)
- typed_real_duration :: Internal.Time t => ScoreT.TimeT -> t -> ScoreT.Typed Signal.Y -> Deriver RealTime.RealTime
- real_duration_at :: ScoreT.TypedFunction -> RealTime.RealTime -> Deriver RealTime.RealTime
- timestep :: ScoreTime.ScoreTime -> TimeStep.TimeStep -> [Int] -> Deriver ScoreTime.ScoreTime
- meter_duration :: ScoreTime.ScoreTime -> Meter.Rank -> Int -> Deriver ScoreTime.ScoreTime
- timestep_duration :: PassedArgs a -> Meter.Rank -> Deriver ScoreTime.ScoreTime
- data UpDown
- invert :: UpDown -> UpDown
- data Hand
- other_hand :: Hand -> Hand
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_pitch_here :: PassedArgs a -> Deriver DeriveT.Pitch Source #
:: (Pitch.Note -> Maybe Pitch.Pitch) | Parse pitch function, as returned by |
-> 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_pitch :: DeriveT.Pitch -> Deriver a -> Deriver a Source #
with_transposed_pitch :: DeriveT.Transposed -> Deriver a -> Deriver a Source #
without_transpose :: Deriver a -> Deriver a Source #
with_symbolic_pitch :: DeriveT.PitchCall -> ScoreTime.ScoreTime -> Deriver a -> Deriver a Source #
with_constant :: ScoreT.Control -> Signal.Y -> Deriver a -> Deriver a Source #
add_control :: ScoreT.Control -> ScoreT.Typed Signal.Control -> Deriver a -> Deriver a Source #
multiply_control :: ScoreT.Control -> ScoreT.Typed Signal.Control -> Deriver a -> Deriver a Source #
add_constant :: ScoreT.Control -> Signal.Y -> Deriver a -> Deriver a Source #
multiply_constant :: ScoreT.Control -> Signal.Y -> Deriver a -> Deriver a Source #
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.
parse_pitch :: (Pitch.Note -> Maybe a) -> DeriveT.Transposed -> Deriver a Source #
nn_difference :: RealTime.RealTime -> DeriveT.Pitch -> DeriveT.Pitch -> Deriver Pitch.NoteNumber Source #
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.
triggered_note :: NoteDeriver Source #
A zero-duration note
.
placed_note :: PassedArgs d -> NoteDeriver Source #
transformer notes
with_attributes :: (Attrs.Attributes -> Attrs.Attributes) -> Deriver d -> Deriver d Source #
Derive with transformed Attributes.
add_attributes :: Attrs.Attributes -> Deriver d -> Deriver d Source #
add_flags :: Flags.Flags -> NoteDeriver -> NoteDeriver Source #
random
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.
random :: Random a => Deriver a Source #
Get a random Double or Int. Ints will lose precision if converted to double!
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.
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.
:: 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.
:: 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.
typed_real_duration :: Internal.Time t => ScoreT.TimeT -> t -> ScoreT.Typed Signal.Y -> Deriver RealTime.RealTime Source #
This is real_duration
, but takes a ScoreT.Typed Signal.Y.
timestep
:: 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
This is for arguments which can be high or low.
Instances
Bounded UpDown Source # | |
Enum UpDown Source # | |
Defined in Derive.Call | |
Show UpDown Source # | |
Eq UpDown Source # | |
Ord UpDown Source # | |
ShowVal.ShowVal UpDown Source # | |
Typecheck.ToVal UpDown Source # | |
Defined in Derive.Call to_val :: UpDown -> DeriveT.Val Source # | |
Typecheck.Typecheck UpDown Source # | |
Defined in Derive.Call | |
Pretty UpDown Source # | |
Instances
other_hand :: Hand -> Hand Source #