Karya, built on 2018-05-31T02:46:59 (patch 0a1a35479c514820d77330ae8a978975ba22a47a)

Safe HaskellNone



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.



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.

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

old_event -> (new_event, advance?)

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.

modify :: (Event -> 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 -> 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 :: 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.

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

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

Apply a ModifyPitch to only pitch tracks.

data Event Source #

Semi-parse event text into method, val, and args. Method is actually the call, val is the first argument to the calll, and args are the remaining arguments. Control calls have a convention where the first argument is the value to set. I separate it out so I can replace just that value while leaving any arguments intact. E.g., exponential interpolation might look like e 0 3, where 0 is the destination and 3 is the exponent. Or e (4c) 3 in the case of pitches. If I press a MIDI key I want to replace just the 4c.

The "method" terminology dates from back before calls existed. Nowadays it's just a call, but for that matter so are numeric literals, so I need something to differentiate 1 from i 1.


Eq Event # 
Instance details

Defined in Cmd.ControlTrack


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

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

Show Event # 
Instance details

Defined in Cmd.ControlTrack


showsPrec :: Int -> Event -> ShowS #

show :: Event -> String #

showList :: [Event] -> ShowS #