Safe Haskell | Safe-Inferred |
---|
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
- data Range
- selection_range :: Sel.Selection -> Range
- event_range :: Event.Event -> Range
- range_times :: Range -> (TrackTime, TrackTime)
- range_start :: Range -> TrackTime
- range_end :: Range -> TrackTime
- range_duration :: Range -> TrackTime
- data Events
- empty :: Events
- null :: Events -> Bool
- length :: Events -> Int
- time_begin :: Events -> ScoreTime
- time_end :: Events -> ScoreTime
- singleton :: Event.Event -> Events
- from_list :: [Event.Event] -> Events
- ascending :: Events -> [Event.Event]
- descending :: Events -> [Event.Event]
- map_events :: (Event.Event -> Event.Event) -> Events -> Events
- move :: ScoreTime -> Events -> Events
- clip :: Bool -> ScoreTime -> Events -> Events
- clip_list :: Bool -> ScoreTime -> [Event.Event] -> [Event.Event]
- insert :: [Event.Event] -> Events -> Events
- remove :: Range -> Events -> Events
- merge :: Events -> Events -> Events
- at :: ScoreTime -> Types.Orientation -> Events -> Maybe Event.Event
- overlapping :: ScoreTime -> Events -> Maybe Event.Event
- head :: Events -> Maybe Event.Event
- last :: Events -> Maybe Event.Event
- split_range :: Range -> Events -> (Events, Events, Events)
- split :: ScoreTime -> Events -> (Events, Events)
- split_exclude :: ScoreTime -> Events -> (Events, Events)
- in_range :: Range -> Events -> Events
- around :: ScoreTime -> ScoreTime -> Events -> Events
- split_lists :: ScoreTime -> Events -> ([Event.Event], [Event.Event])
- at_after :: ScoreTime -> Events -> [Event.Event]
- after :: ScoreTime -> Events -> [Event.Event]
- before :: ScoreTime -> Events -> [Event.Event]
- at_before :: ScoreTime -> Events -> [Event.Event]
- split_at_before :: ScoreTime -> Events -> ([Event.Event], [Event.Event])
range
Range !TrackTime !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. Start should be <= end. |
Point !TrackTime !Types.Orientation | Select an event at exactly the given time and orientation. |
selection_range :: Sel.Selection -> Range Source #
event_range :: Event.Event -> Range Source #
range_start :: Range -> TrackTime Source #
range_duration :: Range -> TrackTime Source #
events
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.
time_begin :: Events -> ScoreTime Source #
list conversion
singleton :: Event.Event -> Events Source #
from_list :: [Event.Event] -> Events Source #
ascending :: Events -> [Event.Event] Source #
Get all events in ascending order.
descending :: Events -> [Event.Event] Source #
transformation
map_events :: (Event.Event -> Event.Event) -> Events -> Events Source #
Map a function across the events in Events.
move :: ScoreTime -> Events -> Events Source #
Move events by a constant amount. It's more efficient than map_events
because it doesn't have to sort and clip the events.
clip :: Bool -> ScoreTime -> Events -> Events Source #
Clip off the events after the given end time. Also shorten the last event so it doesn't cross the end, if necessary.
clip_list :: Bool -> ScoreTime -> [Event.Event] -> [Event.Event] Source #
Like clip
, but works on a list.
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.
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 -> Types.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 -> Events -> Maybe Event.Event Source #
Like at
, but return an event that overlaps the given pos.
split
events
split :: ScoreTime -> Events -> (Events, Events) Source #
Split at the given time. A positive event that starts at the given time will appear in the after events, a negative event in the previous events.
split_exclude :: ScoreTime -> Events -> (Events, Events) Source #
Like split
, but a positive event that matches exactly is excluded from
the result.
around :: 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]
split_lists :: ScoreTime -> Events -> ([Event.Event], [Event.Event]) Source #
split_at_before :: 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.