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

Safe HaskellNone

Cmd.PitchTrack

Contents

Description

Cmds to edit a pitch track, which is a special kind of control track.

This module creates the pitches that are later parsed by Derive.Control.

Synopsis

entry

cmd_val_edit :: Cmd.M m => Msg.Msg -> m Cmd.Status Source #

Val edit turns Msg.InputNotes into the appropriate scale degree call for the scale in scope.

Like control tracks, ' will add a ' call, which repeats the last value. This is useful to extend a constant pitch value to the desired breakpoint.

cmd_method_edit :: Cmd.M m => Msg.Msg -> m Cmd.Status Source #

Method edit directs keystrokes to the (optional) call around the pitch call. Pitches by themselves simply set a constant pitch by default, but a call can create an interpolated curve, or a trill, or anything really.

cmd_record_note_status :: Cmd.M m => Msg.Msg -> m Cmd.Status Source #

Record the last note entered. Should be called by with_note.

implementation

type Modify = ControlTrack.Event -> (Maybe ControlTrack.Event, Bool) Source #

old_event -> (new_event, advance?)

modify :: (ControlTrack.Event -> ControlTrack.Event) -> Event.Event -> Event.Event Source #

Modify event text. This is not used within this module but is exported for others as a more general variant of modify_event_at.

parse :: Text -> ControlTrack.Event Source #

Like ControlTrack.parse, but complicated by the fact that pitch calls can take args.

"x"        -> Event { method = "", val = "x", args = "" }
"x "       -> Event { method = "x", val = "", args = "" }
"x y"      -> Event { method = "", val = "x y", args = "" }
"x (y)"    -> Event { method = "x", val = "(y)", args = "" }
"x (y) z"  -> Event { method = "x", val = "(y)", args = "z" }

unparse :: ControlTrack.Event -> Text Source #

This is a bit more complicated than ControlTrack.unparse, since it needs to add or strip parens.

modify_note :: (Pitch.Note -> Either Text Pitch.Note) -> Text -> Either Text Text Source #

Try to figure out where the pitch call part is in event text and modify that with the given function. The function can signal failure by returning Left.

This is a bit of a heuristic because by design a pitch is a normal call and there's no syntactic way to tell where the pitches are in an expression. If the text is a call with a val call as its first argument, that's considered the pitch call. Otherwise, if the text is just a call, that's the pitch call. Otherwise the text is unchanged.

This works with the convention that pitch calls take the "base" pitch as their first argument.

modify_expr :: (Text -> Either Text Text) -> Text -> Either Text Text Source #

Modify the note expression, e.g. in i (a b c) it would be (a b c), including the parens.

edits

type ModifyPitch = Scale -> BaseTypes.Environ -> Pitch.Note -> Either Text Pitch.Note Source #

Function that modifies the pitch of an event on a pitch track, or a Left if the operation failed.

pitches :: Cmd.M m => ModifyPitch -> m () Source #

pitch_tracks :: Cmd.M m => ModifyPitch -> ModifyEvents.Track m Source #

Apply a ModifyPitch to only pitch tracks.