4#include "configobject.hh"
33 Rest, C, Cis, D, Dis, E, F, Fis, G, Gis, A, Ais, B
37 Whole, Half, Quarter, Eighth, Sixteenth
59 QPair<double, unsigned int> toTone(
unsigned int bpm)
const;
64 unsigned int infer(
double frequency,
unsigned int ms,
unsigned int bpm);
77 Melody(
unsigned int bpm=100, QObject *parent =
nullptr);
99 unsigned int bpm()
const;
114 QVector<QPair<double, unsigned int>>
toTones()
const;
116 bool infer(
const QVector<QPair<double, unsigned int>> &tones);
121 const QVector<QPair<double, unsigned int>> &tones,
unsigned int bpm);
Base class for all configuration objects (channels, zones, contacts, etc).
Definition configobject.hh:40
A config item that encodes a melody.
Definition melody.hh:20
static unsigned int quantizationTimingError(const QVector< QPair< double, unsigned int > > &tones, unsigned int bpm)
Computes the absolute quantization timing error over the given melody for the given BPM.
Definition melody.cc:144
QVector< Note > _melody
The actual melody.
Definition melody.hh:127
bool copy(const ConfigItem &other)
Copies the given item into this one.
Definition melody.cc:27
QString toLilypond() const
Serializes the melody into Lilypond notation.
Definition melody.cc:101
iterator end()
Returns an iterator pointing right after the last note.
Definition melody.cc:44
void setBPM(unsigned int bpm)
Sets the BPM of the melody.
Definition melody.cc:77
Melody(unsigned int bpm=100, QObject *parent=nullptr)
Empty constructor.
Definition melody.cc:10
QVector< QPair< double, unsigned int > > toTones() const
Converts the melody to a series of tones in terms of frequency and duration in ms.
Definition melody.cc:112
bool infer(const QVector< QPair< double, unsigned int > > &tones)
Infer melody from a vector of frequeny-duration pairs.
Definition melody.cc:121
iterator begin()
Returns an iterator pointing at the first note.
Definition melody.cc:40
bool fromLilypond(const QString &melody)
Parses the Lilypond notation of the melody.
Definition melody.cc:85
QVector< Note >::const_iterator const_iterator
Const iterator over notes.
Definition melody.hh:73
const Note & operator[](size_t index) const
Element access.
Definition melody.cc:63
unsigned int bpm
The BPM of the melody.
Definition melody.hh:24
QString melody
The melody in LilyPond notation.
Definition melody.hh:26
QVector< Note >::iterator iterator
Iterator over notes.
Definition melody.hh:71
unsigned int _bpm
Holds the beats per minute.
Definition melody.hh:125
size_t count() const
Returns the number of notes (and rests) of this melody.
Definition melody.cc:58
ConfigItem * clone() const
Clones this item.
Definition melody.cc:17
Encodes a note, that is tone and duration.
Definition melody.hh:30
Duration
Note durations as fractions of a bar.
Definition melody.hh:36
Duration duration
The note duration.
Definition melody.hh:43
int octave
The octave of the note, 0 means middle.
Definition melody.hh:47
bool dotted
If true, the note/rest is dottet.
Definition melody.hh:45
Tone
Possible tone values.
Definition melody.hh:32
Tone tone
The note tone.
Definition melody.hh:41