midi-0.2.0.1: Handling of MIDI messages and files

Safe Haskell | None

Sound.MIDI.File

Description

MIDI-File Datatype

Taken from Haskore.

Synopsis

- data T = Cons Type Division [Track]
- data Division
  - = Ticks Tempo
  - | SMPTE Int Int
- type Track = T ElapsedTime T
- data Type
  - = Mixed
  - | Parallel
  - | Serial
- empty :: T
- type ElapsedTime = Integer
- fromElapsedTime :: ElapsedTime -> Integer
- toElapsedTime :: Integer -> ElapsedTime
- type Tempo = Int
- fromTempo :: Tempo -> Int
- toTempo :: Int -> Tempo
- explicitNoteOff :: T -> T
- implicitNoteOff :: T -> T
- getTracks :: T -> [Track]
- mergeTracks :: C time => Type -> [T time event] -> T time event
- secondsFromTicks :: Division -> T ElapsedTime T -> T Rational T
- ticksPerQuarterNote :: Division -> Tempo
- showLines :: T -> String
- changeVelocity :: Double -> T -> T
- resampleTime :: Double -> T -> T
- showEvent :: T -> ShowS
- showTime :: ElapsedTime -> ShowS
- sortEvents :: T -> T
- progChangeBeforeSetTempo :: T -> T

# Documentation

data T Source

The datatypes for MIDI Files and MIDI Events

Constructors

Cons Type Division [Track] |

Instances

Eq T |
Show T |
Arbitrary T |

data Division Source

Constructors

Ticks Tempo |
SMPTE Int Int |

Instances

Eq Division |
Show Division |
Arbitrary Division |

type Track = T ElapsedTime T Source

data Type Source

Constructors

Mixed |
Parallel |
Serial |

Instances

Bounded Type |
Enum Type |
Eq Type |
Ord Type |
Show Type |
Ix Type |

empty :: T Source

An empty MIDI file. Tempo is set to one tick per quarter note.

type ElapsedTime = Integer Source

fromElapsedTime :: ElapsedTime -> Integer Source

toElapsedTime :: Integer -> ElapsedTime Source

type Tempo = Int Source

fromTempo :: Tempo -> Int Source

toTempo :: Int -> Tempo Source

explicitNoteOff :: T -> T Source

Convert all `NoteOn p 0` to `NoteOff p 64`. The latter one is easier to process.

implicitNoteOff :: T -> T Source

Convert all `NoteOff p 64` to `NoteOn p 0`. The latter one can be encoded more efficiently using the running status.

getTracks :: T -> [Track]Source

mergeTracks :: C time => Type -> [T time event] -> T time eventSource

Merge all tracks into a single track according to the MIDI file type.

secondsFromTicks :: Division -> T ElapsedTime T -> T Rational T Source

Process and remove all `SetTempo` events. The result is an event list where the times are measured in seconds.

ticksPerQuarterNote :: Division -> Tempo Source

showLines :: T -> String Source

Deprecated: only use this for debugging

Show the `T` with one event per line, suited for comparing MIDIFiles with `diff`. Can this be replaced by `showFile`?

changeVelocity :: Double -> T -> T Source

Deprecated: only use this for debugging

A hack that changes the velocities by a rational factor.

resampleTime :: Double -> T -> T Source

Deprecated: only use this for debugging

Change the time base.

showEvent :: T -> ShowS Source

Deprecated: only use this for debugging

showTime :: ElapsedTime -> ShowS Source

Deprecated: only use this for debugging

sortEvents :: T -> T Source

Deprecated: only use this for debugging

Sort MIDI note events lexicographically. This is to make MIDI files unique and robust against changes in the computation. In principle Performance.merge should handle this but due to rounding errors in Float the order of note events still depends on some internal issues. The sample rate of MIDI events should be coarse enough to assert unique results.

progChangeBeforeSetTempo :: T -> T Source

Deprecated: only use this for debugging

Old versions of Haskore.Interface.MIDI.Write wrote `ProgramChange` and `SetTempo` once at the beginning of a file in that order. The current version supports multiple `ProgramChange`s in a track and thus a `ProgramChange` is set immediately before a note. Because of this a `ProgramChange` is now always after a `SetTempo`. For checking equivalence with old MIDI files we can switch this back.