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

Instrument.Common

Description

This contains instrument data in common between different backends.

Synopsis

Documentation

data Common code Source #

Attributes common to all instruments. Unlike Config, these are part of the instrument itself and not configurable.

Constructors

Common 

Fields

  • common_code :: !code

    Cmds and Derive calls. This is abstract so this can be defined without incurring a dependency on Cmd.Cmd, which would wind up being a circular dependency.

  • common_environ :: !REnv.Environ

    This environ is merged into the derive environ when the instrument comes into scope, and also when the pitch of Events with this instrument is converted. Typically it sets things like instrument range, tuning details, etc.

  • common_tags :: ![Tag.Tag]

    Key-value pairs used to index the instrument. A key may appear more than once with different values. Tags are free-form, but there is a list of standard tags in Instrument.Tag.

  • common_doc :: !Doc.Doc

    So, instrument, tell me about yourself.

  • common_flags :: !(Set Flag)

    Flags shared with all instruments.

    TODO unlike midi flags, these are hardcoded and can't be changed per-instrument. I should probably do the same thing as Midi.Patch and have a Settings which is copied as the default. But it's a hassle and I don't need it right now.

  • common_call_map :: !CallMap
     

Instances

Instances details
Functor Common Source # 
Instance details

Defined in Instrument.Common

Methods

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

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

Show code => Show (Common code) Source # 
Instance details

Defined in Instrument.Common

Methods

showsPrec :: Int -> Common code -> ShowS #

show :: Common code -> String #

showList :: [Common code] -> ShowS #

Pretty.Pretty code => Pretty.Pretty (Common code) Source # 
Instance details

Defined in Instrument.Common

Methods

pretty :: Common code -> Text Source #

format :: Common code -> Doc Source #

formatList :: [Common code] -> Doc Source #

Serialize.Serialize (Common ()) Source # 
Instance details

Defined in Instrument.Serialize

code :: Common code :-> code Source #

type CallMap = Map Attrs.Attributes Expr.Symbol Source #

Map attributes to the names of the calls they should map to. This is used by the integrator to turn score events into UI events.

common :: code -> Common code Source #

data Flag Source #

Constructors

Triggered

Patch doesn't pay attention to duration, e.g. percussion. The UI can use this to create zero duration events for this instrument.

Instances

Instances details
Bounded Flag Source # 
Instance details

Defined in Instrument.Common

Enum Flag Source # 
Instance details

Defined in Instrument.Common

Methods

succ :: Flag -> Flag #

pred :: Flag -> Flag #

toEnum :: Int -> Flag #

fromEnum :: Flag -> Int #

enumFrom :: Flag -> [Flag] #

enumFromThen :: Flag -> Flag -> [Flag] #

enumFromTo :: Flag -> Flag -> [Flag] #

enumFromThenTo :: Flag -> Flag -> Flag -> [Flag] #

Show Flag Source # 
Instance details

Defined in Instrument.Common

Methods

showsPrec :: Int -> Flag -> ShowS #

show :: Flag -> String #

showList :: [Flag] -> ShowS #

Eq Flag Source # 
Instance details

Defined in Instrument.Common

Methods

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

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

Ord Flag Source # 
Instance details

Defined in Instrument.Common

Methods

compare :: Flag -> Flag -> Ordering #

(<) :: Flag -> Flag -> Bool #

(<=) :: Flag -> Flag -> Bool #

(>) :: Flag -> Flag -> Bool #

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

max :: Flag -> Flag -> Flag #

min :: Flag -> Flag -> Flag #

Pretty.Pretty Flag Source # 
Instance details

Defined in Instrument.Common

Serialize.Serialize Flag Source # 
Instance details

Defined in Cmd.Serialize

add_environ :: REnv.ToVal a => EnvKey.Key -> a -> Common code -> Common code Source #

AttributeMap

newtype AttributeMap a Source #

This determines what Attributes the instrument can respond to. Each set of Attributes is mapped to a backend-specific value. The attributes are matched by subset in order, so their order gives a priority.

For example, if +pizz is before +nv, then +pizz+nv will map to +pizz, unless +pizz+nv exists. The idea is that more specific or more perceptually important attributes go first. Since pizz vs. arco is a much more obvious distinction than vibrato vs. nv, if you say everything is nv but some notes are also pizz, chances are you want those notes to get pizz even if there isn't a specifically nv pizz variant.

This also means that if a previous attr is a subset of a later one, the later one will never be selected. overlapping_attributes will check for that, but normally you use a constructor that calls sort_attributes to make sure that can't happen.

Constructors

AttributeMap [(Attrs.Attributes, a)] 

Instances

Instances details
Functor AttributeMap Source # 
Instance details

Defined in Instrument.Common

Methods

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

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

Monoid (AttributeMap a) Source # 
Instance details

Defined in Instrument.Common

Semigroup (AttributeMap a) Source # 
Instance details

Defined in Instrument.Common

Show a => Show (AttributeMap a) Source # 
Instance details

Defined in Instrument.Common

Eq a => Eq (AttributeMap a) Source # 
Instance details

Defined in Instrument.Common

Pretty.Pretty a => Pretty.Pretty (AttributeMap a) Source # 
Instance details

Defined in Instrument.Common

Serialize.Serialize a => Serialize.Serialize (AttributeMap a) Source # 
Instance details

Defined in Instrument.Common

overlapping_attributes :: AttributeMap a -> [Text] Source #

Figured out if any attributes shadow other attributes. I think this shouldn't happen if you called sort_attributes, or used any of the constructors other than AttributeMap.

sort_attributes :: [(Attrs.Attributes, a)] -> [(Attrs.Attributes, a)] Source #

lookup_attributes looks for the first subset, which means that a smaller set of attributes can shadow a larger set. Since it's annoying to have to worry about order, sort larger sets to the back.

The sort is stable, so it shouldn't destroy the priority implicit in the order.

Config

data Config Source #

Configuration for a specific allocation of an instrument in a specific score.

Constructors

Config 

Fields

  • config_environ :: !REnv.Environ

    This is a local version of common_environ. Overlayed on the instrument config common_environ.

  • config_controls :: !ScoreT.ControlValMap

    This is the control equivalent to config_environ. These controls are merged using their default mergers in the note call. Being in the note call means that the merge should only happen once. config_environ, on the other hand, is applied when the instrument comes into scope, which should be safe, since merging the environ is idempotent.

    This can be useful to set a per-instrument transposition, or dynamic level.

  • config_mute :: !Bool

    If true, this instrument is filtered out prior to playing.

  • config_solo :: !Bool

    If any instrument is soloed, all instruments except soloed ones are filtered out prior to playing.

Instances

Instances details
Show Config Source # 
Instance details

Defined in Instrument.Common

Eq Config Source # 
Instance details

Defined in Instrument.Common

Methods

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

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

Pretty.Pretty Config Source # 
Instance details

Defined in Instrument.Common

Serialize.Serialize Config Source # 
Instance details

Defined in Cmd.Serialize