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

Perform.Midi.Patch

Description

Description of a midi-specific instrument, as well as the runtime midi device and channel mapping.

Synopsis

Config

data Config Source #

Configuration for one MIDI instrument allocation.

Constructors

Config 

Fields

  • config_allocation :: ![(Addr, Maybe Voices)]

    An instrument may have multiple addresses assigned to it, which means that it can be multiplexed across multiple channels. In addition, multiple instruments can be allocated to overlapping addresses, which is how keyswitches work; each one is considered a separate instrument. An instrument wishing to use an address will emit an appropriate message to configure it (probably a keyswitch, possibly a program change).

    Each Addr has a count of how many simultaneous voices the addr can handle. Nothing means there's no limit.

  • config_initialization :: !(Set Initialization)
     
  • config_settings :: !Settings
     

Instances

Instances details
Eq Config # 
Instance details

Defined in Perform.Midi.Patch

Methods

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

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

Read Config # 
Instance details

Defined in Perform.Midi.Patch

Show Config # 
Instance details

Defined in Perform.Midi.Patch

Pretty.Pretty Config # 
Instance details

Defined in Perform.Midi.Patch

Serialize Config # 
Instance details

Defined in Cmd.Serialize

data Initialization Source #

Document what kinds of initialization this instrument needs. Each instrument is initialized once when the score is loaded.

Constructors

Tuning

Configure tuning with Midi.realtime_tuning.

NrpnTuning

Configure tuning with Midi.nrpn_tuning.

Midi

Send InitializePatch.

Instances

Instances details
Bounded Initialization # 
Instance details

Defined in Perform.Midi.Patch

Enum Initialization # 
Instance details

Defined in Perform.Midi.Patch

Eq Initialization # 
Instance details

Defined in Perform.Midi.Patch

Ord Initialization # 
Instance details

Defined in Perform.Midi.Patch

Read Initialization # 
Instance details

Defined in Perform.Midi.Patch

Show Initialization # 
Instance details

Defined in Perform.Midi.Patch

Pretty.Pretty Initialization # 
Instance details

Defined in Perform.Midi.Patch

Serialize Initialization # 
Instance details

Defined in Cmd.Serialize

type Addr = (Midi.WriteDevice, Midi.Channel) Source #

MIDI instruments are addressed by a (device, channel) pair, allocated in Config.

type Voices = Int Source #

Number of simultaneous voices a certain Addr supports, aka polyphony.

type PbRange = (Int, Int) Source #

Pitchbend range in tempered semitones below and above unity. The first integer should probably be negative.

Settings

data Settings Source #

This has instrument configuration which has built-in defaults but can also be modified per score. When the instrument is looked up (Cmd.resolve_instrument), patch_defaults is merged with config_settings via merge_defaults.

Constructors

Settings 

Fields

Instances

Instances details
Eq Settings # 
Instance details

Defined in Perform.Midi.Patch

Read Settings # 
Instance details

Defined in Perform.Midi.Patch

Show Settings # 
Instance details

Defined in Perform.Midi.Patch

Semigroup Settings # 
Instance details

Defined in Perform.Midi.Patch

Monoid Settings # 
Instance details

Defined in Perform.Midi.Patch

Pretty.Pretty Settings # 
Instance details

Defined in Perform.Midi.Patch

Serialize Settings # 
Instance details

Defined in Cmd.Serialize

Patch

data Patch Source #

A Patch has information about one specific instrument. The performance Instrument and MIDI config are derived from it, via its Synth.

Constructors

Patch 

Fields

Instances

Instances details
Eq Patch # 
Instance details

Defined in Perform.Midi.Patch

Methods

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

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

Show Patch # 
Instance details

Defined in Perform.Midi.Patch

Methods

showsPrec :: Int -> Patch -> ShowS #

show :: Patch -> String #

showList :: [Patch] -> ShowS #

Pretty.Pretty Patch # 
Instance details

Defined in Perform.Midi.Patch

Serialize Patch # 
Instance details

Defined in Instrument.Serialize

patch :: PbRange -> InstTypes.Name -> Patch Source #

Create a Patch with empty vals, to set them as needed.

default_name :: InstTypes.Name Source #

This is a convention for the default instrument of a synth. This is useful for softsynths whose patches all generally have the same config.

Scale

data Scale Source #

Describe the tuning of a MIDI patch.

This is used both to describe a patch tuned to something other than 12TET, and to retune a 12TET patch.

The Scale is used during performance to warp played pitches to the patch's tuning. The idea is that they will warp to integral Midi.Keys that won't need any tuning and can thus all go on a single MIDI channel.

Constructors

Scale 

Fields

Instances

Instances details
Eq Scale # 
Instance details

Defined in Perform.Midi.Patch

Methods

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

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

Read Scale # 
Instance details

Defined in Perform.Midi.Patch

Show Scale # 
Instance details

Defined in Perform.Midi.Patch

Methods

showsPrec :: Int -> Scale -> ShowS #

show :: Scale -> String #

showList :: [Scale] -> ShowS #

Pretty.Pretty Scale # 
Instance details

Defined in Perform.Midi.Patch

Serialize Scale # 
Instance details

Defined in Cmd.Serialize

make_scale :: Text -> [(Midi.Key, Pitch.NoteNumber)] -> Scale Source #

Fill in non-adjacent MIDI keys by interpolating the neighboring NoteNumbers. This is because a 0 between two notes will prevent pitch slides. Another problem is that the MIDI performer has no notion of instruments that don't support certain key numbers. That could be added but it's simpler to just not have patches like that.

convert_scale Source #

Arguments

:: Scale 
-> Pitch.NoteNumber

if you want this pitch

-> Maybe Pitch.NoteNumber

play this key

scale_nns :: Maybe AttributeMap -> Scale -> [(Midi.Key, Pitch.NoteNumber)] Source #

Absolute NoteNumber for each Midi.Key to tune 12TET to this scale.

scale_offsets :: Maybe AttributeMap -> Scale -> [Maybe Pitch.NoteNumber] Source #

Relative NoteNumber offset for each Midi.Key to tune 12TET to this scale.

scale_tuning :: Maybe AttributeMap -> Scale -> [Maybe (Midi.Key, Pitch.NoteNumber)] Source #

Map the mapped keys through the scale.

Flag

data Flag Source #

Various instrument flags. Add new ones at the bottom to avoid messing up serialization.

Constructors

Pressure

Patch uses continuous pressure control, assigned to CC 2 (breath), instead of trigger velocity. This is used to support the dyn control. Percussive instruments like pianos map it to MIDI velocity, and continuous instruments like winds always have maximum velocity and map dyn to breath.

HoldKeyswitch

If set, a keysitch has to be held while its note is playing. Otherwise, it will just be tapped before the note starts.

ResumePlay

When playing from mid-score, scan backwards for the first overlapping notes with this instrument set and resume that note. This way you can play long notes like tambura from the middle.

UseFinalNoteOff

If there are overlapping notes with the same MIDI key, delay all NoteOffs until the final one. This is for synthesizers which turn the note off on the first one, such as Kontakt.

TODO: this is disabled, remove it entirely if I really don't seem to need it. avoid_overlaps.

Old_Triggered

Obsolete, don't use.

Instances

Instances details
Bounded Flag # 
Instance details

Defined in Perform.Midi.Patch

Enum Flag # 
Instance details

Defined in Perform.Midi.Patch

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 Perform.Midi.Patch

Methods

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

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

Ord Flag # 
Instance details

Defined in Perform.Midi.Patch

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 #

Read Flag # 
Instance details

Defined in Perform.Midi.Patch

Show Flag # 
Instance details

Defined in Perform.Midi.Patch

Methods

showsPrec :: Int -> Flag -> ShowS #

show :: Flag -> String #

showList :: [Flag] -> ShowS #

Pretty.Pretty Flag # 
Instance details

Defined in Perform.Midi.Patch

Serialize Flag # 
Instance details

Defined in Cmd.Serialize

InitializePatch

data InitializePatch Source #

Describe how an instrument should be initialized before it can be played.

Constructors

InitializeMidi ![Midi.Message]

Send these msgs to initialize the patch. It should be a patch change or a sysex.

InitializeMessage !Text

Display this msg to the user and hope they do what it says.

NoInitialization 

AttributeMap

type AttributeMap = Common.AttributeMap ([Keyswitch], Maybe Keymap) Source #

This is a specialization of Common.AttributeMap for MIDI. You should use a constructor like keyswitches, which will call sort_attributes to make sure there are no overlaps.

data Keymap Source #

A Keymap corresponds to a timbre selected by MIDI key range, rather than keyswitches. Unlike a keyswitch, this doesn't change the state of the MIDI channel, so multiple keymapped notes can coexist, and keymap replaces the pitch of the note.

Constructors

UnpitchedKeymap !Midi.Key

This ignores the event's pitch and instead emits the given MIDI key. This is appropriate for drumkit style patches, with a separate unpitched timbre on each key.

PitchedKeymap !Midi.Key !Midi.Key !Midi.Key

The timbre is mapped over the inclusive MIDI key range from low to high, where the pitch of the low end of the range is given by the NoteNumber. So this transposes the event's pitch and clips it to the given range.

Instances

Instances details
Eq Keymap # 
Instance details

Defined in Perform.Midi.Patch

Methods

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

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

Ord Keymap # 
Instance details

Defined in Perform.Midi.Patch

Show Keymap # 
Instance details

Defined in Perform.Midi.Patch

DeepSeq.NFData Keymap # 
Instance details

Defined in Perform.Midi.Patch

Methods

rnf :: Keymap -> () #

Pretty.Pretty Keymap # 
Instance details

Defined in Perform.Midi.Patch

Serialize Keymap # 
Instance details

Defined in Instrument.Serialize

data Keyswitch Source #

A Keyswitch changes the timbre of a patch, but does so in a channel-global way. So overlapping notes with different keyswitches will be split into different channels, if possible. See NOTE [midi-state].

Constructors

Keyswitch !Midi.Key 
ControlSwitch !Midi.Control !Midi.ControlValue

This keyswitch is triggered by a control change.

Aftertouch !Midi.ControlValue

This is like ControlSwitch, except send a poly aftertouch value for the note's pitch. This allows simultaneous different notes with different articulations.

keyswitches :: [(Attrs.Attributes, [Keyswitch])] -> AttributeMap Source #

An AttributeMap with just Keyswitches.

single_keyswitches :: [(Attrs.Attributes, Midi.Key)] -> AttributeMap Source #

An AttributeMap with a single Midi.Key keyswitch per Attribute.

cc_keyswitches :: [(Midi.Control, [(Attrs.Attributes, Midi.ControlValue)])] -> AttributeMap Source #

An AttributeMap that uses ControlSwitches. Each CC can have attrs at several values.

cc_keyswitches_permute :: [(Midi.Control, [(Attrs.Attributes, Midi.ControlValue)])] -> AttributeMap Source #

Like cc_keyswitches, except that all the controls are orthogonal, so every cross-control combination of attributes is valid.

keymap :: [(Attrs.Attributes, Keymap)] -> AttributeMap Source #

An AttributeMap with just Keymaps.

unpitched_keymap :: [(Attrs.Attributes, Midi.Key)] -> AttributeMap Source #

An AttributeMap with just unpitched keymaps.

keyswitch_on :: Midi.Key -> Keyswitch -> Midi.ChannelMessage Source #

The MIDI message to activate the given Keyswitch.

ModeMap

newtype ModeMap Source #

The ModeMap is like the AttributeMap, but it's triggered by the event Environ, rather than Attributes. This is suitable for modes which have mutually exclusive settings. See NOTE [midi-state].

Instances

Instances details
Eq ModeMap # 
Instance details

Defined in Perform.Midi.Patch

Methods

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

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

Show ModeMap # 
Instance details

Defined in Perform.Midi.Patch

Pretty.Pretty ModeMap # 
Instance details

Defined in Perform.Midi.Patch

Serialize ModeMap # 
Instance details

Defined in Instrument.Serialize

cc_mode_map :: [(EnvKey.Key, Midi.Control, [(Expr.MiniVal, Midi.ControlValue)])] -> (ModeMap, [(Midi.Control, ScoreT.Control)]) Source #

Construct a ModeMap that uses MIDI CC.