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

Safe HaskellNone

Cmd.ControlTrack

Contents

Synopsis

Documentation

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

Accept keystrokes and modify the val field of the event. Also accept InputNote.NoteOn or InputNote.Control msgs and enter a value based on their velocity or value, respectively. So you can use a MIDI knob to set arbitrary control values.

Since control vals are typically normalized between 0 and 1, this accepts hexadecimal higits and modifies the event text with modify_hex. However, not all tracks are normalized, so this only happens if infer_normalized thinks that it's normalized.

The ' key will enter a ' call, which repeats the last value. This is useful to extend a constant pitch value to the desired breakpoint.

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

Editing a tempo track is just like editing a normal control track, except that it doesn't do the hex entry thing.

infer_normalized :: Ui.M m => TrackId -> m Bool Source #

A track is assumed to be normalized if its first event has a `0x` in it. If the track has no first event, then it defaults to normalized.

TODO This is kind of bogus since it's just the first event and it just looks for a substring. A better check would be to see if the event being edited can have a normalized number extracted from it, and fall back on this only if there is no existing event.

modify_hex :: EditUtil.Key -> Modify Source #

This is tricky because the editing mode is different depending on whether the val is hex or not.

If it's hex or null, expect higits and rotate them into the value, always staying in the form `0x`##. If it's not hex, act like cmd_tempo_val_edit.

The one difference is that cmd_val_edit catches all alphanum keys since it is expecting a-f, and will then ignore them if they are other letters, while cmd_tempo_val_edit only catches the keys it will use, passing the rest through. It's already confusing enough which keys are caught by which editing mode, it would be even worse if it also depended on text of the event being editing. TODO perhaps I should go further and catch alphanum for the tempo track too, for consistency.

update_hex :: Text -> EditUtil.Key -> Maybe (Maybe Text) Source #

Nothing if the val is not a hex number, Just Nothing if it was but the key was Backspace, and Just Just if it should get a new value.

implementation

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.

Constructors

Event 

Instances

Eq Event # 

Methods

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

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

Show Event # 

Methods

showsPrec :: Int -> Event -> ShowS #

show :: Event -> String #

showList :: [Event] -> ShowS #

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

old_event -> (new_event, advance?)

modify_event :: Cmd.M m => Modify -> m () Source #

parse :: Text -> Event Source #

Try to figure out the call part of the expression and split it from the rest.

I use a trailing space to tell the difference between a method and a val.

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

The val itself can't have args, because it will then be mistaken for the method. E.g. given .5 0, the 0 will be considered the val while .5 is the method. This isn't a problem for control calls, which are just numbers and don't take arguments.

TODO The event is already bytestring, why don't I just directly give it to lex1?

modify_val Source #

Arguments

:: (Signal.Y -> Signal.Y) 
-> Text 
-> Maybe Text

Nothing if I couldn't parse out a VNum.

Try to figure out where the note part is in event text and modify that with the given function.

If the val was hex, keep it hex.