zmidi-score-0.3.0.0: Representing MIDI a simple score.

Copyright(c) 2012--2014, Utrecht University
LicenseLGPL-3
MaintainerW. Bas de Haas <w.b.dehaas@uu.nl>
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell98

ZMidi.Score.Quantise

Contents

Description

Summary: Functions for quantising a MidiScore

Synopsis

Quantisation specific datatypes

data QMidiScore Source

QMidiScore wraps around a MidiScore and stores some additional information about the quantisation process.

data ShortestNote Source

The ShortestNote determines the minimal grid length of a quantised QMidiScore, when quantised with quantise.

newtype GridUnit Source

The GridUnit describes the minimal length of a quantised event and is controlled by the number of QBins

Constructors

GridUnit 

Fields

gridUnit :: Int
 

newtype QBins Source

The QBins describes the number of quantisation bins per (annotated) beat length and is generally controlled by the ShortestNote parameter. (see also: toQBins )

Constructors

QBins 

Fields

qbins :: Int
 

newtype QDev Source

Represents a quantisation deviation, i.e. the number of ticks that an event was moved to match the time grid.

Constructors

QDev 

Fields

qDev :: Int
 

newtype QDevPerc Source

Represents the average quantisation deviation per onset

Constructors

QDevPerc 

Fields

qDevPerc :: Double
 

Quantisation functions

quantise :: MidiScore -> QMidiScore Source

Quantises a MidiScore snapping all events to a ShortestNote grid.

quantiseSafe :: ShortestNote -> MidiScore -> Either String QMidiScore Source

Quantises a MidiScore snapping all events to a ShortestNote grid. The absolute size of the grid is based on the GridUnit, which is the ticksPerBeat divided by the number of quantization bins per beat. Besides the quantised MidiScore and the GridUnit also the cumulative deviation from the grid is returned.

quantiseQDevSafe :: MidiScore -> Either String QMidiScore Source

Quantises a MidiScore or returns a warning if the quantisation deviation exceeds the acceptableQuantisationDeviation.

Utilities

avgQDevQMS :: QMidiScore -> QDevPerc Source

calculating the average quantisation deviation

canBeQuantisedAt :: ShortestNote -> MidiScore -> Bool Source

Returns true if the number of ticks per beat can be divided by the maximal number of quantisation bins.

removeOverlap :: Voice -> Voice Source

Although quantise also quantises the duration of NoteEvents, it can happen that melody notes do still overlap. This function removes the overlap N.B. This function is designed only for monophonic melodies, it does not work on a polyphonic score.

getMinGridSize :: ShortestNote -> MidiScore -> TPB Source

Returns the minimal grid size of a MidiScore if it has been quantised. This is the ticksPerBeat divided by the number of quantisation bins. N.B. this function does not check whether a file is quantised.

toQBins :: ShortestNote -> QBins Source

takes the quantisation granularity parameter ShortestNote and returns a the GridUnit that the beat length should be divided by. The resulting value we name GridUnit; it describes the minimal length of an event.

getNumForQBins :: QBins -> Ratio Int -> Int Source

Returns the numerator of a Ratio given a certain QBins as denominator. The standard Ratio implementation simplifies the Ration, e.g. 3 % 12 is converted into 1 % 4. This function reverses that process:

>>> getNumForQBins 12 (1 % 4)
>>> 3
>>> getNumForQBins 12 (1 % 1)
>>> 12