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

Safe HaskellNone

Derive.Slice

Description

Slicing is chopping the block horizontally, so that the horizontal chunks can act like their own little blocks.

For the sake of convenient notation, this is done in several places.

  1. A note with subtracks will slice out the subevents within its range. This allows a note to take another note (or notes) as arguments, e.g. a tuplet. This is what slice_notes is for.
  2. A note with controls as subtracks can invert itself so it has control over the evaluation of the controls. Documented further in Derive.Call.Note.
  3. #1 above is a convenient way to apply a transformation to multiple notes: group the tracks under another, and put the transformations in the parent. However, notes that have no transformation (aka orphans) must be extracted from underneath the empty parent, otherwise they will not be evaluated at all. This is done by derive_note_track.

This is a nasty tricky bit of work, but is depended on by all the high level notation, e.g. calls that can manipulate the results of other calls, aka parent calls. I'd still love to figure out a better way to do it though!

Synopsis

Documentation

data InsertEvent Source #

Ask slice to synthesize a note track and insert it at the leaves of the sliced tree.

Constructors

InsertEvent 

Fields

  • event_duration :: !ScoreTime
     
  • event_orientation :: !Event.Orientation

    A Negative orientation means that the controls at the Event.end time are not trimmed off.

  • event_around :: !([Event.Event], [Event.Event])
     
  • event_track_id :: !(Maybe TrackId)

    The TrackId for the track created for this event. This is required so it can collect a TrackDynamic and when the Cmd level looks at at track with inverted note calls, it sees the environ established by the tracks that the calls are inverted beneath. E.g., if the pitch track sets a scale, the Cmd layer should see the note track as having that scale.

slice Source #

Arguments

:: Bool

Omit events than begin at the start. slice_notes documents why this is necessary.

-> ScoreTime 
-> ScoreTime 
-> Maybe InsertEvent

If given, insert an event at the bottom with the given text and dur. The created track will have the given track_range, so it can create a Stack.Region entry.

-> TrackTree.EventsNode 
-> TrackTree.EventsNode 

Slice a track between start and end, and optionally put a note track with a single event of given string at the bottom. Sliced control tracks usually get events beyond the slice boundaries for context.

checked_slice_notes Source #

Arguments

:: Bool

TODO change this to Event.Orientation?

-> ScoreTime 
-> ScoreTime 
-> TrackTree.EventsTree 
-> Either Text [[Note]] 

This is slice_notes, but throw an error if find_overlapping complains.

TODO I think I don't want to allow sub-events larger than their slice, but currently I do. Actually I think overlap checking needs an overhaul in general.

slice_orphans :: Bool -> ScoreTime -> ScoreTime -> [TrackTree.EventsNode] -> Either Text [TrackTree.EventsNode] Source #

This is a variant of slice used by note track evaluation to derive orphan events.

strip_empty_tracks :: TrackTree.EventsNode -> [TrackTree.EventsNode] Source #

If a branch has no note track children with events, there's no way it can produce any events, so it can be dropped before derivation.

The branch has to have no notes from top to bottom, because any note in the middle could invert below.

slice_notes Source #

Arguments

:: Bool

include a note at the end

-> ScoreTime 
-> ScoreTime 
-> TrackTree.EventsTree 
-> [[Note]]

One [Note] per sub note track, in right to left order.

Expect a note track somewhere in the tree. Slice the tracks above and below it to each of its events.

The shift of each Event will be subtracted from the track events, so they start at 0. Control tracks caught in the middle are extended one event on either edge of the slice boundary courtesy of the slice function. Note that there will be control events at negative ScoreTime if they lie before the note.

Technically the children of the note track don't need to be sliced, since if it is inverting it will do that anyway. But slicing lets me shift fewer events, so it's probably a good idea anyway.