Karya, built on 2020-11-26T21:03:17 (patch 23b5be2d53a9e8e7d6136cda5aae2849abe5cded)
Safe HaskellNone

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 :: !RestrictedEnviron.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 # 
Instance details

Defined in Instrument.Common

Methods

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

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

Show code => Show (Common code) # 
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) # 
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 ()) # 
Instance details

Defined in Instrument.Serialize

Methods

put :: Putter (Common ()) Source #

get :: Get (Common ()) Source #

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 # 
Instance details

Defined in Instrument.Common

Enum Flag # 
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] #

Eq Flag # 
Instance details

Defined in Instrument.Common

Methods

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

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

Ord Flag # 
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 #

Show Flag # 
Instance details

Defined in Instrument.Common

Methods

showsPrec :: Int -> Flag -> ShowS #

show :: Flag -> String #

showList :: [Flag] -> ShowS #

Pretty.Pretty Flag # 
Instance details

Defined in Instrument.Common

Serialize.Serialize Flag # 
Instance details

Defined in Cmd.Serialize

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_attribute_map to make sure that can't happen.

Constructors

AttributeMap [(Attrs.Attributes, a)] 

Instances

Instances details
Functor AttributeMap # 
Instance details

Defined in Instrument.Common

Methods

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

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

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

Defined in Instrument.Common

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

Defined in Instrument.Common

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

Defined in Instrument.Common

Serialize.Serialize a => Serialize.Serialize (AttributeMap a) # 
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_attribute_map, or used any of the constructors other than AttributeMap.

sort_attribute_map :: AttributeMap a -> AttributeMap 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

Instances

Instances details
Eq Config # 
Instance details

Defined in Instrument.Common

Methods

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

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

Show Config # 
Instance details

Defined in Instrument.Common

Pretty.Pretty Config # 
Instance details

Defined in Instrument.Common

Serialize.Serialize Config # 
Instance details

Defined in Cmd.Serialize