Karya, built on 2020-11-26T21:03:17 (patch 23b5be2d53a9e8e7d6136cda5aae2849abe5cded)

Derive.Args

Description

Extract things from the PassedArgs data structure.

Synopsis

# prev and next

## from ctx_prev_val

Polymorphic version of prev_control or prev_pitch.

Get the previous val. See NOTE [prev-val].

## from state_prev_val

Get the previous note. Unlike prev_val, this always gets the previous Score.Event, even if you're evaluating a control track under the note track.

TODO it doesn't really belong here since it doesn't use PassedArgs, but this is where I would look for a function for the previous value.

## state_pitch_map

Pitch at the time of the next event in this track.

Pitch at the time of the next note event of this track's state_note_track.

Get a logical pitch at the given time, via state_pitch_map. As documented by state_pitch_map, the pitch map is unset while evaluating the pitch map, so pitch calls that use this shouldn't be surprised if it's Nothing.

Like lookup_pitch_at, except for parsed pitches. Normally you'd pass get_pitch_functions to make a Pitch.Pitch.

## eval

eval :: CallableExpr d => Context x -> Event.Event -> [Event.Event] -> Deriver (Stream.Stream d) Source #

Unused, but might be used again if I need to evaluate the next event.

Get the pitch at the time of the next event, when evaluating a pitch track. Since the pitch hasn't been evaluated yet, it has to be evaluated here. So if it depends on the previous pitch, you won't get a pitch back.

Actually, the pitch likely *has* been evaluated, I just can't get at it here. If it's uninverted then I have the whole pitch track, and if it's inverted then the event at or after the end of the event will be included. But trim_signal will clip that sample off to avoid a spurious pitch change at the end of the note.

# event timing

The start of the next event, or the end of the block if there is no next event.

Used by calls to determine their extent, especially control calls, which have no explicit duration.

End of the next event, or the end of the block if there is no next event.

Get the start of the next event, if there is one.

This is similar to next, except that it will be Nothing at the end of the block.

Start time of the previous event.

End time of the previous event.

## modify

Modify the duration of the ctx_event. This is a hack, because calls run in TrackTime, instead of using Derive.place.

## range

range :: PassedArgs a -> (TrackTime, TrackTime) Source #

Range of the called event, i.e. (min, max). Note that range is the minimum to maximum, which is not the same as the start and end if the event has negative duration.

Like range, but if the duration is 0, then the end is next event.

The current event's start and end times.

If the event has a duration, then use that. Otherwise, if there is a EnvKey.note_end, return that. Otherwise, return next. However, if there's an EnvKey.note_start and it's past the event start, then this event isn't contained within the range of its parent note, which means that its expected note end has also passed. In that case, it returns (note_start, note_start), which should cause the call to just emit its final sample at the note-start, which will both get the correct value for the event and not destroy the earlier track signal fragment.

Start and duration of the event. This is probably the right thing for calls that generate a note since it will give a negative duration when appropriate.

Event range as it appears on the track, regardless of slicing.

normalized :: PassedArgs a -> Deriver b -> Deriver b Source #

This normalizes a deriver to start at 0 and have a duration of 1, provided that the deriver is placed at the start and dur of the given args. This is the case if the deriver is a transformer arg, so this is useful for a transformer to manipulate its argument.

Like normalized, but only shifts start to 0.