libdrmconf  0.11.3
A library to program DMR radios.
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
Melody::Note Struct Reference

Encodes a note, that is tone and duration. More...

#include <melody.hh>

Public Types

enum class  Tone {
  Rest , C , Cis , D ,
  Dis , E , F , Fis ,
  G , Gis , A , Ais ,
  B
}
 Possible tone values.
 
enum class  Duration {
  Whole , Half , Quarter , Eighth ,
  Sixteenth
}
 Note durations as fractions of a bar.
 

Public Member Functions

 Note ()
 Default constructor. More...
 
bool fromLilypond (const QString &note, Duration currentDuration)
 Reads a note in Lilypond notation.
 
QString toLilypond (Duration currentDuration) const
 Serializes the note in Lilypond notation.
 
QPair< double, unsigned int > toTone (unsigned int bpm) const
 Converts the note to a frequency in Hz and duration in seconds.
 
unsigned int infer (double frequency, unsigned int ms, unsigned int bpm)
 Infers the note from the given frequency and duration in ms. More...
 

Static Public Member Functions

static unsigned int quantizationTimingError (unsigned int ms, unsigned int bpm)
 Computes the quantization timing error for the given duration and BPM.
 

Public Attributes

Tone tone
 The note tone.
 
Duration duration
 The note duration.
 
bool dotted
 If true, the note/rest is dottet.
 
int octave
 The octave of the note, 0 means middle.
 

Detailed Description

Encodes a note, that is tone and duration.

Constructor & Destructor Documentation

◆ Note()

Melody::Note::Note ( )

Default constructor.

A middle C quarter note.

Member Function Documentation

◆ infer()

unsigned int Melody::Note::infer ( double  frequency,
unsigned int  ms,
unsigned int  bpm 
)

Infers the note from the given frequency and duration in ms.

This is guesswork, consequently there will be some issues. The function updates the note and returns the timing error in ms.


The documentation for this struct was generated from the following files: