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

Safe HaskellNone

Ui.Events

Contents

Description

The Events type contains the events of a track.

This is the largest part of the score and also the part most often modified, so there is a plethora of access functions.

Synopsis

range

data Range Source #

Constructors

Range !ScoreTime.TrackTime !ScoreTime.TrackTime

A range between the given points. It will select a positive event at the start time, or a negative one at the end time. Effectively it's half-open from the start for Positive events, and half-open from the end for Negative ones.

Point !ScoreTime.TrackTime !Event.Orientation

Select an event at exactly the given time and orientation.

Instances

events

newtype Events Source #

This is the underlying storage for a sequence of events. The invariant is that events start + duration don't overlap.

This type should remain abstract, and you should manipulate events using functions in this module.

Constructors

Events EventMap 

list conversion

ascending :: Events -> [Event.Event] Source #

Get all events in ascending order.

transformation

map_events :: (Event.Event -> Event.Event) -> Events -> Events Source #

Map a function across the events in Events.

clip :: Bool -> ScoreTime.ScoreTime -> [Event.Event] -> [Event.Event] Source #

Clip off the events after the given end time. Also shorten the last event so it doesn't cross the end, if necessary.

insert / remove

insert :: [Event.Event] -> Events -> Events Source #

Merge events into the given Events. Events that overlap will have their tails clipped until they don't, and given events that start at the same place as existing events will replace the existing ones.

This should be the the only way to create a Events, short of debugging, since it enforces that events don't overlap.

remove :: Range -> Events -> Events Source #

Remove events in the range.

merge :: Events -> Events -> Events Source #

Merge evts2 into evts1. Events that overlap other events will be clipped so they don't overlap. If events occur simultaneously, the event from evts1 wins.

lookup

at :: ScoreTime.ScoreTime -> Event.Orientation -> Events -> Maybe Event.Event Source #

An event exactly at the given pos, or Nothing. TODO this is just in_range (Point ...), merge them?

overlapping :: ScoreTime.ScoreTime -> Events -> Maybe Event.Event Source #

Like at, but return an event that overlaps the given pos.

last :: Events -> Maybe Event.Event Source #

Final event, if there is one.

split

events

split :: ScoreTime.ScoreTime -> Events -> (Events, Events) Source #

Split at the given time. A positive event that starts at the given time will appear in the above events, a negative event in the below events.

split_exclude :: ScoreTime.ScoreTime -> Events -> (Events, Events) Source #

Like split, but a positive event that matches exactly is excluded from the result.

in_range :: Range -> Events -> Events Source #

Like split_range, but only return the middle part.

around :: ScoreTime.ScoreTime -> ScoreTime.ScoreTime -> Events -> Events Source #

Get events in the given range, plus surrounding. If there is no event at start, the previous event will be included. The event after end is always included.

List [Event]

at_after :: ScoreTime.ScoreTime -> Events -> [Event.Event] Source #

Events whose start is at or after pos.

after :: ScoreTime.ScoreTime -> Events -> [Event.Event] Source #

Events whose start is strictly after pos.

before :: ScoreTime.ScoreTime -> Events -> [Event.Event] Source #

Events whose start before pos.

split_at_before :: ScoreTime.ScoreTime -> Events -> ([Event.Event], [Event.Event]) Source #

This is like split, but if there isn't an event exactly at the pos then put the previous one in the post list.

Range

data Range Source #

Constructors

Range !ScoreTime.TrackTime !ScoreTime.TrackTime

A range between the given points. It will select a positive event at the start time, or a negative one at the end time. Effectively it's half-open from the start for Positive events, and half-open from the end for Negative ones.

Point !ScoreTime.TrackTime !Event.Orientation

Select an event at exactly the given time and orientation.

Instances

events

list conversion

ascending :: Events -> [Event.Event] Source #

Get all events in ascending order.

transformation

map_events :: (Event.Event -> Event.Event) -> Events -> Events Source #

Map a function across the events in Events.

clip :: Bool -> ScoreTime.ScoreTime -> [Event.Event] -> [Event.Event] Source #

Clip off the events after the given end time. Also shorten the last event so it doesn't cross the end, if necessary.

insert / remove

insert :: [Event.Event] -> Events -> Events Source #

Merge events into the given Events. Events that overlap will have their tails clipped until they don't, and given events that start at the same place as existing events will replace the existing ones.

This should be the the only way to create a Events, short of debugging, since it enforces that events don't overlap.

round_event :: Event.Event -> Event.Event Source #

Round event times as described in ScoreTime.round.

remove :: Range -> Events -> Events Source #

Remove events in the range.

lookup

at :: ScoreTime.ScoreTime -> Event.Orientation -> Events -> Maybe Event.Event Source #

An event exactly at the given pos, or Nothing. TODO this is just in_range (Point ...), merge them?

overlapping :: ScoreTime.ScoreTime -> Events -> Maybe Event.Event Source #

Like at, but return an event that overlaps the given pos.

last :: Events -> Maybe Event.Event Source #

Final event, if there is one.

split

events

split :: ScoreTime.ScoreTime -> Events -> (Events, Events) Source #

Split at the given time. A positive event that starts at the given time will appear in the above events, a negative event in the below events.

split_exclude :: ScoreTime.ScoreTime -> Events -> (Events, Events) Source #

Like split, but a positive event that matches exactly is excluded from the result.

in_range :: Range -> Events -> Events Source #

Like split_range, but only return the middle part.

around :: ScoreTime.ScoreTime -> ScoreTime.ScoreTime -> Events -> Events Source #

Get events in the given range, plus surrounding. If there is no event at start, the previous event will be included. The event after end is always included.

List [Event]

at_after :: ScoreTime.ScoreTime -> Events -> [Event.Event] Source #

Events whose start is at or after pos.

after :: ScoreTime.ScoreTime -> Events -> [Event.Event] Source #

Events whose start is strictly after pos.

before :: ScoreTime.ScoreTime -> Events -> [Event.Event] Source #

Events whose start before pos.

split_at_before :: ScoreTime.ScoreTime -> Events -> ([Event.Event], [Event.Event]) Source #

This is like split, but if there isn't an event exactly at the pos then put the previous one in the post list.

implementation

newtype Events Source #

This is the underlying storage for a sequence of events. The invariant is that events start + duration don't overlap.

This type should remain abstract, and you should manipulate events using functions in this module.

Constructors

Events EventMap 

data Key Source #

This determines event order, and which events can coexist.

Technically, since Event.start is in here, it doesn't have to be in Event.Event. I used to have them separate, but it was a pain to pass (ScoreTime, Event) pairs around everywhere.

Instances

Eq Key # 

Methods

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

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

Ord Key # 

Methods

compare :: Key -> Key -> Ordering #

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

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

(>) :: Key -> Key -> Bool #

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

max :: Key -> Key -> Key #

min :: Key -> Key -> Key #

Read Key # 
Show Key # 

Methods

showsPrec :: Int -> Key -> ShowS #

show :: Key -> String #

showList :: [Key] -> ShowS #

DeepSeq.NFData Key # 

Methods

rnf :: Key -> () #

Pretty.Pretty Key # 
Serialize.Serialize Key # 

from_ascending :: [Event.Event] -> EventMap Source #

This assumes the input is already sorted!

_split_overlapping :: ScoreTime.ScoreTime -> ScoreTime.ScoreTime -> EventMap -> (EventMap, EventMap, EventMap) Source #

Put events that overlap the range into within.

merge :: Events -> Events -> Events Source #

Merge evts2 into evts1. Events that overlap other events will be clipped so they don't overlap. If events occur simultaneously, the event from evts1 wins.

clip_key :: (Bool, (Key, x)) -> (Key, Int) Source #

Order otherwise-equal events so that new ones will prevail over old ones. For positive events, the last event wins, for negative ones it's the first.

clip_events :: [Event.Event] -> [Event.Event] Source #

Clip overlapping event durations. An event with duration overlapping another event will be clipped. Positive events are clipped by following events, and negative ones are clipped by previous ones. In the event of a conflict between positive and negative, the positive one wins. If an event would be clip to <=0, it is dropped.

The precondition is that the input events are sorted by event_key, the postcondition is that they are still sorted and no [pos .. pos+dur) ranges will overlap.

serialize