Karya, built on 2018-02-23T20:23:55 (patch cf8565b7ac832266878af99a942555d139065f12)

Safe HaskellNone

Derive.Score

Contents

Description

This has the basic data structures for the deriver level.

The events here are generated from UI Events, and will eventually be transformed into Perform Events, which are specific to the performance backend.

Synopsis

Documentation

Event

data Event Source #

Constructors

Event 

Fields

Instances

Show Event # 

Methods

showsPrec :: Int -> Event -> ShowS #

show :: Event -> String #

showList :: [Event] -> ShowS #

Show InstrumentCalls # 
Show Builtins # 
Show Library # 
Semigroup NoteDeriver # 
Monoid NoteDeriver # 
DeepSeq.NFData Event # 

Methods

rnf :: Event -> () #

Pretty.Pretty Event # 
Taggable Event # 
Cacheable Event # 
Semigroup (Stream Event) # 
Monoid (Stream Event) # 
Callable (Transformer Note) # 
Callable (Generator Note) # 
Callable (TrackCall Note) # 
ToLibrary (Transformer Note) # 
ToLibrary (Generator Note) # 
ToLibrary (TrackCall Note) # 

short_event :: Event -> Text Source #

Format an event in a way suitable for including inline in log messages. It's short, but hopefully enough information to identify the event in question.

This is the derive equivalent to log_event.

event_min :: Event -> RealTime Source #

Get minimum and maximum edges of the event. event_start isn't necessarily the minimum because of negative durations.

event_max :: Event -> RealTime Source #

Get minimum and maximum edges of the event. event_start isn't necessarily the minimum because of negative durations.

copy :: Event -> Event Source #

If you use an event to create another event, call this to clear out data that shouldn't go with the copy.

normalize :: Event -> Event Source #

Apply environ and controls to pitches.

Normally this is done by Convert, but if you want to see an event for debugging it can be nicer to see the normalized version.

Unlike Perform.Midi.Convert, this doesn't trim the controls, so it applies out-of-range transpositions.

flags

logs

environ

modify_environ_key :: EnvKey.Key -> (Maybe BaseTypes.Val -> BaseTypes.Val) -> Event -> Event Source #

Modify the value at the given key.

attributes

delayed args

put_arg :: Typeable a => Text -> a -> Event -> Event Source #

take_arg :: Typeable a => Text -> Event -> Either Text (Event, Maybe a) Source #

Find an arg in event_delayed_args, and remove it from the event if it existed. Throw an error if it existed but had an unexpected type.

modify events

move :: (RealTime -> RealTime) -> Event -> Event Source #

Change the start time of an event and move its controls along with it.

set_instrument :: Instrument -> BaseTypes.Environ -> Event -> Event Source #

Set the instrument on an event, and also update its environ from the instrument. You should really rederive with the new instrument, but this way can be more convenient, if somewhat sketchy.

control

data Control Source #

A control is an abstract parameter that influences derivation. Some of them affect performance and will be rendered as MIDI controls or note parameters or whatever, while others may affect derivation (e.g. tempo) and won't be seen by the backend at all.

A Control should be a valid identifier as defined by valid_symbol.

Instances

Eq Control # 

Methods

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

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

Ord Control # 
Read Control # 
Show Control # 
IsString Control # 

Methods

fromString :: String -> Control #

DeepSeq.NFData Control # 

Methods

rnf :: Control -> () #

Pretty.Pretty Control # 
Pretty.Pretty BaseTypes.ControlRef # 
Serialize Control # 
ShowVal Control # 
ShowVal BaseTypes.ControlRef #

This can only represent constant signals, since there's no literal for an arbitrary signal. Non-constant signals will turn into a constant of whatever was at 0.

ToVal BaseTypes.ControlRef # 
ToVal Control # 
ToVal BaseTypes.ControlRef # 
Typecheck Control # 
Typecheck BaseTypes.ControlRef #

Use a TypedFunction or Function instead of this.

ShowVal (Typed Control) # 

type ControlValMap = Map Control Signal.Y Source #

This is a snapshot of the control signals at a certain point in time. It's meant for PitchConfig, so the values are expected to be transpositions, and hence untyped.

control_at :: RealTime -> Control -> Event -> Maybe (Typed Signal.Y) Source #

Get a control value from the event, or Nothing if that control isn't present.

modify_dynamic :: (Signal.Y -> Signal.Y) -> Event -> Event Source #

Use this instead of modify_control_vals because it also sets EnvKey.dynamic_val. This is only valid for linear functions like (+) or (*).

set_dynamic :: Signal.Y -> Event -> Event Source #

Use this instead of set_control because it also sets EnvKey.dynamic_val.

modify_control :: Control -> (Signal.Control -> Signal.Control) -> Event -> Event Source #

Modify a control. If there is no existing control, the modify function gets an empty signal.

pitch

data PControl Source #

The pitch control version of Control. Unlike Control, this is allowed to be null, which is the name of the default pitch signal.

A PControl should be a valid identifier as defined by valid_symbol, except that its literal tracklang form starts with a #, to differentiate from a Control.

Instances

Eq PControl # 
Ord PControl # 
Read PControl # 
Show PControl # 
IsString PControl # 
DeepSeq.NFData PControl # 

Methods

rnf :: PControl -> () #

Pretty.Pretty PControl # 
Pretty.Pretty BaseTypes.PControlRef # 
Serialize PControl # 
ShowVal PControl # 
ShowVal BaseTypes.PControlRef #

There's no way to convert a pitch back into the expression that produced it, so this is the best I can do.

Similar to ShowVal BaseTypes.ControlRef, there's no signal literal so I use the value at 0. A pitch can be turned into an expression, but not necessarily accurately since it doesn't take things like pitch interpolation into account.

ToVal PControl # 
ToVal BaseTypes.PControlRef # 
Typecheck PControl # 
Typecheck BaseTypes.PControlRef # 

transposed_at :: RealTime -> Event -> Maybe BaseTypes.Transposed Source #

Unlike pitch_at, the transposition has already been applied. This is because callers expect to get the actual pitch, not the pitch plus some homework to do on the pitch. If you use this pitch to emit another pitch you proabbly need the raw pitch, but so far everyone doing that is at the Derive level, not postproc, so they use Derive.pitch_at.

Type

data Type Source #

Tag for the type of the values in a control signal.

Constructors

Untyped 
Chromatic 
Diatonic 
Nn 
Score 
Real 

Instances

data Typed a Source #

Constructors

Typed 

Fields

Instances

Functor Typed # 

Methods

fmap :: (a -> b) -> Typed a -> Typed b #

(<$) :: a -> Typed b -> Typed a #

Pretty.Pretty BaseTypes.ControlRef # 
ShowVal BaseTypes.ControlRef #

This can only represent constant signals, since there's no literal for an arbitrary signal. Non-constant signals will turn into a constant of whatever was at 0.

ToVal BaseTypes.ControlRef # 
ToVal BaseTypes.ControlRef # 
Typecheck BaseTypes.ControlRef #

Use a TypedFunction or Function instead of this.

Typecheck TypedFunction # 
Eq a => Eq (Typed a) # 

Methods

(==) :: Typed a -> Typed a -> Bool #

(/=) :: Typed a -> Typed a -> Bool #

Ord a => Ord (Typed a) # 

Methods

compare :: Typed a -> Typed a -> Ordering #

(<) :: Typed a -> Typed a -> Bool #

(<=) :: Typed a -> Typed a -> Bool #

(>) :: Typed a -> Typed a -> Bool #

(>=) :: Typed a -> Typed a -> Bool #

max :: Typed a -> Typed a -> Typed a #

min :: Typed a -> Typed a -> Typed a #

Read a => Read (Typed a) # 
Show a => Show (Typed a) # 

Methods

showsPrec :: Int -> Typed a -> ShowS #

show :: Typed a -> String #

showList :: [Typed a] -> ShowS #

Semigroup a => Semigroup (Typed a) # 

Methods

(<>) :: Typed a -> Typed a -> Typed a #

sconcat :: NonEmpty (Typed a) -> Typed a #

stimes :: Integral b => b -> Typed a -> Typed a #

(Semigroup a, Monoid a) => Monoid (Typed a) # 

Methods

mempty :: Typed a #

mappend :: Typed a -> Typed a -> Typed a #

mconcat :: [Typed a] -> Typed a #

DeepSeq.NFData a => DeepSeq.NFData (Typed a) # 

Methods

rnf :: Typed a -> () #

Pretty.Pretty a => Pretty.Pretty (Typed a) # 
Serialize a => Serialize (Typed a) # 

Methods

put :: Putter (Typed a) Source #

get :: Get (Typed a) Source #

ShowVal (Typed Signal.Y) # 
ShowVal (Typed Control) # 
TypecheckNum (Typed Signal.Y) # 
ToVal (Typed Signal.Y) # 
Typecheck (Typed Signal.Y) # 

untyped :: a -> Typed a Source #

merge_typed :: (a -> a -> a) -> Typed a -> Typed a -> Typed a Source #

instrument

newtype Instrument Source #

An Instrument is identified by a plain string. This will be looked up in the instrument db to get the backend specific Instrument type as well as the backend itself, but things at the Derive layer and above don't care about all that.

This should be a valid symbol as defined by valid_symbol. This way it can be parsed without quotes.

Constructors

Instrument Text 

util

control :: Text -> Either Text Control Source #

Use this constructor when making a Control from user input. Literals can use the IsString instance.

pcontrol :: Text -> Either Text PControl Source #

Use this constructor when making a PControl from user input. Literals can use the IsString instance.

c_dynamic :: Control Source #

Converted into velocity or breath depending on the instrument.

parse_generic_control :: Text -> Either Text (Either Control PControl) Source #

Parse either a Control or PControl.