Safe Haskell | Safe-Inferred |
---|
Simulate a MIDI synth and turn low level MIDI msgs back into a medium level form. This is a bit like "unperform".
Synopsis
- initial_pitches :: [Note] -> [(Int, Pitch.NoteNumber)]
- nonconstant_pitches :: [Note] -> [Note]
- initial_pitch :: Note -> Pitch.NoteNumber
- round_cents :: Pitch.NoteNumber -> Pitch.NoteNumber
- data State = State {
- state_pb_range :: !(Map MState.Addr PbRange)
- state_channel :: !MState.State
- state_active :: !(Map MState.Addr [SoundingNote])
- state_notes :: ![Note]
- state_warns :: ![(Midi.WriteMessage, Text)]
- empty_state :: State
- type PbRange = (Pitch.NoteNumber, Pitch.NoteNumber)
- get_pb_range :: MState.Addr -> State -> PbRange
- type SoundingNote = NoteT (Maybe RealTime.RealTime)
- type Note = NoteT RealTime.RealTime
- data NoteT end = Note {}
- type ControlMap = Map MState.Control [(RealTime.RealTime, Midi.ControlValue)]
- type SynthM a = Reader.ReaderT Midi.WriteMessage (State.StateT State Identity) a
- modify :: (State -> State) -> SynthM ()
- run :: State -> [Midi.WriteMessage] -> State
- postproc :: State -> State
- run_msg :: Midi.WriteMessage -> SynthM ()
- update_channel_state :: Midi.WriteMessage -> State -> State
- normalize_msg :: Midi.ChannelMessage -> Midi.ChannelMessage
- deactivate :: RealTime.RealTime -> State -> State
- deactivate_time :: RealTime.RealTime
- note_on :: MState.Addr -> RealTime.RealTime -> Midi.Key -> Midi.Velocity -> SynthM ()
- make_note :: PbRange -> MState.Channel -> MState.Addr -> RealTime.RealTime -> Midi.Key -> Midi.Velocity -> SoundingNote
- note_off :: MState.Addr -> RealTime.RealTime -> Midi.Key -> SynthM ()
- key_sounding :: Midi.Key -> SoundingNote -> Bool
- control :: MState.Addr -> RealTime.RealTime -> MState.Control -> Midi.ControlValue -> SynthM ()
- pitch_bend :: MState.Addr -> RealTime.RealTime -> Midi.PitchBendValue -> SynthM ()
- convert_pitch :: PbRange -> Midi.Key -> Midi.PitchBendValue -> Pitch.NoteNumber
- modify_notes :: MState.Addr -> ([SoundingNote] -> [SoundingNote]) -> SynthM ()
- warn :: Text -> SynthM ()
- pretty_state :: State -> Text
- pretty_controls :: ControlMap -> Text
- pretty_warn :: (Midi.WriteMessage, Text) -> Text
analyze
initial_pitches :: [Note] -> [(Int, Pitch.NoteNumber)] Source #
nonconstant_pitches :: [Note] -> [Note] Source #
initial_pitch :: Note -> Pitch.NoteNumber Source #
compute
State | |
|
empty_state :: State Source #
type PbRange = (Pitch.NoteNumber, Pitch.NoteNumber) Source #
(down, up)
get_pb_range :: MState.Addr -> State -> PbRange Source #
type SoundingNote = NoteT (Maybe RealTime.RealTime) Source #
SoundingNotes may still be open.
type Note = NoteT RealTime.RealTime Source #
Note | |
|
type ControlMap = Map MState.Control [(RealTime.RealTime, Midi.ControlValue)] Source #
type SynthM a = Reader.ReaderT Midi.WriteMessage (State.StateT State Identity) a Source #
Keep the current msg for warn
.
run_msg :: Midi.WriteMessage -> SynthM () Source #
update_channel_state :: Midi.WriteMessage -> State -> State Source #
deactivate :: RealTime.RealTime -> State -> State Source #
After notes have had a note-off time for a certain amount of time, move
them from state_active
to state_notes
. The certain amount of time
should be the note's decay time, but since I don't really know that, just
pick an arbitrary constant.
msgs
note_on :: MState.Addr -> RealTime.RealTime -> Midi.Key -> Midi.Velocity -> SynthM () Source #
make_note :: PbRange -> MState.Channel -> MState.Addr -> RealTime.RealTime -> Midi.Key -> Midi.Velocity -> SoundingNote Source #
note_off :: MState.Addr -> RealTime.RealTime -> Midi.Key -> SynthM () Source #
key_sounding :: Midi.Key -> SoundingNote -> Bool Source #
control :: MState.Addr -> RealTime.RealTime -> MState.Control -> Midi.ControlValue -> SynthM () Source #
Append a CC change to all sounding notes.
pitch_bend :: MState.Addr -> RealTime.RealTime -> Midi.PitchBendValue -> SynthM () Source #
Append pitch bend to all sounding notes.
convert_pitch :: PbRange -> Midi.Key -> Midi.PitchBendValue -> Pitch.NoteNumber Source #
modify_notes :: MState.Addr -> ([SoundingNote] -> [SoundingNote]) -> SynthM () Source #
util
pretty
pretty_state :: State -> Text Source #
Format synth state in an easier to read way.
pretty_controls :: ControlMap -> Text Source #
pretty_warn :: (Midi.WriteMessage, Text) -> Text Source #