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

Cmd.ModifyEvents

Description

Utilities to modify events in tracks.

Synopsis

Documentation

type Tracks m = BlockId -> [(TrackId, [Event.Event])] -> m [(TrackId, [Event.Event])] Source #

Map a function over multiple tracks. It has access to all selected events. Omit a TrackId from the output to leave it unchanged.

type Track m = BlockId -> TrackId -> [Event.Event] -> m (Maybe [Event.Event]) Source #

Map a function over events on a certain track. Returning Nothing will leave the track unchanged.

track :: Monad m => Track m -> Tracks m Source #

Map a Track transformer over multiple tracks.

events :: Monad m => ([Event.Event] -> m [Event.Event]) -> Track m Source #

Map a function over a set of events.

event :: Monad m => (Event.Event -> Event.Event) -> Track m Source #

Map a function over a single event.

text :: Monad m => (Text -> Text) -> Track m Source #

pipeline :: ([[Text]] -> [[Text]]) -> Text -> Text Source #

Split up a pipeline and lex the calls.

failable_text :: Cmd.M m => (Text -> Either.Either Text Text) -> Track m Source #

Take a text transformation that can fail to a Track transformation that transforms all the events and throws if any of the text transformations failed.

modify selections

selection :: Cmd.M m => Track m -> m () Source #

Map a function over the selected events, as per Selection.events.

selection_visible :: Cmd.M m => Track m -> m () Source #

Like selection, but don't apply to collapsed tracks. This is appropriate for operations that often apply to note tracks. If you select multiple note tracks, then the intervening collapsed pitch tracks will also be selected and if you accidentally modify those you won't see the modifications.

selected_track :: Cmd.M m => Track m -> m () Source #

Like selection, but only operate on the point_track.

data Collapsed Source #

Instances

Instances details
Show Collapsed Source # 
Instance details

Defined in Cmd.ModifyEvents

Eq Collapsed Source # 
Instance details

Defined in Cmd.ModifyEvents

advance_if_point :: Cmd.M m => m () Source #

Advance the selection if it was a point. This is convenient for applying a transformation repeatedly.

overlapping :: Cmd.M m => Track m -> m () Source #

Map a function over the events that overlap the selection point.

tracks_named :: Cmd.M m => (Text -> Bool) -> Track m -> Track m Source #

Map over tracks whose name matches the predicate.

selected_note :: Cmd.M m => Track m -> m () Source #

selected_control :: Cmd.M m => Track m -> m () Source #

selected_pitch :: Cmd.M m => Track m -> m () Source #

block tracks

block :: Cmd.M m => BlockId -> Track m -> m () Source #

Like selection, but maps over an entire block.

all_blocks :: Cmd.M m => Track m -> m () Source #

all_tracks_named :: Cmd.M m => (Text -> Bool) -> Track m -> m () Source #

note_tracks :: Cmd.M m => Track m -> m () Source #

control_tracks :: Cmd.M m => Track m -> m () Source #

pitch_tracks :: Cmd.M m => Track m -> m () Source #

misc

move_track_events :: Ui.M m => ScoreTime -> ScoreTime -> ScoreTime -> TrackId -> m () Source #

Move everything at or after start by shift.

move_events Source #

Arguments

:: ScoreTime

events past the block end are shortened or removed

-> ScoreTime 
-> ScoreTime 
-> Events.Events 
-> Events.Events 

All events starting at and after a point to the end are shifted by the given amount.

replace tokens

data Replacement Source #

Constructors

RLiteral !Text

literal text

F !Int

field from match

Instances

Instances details
String.IsString Replacement Source # 
Instance details

Defined in Cmd.ModifyEvents

Show Replacement Source # 
Instance details

Defined in Cmd.ModifyEvents

Eq Replacement Source # 
Instance details

Defined in Cmd.ModifyEvents

substitute :: Parser -> [Replacement] -> Text -> Either.Either Text Text Source #

Regex-like substitution on tracklang tokens.

Short names and IsString instances attempt to make it concise enough for inline use. If the pattern doesn't match, the input is returned unchanged.

parser

newtype Parser Source #

Yet another "list of successes" style parser.

Constructors

Parser ([Token] -> [([Match], [Token])]) 

Instances

Instances details
String.IsString Parser Source # 
Instance details

Defined in Cmd.ModifyEvents

Monoid Parser Source # 
Instance details

Defined in Cmd.ModifyEvents

Semigroup Parser Source # 
Instance details

Defined in Cmd.ModifyEvents

type Match = [Token] Source #

parse :: Parser -> [Token] -> [[Match]] Source #

literal :: Text -> Parser Source #

Match a literal token.

w :: Parser Source #

Match one token.

ws :: Parser Source #

Match 0 or more tokens.

ws1 :: Parser Source #

Match 1 or more tokens.

splits :: [a] -> [([a], [a])] Source #