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

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 :: !(Maybe Initialization)
     
  • config_settings :: !Settings
     

Instances

Instances details
Generics.Generic Config Source # 
Instance details

Defined in Perform.Midi.Patch

Associated Types

type Generics.Rep Config :: Type -> Type #

Show Config Source # 
Instance details

Defined in Perform.Midi.Patch

Eq Config Source # 
Instance details

Defined in Perform.Midi.Patch

Methods

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

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

Pretty.Pretty Config Source # 
Instance details

Defined in Perform.Midi.Patch

Serialize Config Source # 
Instance details

Defined in Cmd.Serialize

type Generics.Rep Config Source # 
Instance details

Defined in Perform.Midi.Patch

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.

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
Monoid Settings Source # 
Instance details

Defined in Perform.Midi.Patch

Semigroup Settings Source # 
Instance details

Defined in Perform.Midi.Patch

Generics.Generic Settings Source # 
Instance details

Defined in Perform.Midi.Patch

Associated Types

type Generics.Rep Settings :: Type -> Type #

Show Settings Source # 
Instance details

Defined in Perform.Midi.Patch

Eq Settings Source # 
Instance details

Defined in Perform.Midi.Patch

Pretty.Pretty Settings Source # 
Instance details

Defined in Perform.Midi.Patch

Serialize Settings Source # 
Instance details

Defined in Cmd.Serialize

type Generics.Rep Settings Source # 
Instance details

Defined in Perform.Midi.Patch

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
Show Patch Source # 
Instance details

Defined in Perform.Midi.Patch

Methods

showsPrec :: Int -> Patch -> ShowS #

show :: Patch -> String #

showList :: [Patch] -> ShowS #

Eq Patch Source # 
Instance details

Defined in Perform.Midi.Patch

Methods

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

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

Pretty.Pretty Patch Source # 
Instance details

Defined in Perform.Midi.Patch

Serialize Patch Source # 
Instance details

Defined in Instrument.Serialize

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

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

default_name :: InstT.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
Show Scale Source # 
Instance details

Defined in Perform.Midi.Patch

Methods

showsPrec :: Int -> Scale -> ShowS #

show :: Scale -> String #

showList :: [Scale] -> ShowS #

Eq Scale Source # 
Instance details

Defined in Perform.Midi.Patch

Methods

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

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

Pretty.Pretty Scale Source # 
Instance details

Defined in Perform.Midi.Patch

Serialize Scale Source # 
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 Source # 
Instance details

Defined in Perform.Midi.Patch

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

Show Flag Source # 
Instance details

Defined in Perform.Midi.Patch

Methods

showsPrec :: Int -> Flag -> ShowS #

show :: Flag -> String #

showList :: [Flag] -> ShowS #

Eq Flag Source # 
Instance details

Defined in Perform.Midi.Patch

Methods

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

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

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

Pretty.Pretty Flag Source # 
Instance details

Defined in Perform.Midi.Patch

Serialize Flag Source # 
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. Channel is ignored.

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 Common.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. low, high, nn

Instances

Instances details
Show Keymap Source # 
Instance details

Defined in Perform.Midi.Patch

DeepSeq.NFData Keymap Source # 
Instance details

Defined in Perform.Midi.Patch

Methods

rnf :: Keymap -> () #

Eq Keymap Source # 
Instance details

Defined in Perform.Midi.Patch

Methods

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

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

Ord Keymap Source # 
Instance details

Defined in Perform.Midi.Patch

Pretty.Pretty Keymap Source # 
Instance details

Defined in Perform.Midi.Patch

Serialize Keymap Source # 
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.

Instances

Instances details
Show Keyswitch Source # 
Instance details

Defined in Perform.Midi.Patch

DeepSeq.NFData Keyswitch Source # 
Instance details

Defined in Perform.Midi.Patch

Methods

rnf :: Keyswitch -> () #

Eq Keyswitch Source # 
Instance details

Defined in Perform.Midi.Patch

Ord Keyswitch Source # 
Instance details

Defined in Perform.Midi.Patch

Pretty.Pretty Keyswitch Source # 
Instance details

Defined in Perform.Midi.Patch

Serialize Keyswitch Source # 
Instance details

Defined in Instrument.Serialize

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
Show ModeMap Source # 
Instance details

Defined in Perform.Midi.Patch

Eq ModeMap Source # 
Instance details

Defined in Perform.Midi.Patch

Methods

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

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

Pretty.Pretty ModeMap Source # 
Instance details

Defined in Perform.Midi.Patch

Serialize ModeMap Source # 
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.