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

Perform.Midi.Convert

Description

Convert from the Derive events to MIDI performer specific events.

Since this module depends on both the Derive and Perform.Midi layers, it should be called from Derive or Cmd, not Perform.Midi, even though it's physically located in Perform.Midi.

Synopsis

Documentation

default_srate :: RealTime Source #

This is the sampling rate used to convert linear segments from Signal.Signal to MSignal.Signal.

Since this is only used to interpolate linear segments, it probably doesn't need to be as high as one needed to express the nuances of more complicated curves. If the tracklang srate is higher, then the MIDI output will be denser and more accurate.

convert :: RealTime -> MidiLookup -> (ScoreT.Instrument -> Maybe Cmd.ResolvedInstrument) -> [Score.Event] -> [LEvent.LEvent Types.Event] Source #

Convert Score events to Perform events, emitting warnings that may have happened along the way.

convert_midi_pitch :: Log.LogMonad m => RealTime -> ScoreT.Instrument -> Patch.Patch -> Patch.Config -> ScoreT.ControlMap -> Score.Event -> m ((Types.Patch, [(Midi.Control, Midi.ControlValue)]), PitchSignal) Source #

If the Event has an attribute matching its keymap, use the pitch from the keymap. Otherwise convert the pitch signal.

TODO this used to warn about unmatched attributes, but it got annoying because I use attributes freely. It still seems like it could be useful, so maybe I want to put it back in again someday.

convert_event_pitch :: Log.LogMonad m => RealTime -> Types.Patch -> ScoreT.ControlMap -> Score.Event -> m PitchSignal Source #

Get the flattened Signal.NoteNumber from an event.

round_pitch :: Signal.Y -> Signal.Y Source #

Round pitches to the nearest tenth of a cent. Differences below this are probably imperceptible. Due to floating point inaccuracy, pitches can wind up being slightly off of integral, leading to pitch bending where there should be none.

convert_controls Source #

Arguments

:: RealTime 
-> Control.ControlMap

Instrument's control map.

-> ScoreT.ControlMap

Controls to convert.

-> Map ScoreT.Control MSignal.Signal 

Convert deriver controls to performance controls. Drop all non-MIDI controls, since those will inhibit channel sharing later.