Copyright | (c) 2012--2014, Utrecht University |
---|---|
License | LGPL-3 |
Maintainer | W. Bas de Haas <w.b.dehaas@uu.nl> |
Stability | experimental |
Portability | non-portable |
Safe Haskell | None |
Language | Haskell98 |
Summary: Functions for quantising a MidiScore
- data QMidiScore = QMidiScore {}
- data ShortestNote
- newtype GridUnit = GridUnit {}
- newtype QBins = QBins {}
- newtype QDev = QDev {}
- newtype QDevPerc = QDevPerc {}
- quantise :: MidiScore -> QMidiScore
- quantiseSafe :: ShortestNote -> MidiScore -> Either String QMidiScore
- quantiseQDevSafe :: MidiScore -> Either String QMidiScore
- avgQDev :: GridUnit -> QDev -> Int -> QDevPerc
- avgQDevQMS :: QMidiScore -> QDevPerc
- canBeQuantisedAt :: ShortestNote -> MidiScore -> Bool
- removeOverlap :: Voice -> Voice
- getMinGridSize :: ShortestNote -> MidiScore -> TPB
- qToQBins :: QMidiScore -> QBins
- toQBins :: ShortestNote -> QBins
- getNumForQBins :: QBins -> Ratio Int -> Int
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
.
The QBins
describes the number of quantisation bins per (annotated) beat
length and is generally controlled by the ShortestNote
parameter.
(see also: toQBins
)
Represents a quantisation deviation, i.e. the number of ticks that an event was moved to match the time grid.
Represents the average quantisation deviation per onset
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.
qToQBins :: QMidiScore -> QBins Source
Applies toQBins
to the ShortestNote
in a QMidiScore
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