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

Derive.Call.Sub

Description

This is the basic interface for slicing. This also includes inverting, which is a special case of slicing.

Synopsis

inversion

under_invert :: (NoteArgs -> NoteDeriver -> NoteDeriver) -> NoteArgs -> NoteDeriver -> NoteDeriver Source #

Cause this transformer to apply only after inversion. under_invert documents this, also see NOTE [under-invert].

Normally when a call is inverted, the transformers run outside the inversion, while only the generator runs underneath. However, some transformers rely on per-note controls, such as pitch and dyn, and therefore need to go under the invert. So this saves the transformer, and applies it only after all the inversion has happened.

If there are no sub-tracks, then inversion won't happen, and the transform is run right here. However, if there are sub-tracks, but the generator doesn't want to run, then the transform will be lost.

TODO I could probably fix it by making Eval.eval_generator apply the transform, but it would have to clear it out too to avoid evaluating more than once. Not sure which way is right.

inverting :: (PassedArgs d -> NoteDeriver) -> PassedArgs d -> NoteDeriver Source #

Convert a call into an inverting call. This is designed to be convenient to insert after the signature arg in a call definition. The args passed to the call have been stripped of their sub tracks to avoid another inversion.

inverting_args :: PassedArgs d -> (PassedArgs d -> NoteDeriver) -> NoteDeriver Source #

inverting with its arguments flipped. This is useful for calls that want to do stuff with the args before inverting. Make sure to shadow the old PassedArgs with the ones passed to the call, for the reason documented in inverting.

events

sub_events :: PassedArgs d -> Deriver [[SubT.Event]] Source #

Get the Events of subtracks, if any, returning one list of events per sub note track. This is the top-level utility for note calls that take other note calls as arguments.

sub_events_negative :: PassedArgs d -> Deriver [[SubT.Event]] Source #

Like sub_events, but exclude events at the start time, and include events at the end time. Presumably suitable for Negative calls.

sub_tracks :: PassedArgs d -> Deriver [SubT.Track] Source #

TODO maybe this should replace sub_events

assert_no_subs :: PassedArgs d -> Deriver () Source #

Throw an exception if there are sub-events.

modify_notes :: ([SubT.EventT Text] -> Either Text [SubT.EventT Text]) -> PassedArgs a -> Either Text (PassedArgs a) Source #

Modify the text of sub note tracks before deriving them. This can be used to implement an ad-hoc new language.

derive :: [SubT.Event] -> NoteDeriver Source #

Derive and merge Events.

derive_pitch :: SubT.Event -> Deriver (SubT.EventT (Maybe Pitch.Note)) Source #

Get the pitch of an Event. Useful for debugging.

fit Source #

Arguments

:: (ScoreTime, ScoreTime)

fit this range

-> (ScoreTime, ScoreTime)

into this range

-> [SubT.Event] 
-> NoteDeriver 

Re-fit the events from one range to another.

RestEvent

type RestEvent = SubT.EventT (Maybe NoteDeriver) Source #

A Nothing represents a rest.

sub_rest_events Source #

Arguments

:: Bool

end bias

-> Bool

if True, include the trailing gap as a rest

-> PassedArgs d 
-> Deriver [[RestEvent]] 

This is like sub_events, but gaps between the events are returned as explicit rests.

reapply

reapply :: Context Score.Event -> DeriveT.Expr -> [[SubT.Event]] -> NoteDeriver Source #

Call a note parent with sub-events. While you can easily call other kinds of calls with Eval.reapply, note parents are more tricky because they expect a track structure in ctx_sub_tracks. This bypasses that and directly passes SubT.EventTs to the note parent, courtesy of ctx_sub_events.