Generate an accompaniement for a given melody
|
This file defines all the data structures related to music objects. More...
#include <map>
#include <vector>
#include <climits>
#include <iostream>
#include <stdexcept>
#include <cassert>
#include <functional>
#include <boost/rational.hpp>
Go to the source code of this file.
Classes | |
struct | CompleteNoteName |
Fully describes a note (name + accidental) More... | |
struct | Pitch |
Describe a note with its absolute pitch. More... | |
struct | Note |
Describe a note as a musical event (pitch + duration) More... | |
class | Measure |
Describe a musical bar. More... | |
struct | Key |
Describe the key of a melody. More... | |
struct | Chord |
Describe a chord. More... | |
class | Melody |
Describes a melody. More... | |
Typedefs | |
using | Octave = unsigned |
Octave 4 is A 440Hz. | |
using | Fraction = boost::rational< int > |
Fraction class to easily manipulate fractions of beats, measures,... | |
using | ChordProgression = std::vector< Chord > |
ChordProgression is the class used to give the set of chords used. | |
Enumerations | |
enum | NoteName { C, D, E, F, G, A, B } |
Describe the name of the note. More... | |
enum | Accidental { Accidental::Flat, Accidental::Sharp, Accidental::None } |
Describe the accidental of the note. More... | |
Functions | |
std::ostream & | operator<< (std::ostream &o, NoteName n) |
output operator for NoteName The format is capital letters for the NoteName More... | |
std::istream & | operator>> (std::istream &i, NoteName &n) |
input operator for NoteName The format is capital or small letters for the NoteName More... | |
std::ostream & | operator<< (std::ostream &o, Accidental a) |
output operator for Accidental The format is ^ for sharp, _ for flat and nothing for none More... | |
std::istream & | operator>> (std::istream &i, Accidental &a) |
input operator for Accidental The format is ^ for sharp, _ for flat and nothing or = for none More... | |
std::ostream & | operator<< (std::ostream &o, const CompleteNoteName &n) |
output operator for CompleteNoteName The format is as follow : the modifier (if any) followed by the NoteName More... | |
std::istream & | operator>> (std::istream &i, CompleteNoteName &n) |
input operator for CompleteNoteName The format is as follow : the modifier (if any) followed by the NoteName More... | |
std::ostream & | operator<< (std::ostream &o, const Pitch &n) |
output operator for Pitch The format is as follow : the CompleteNoteName followed by (Octave-4) ' or (4-Octave) , Without specification, a note is assumed to be in the forth octave. The string "A" thus refer to a A 440Hz. From this reference, one can add or subtract octave. The character "'" corresponds to the addition of one octave, and "," to the subtraction. For example, "_G,," represents a G flat in the second octave (4-2) and "B'''" represents a B in the seventh octave (4+3) More... | |
std::istream & | operator>> (std::istream &i, Pitch &n) |
input operator for Pitch The format is as follow : the CompleteNoteName followed by (Octave-4) ' or (4-Octave) , Without specification, a note is assumed to be in the forth octave. The string "A" thus refer to a A 440Hz. From this reference, one can add or subtract octave. The character "'" corresponds to the addition of one octave, and "," to the subtraction. For example, "_G,," represents a G flat in the second octave (4-2) and "B'''" represents a G in the seventh octave (4+3) If the pitch is A,,,,,, which does not exist, the parsing stops at A,,,, as any standard operator >> behaves More... | |
std::ostream & | operator<< (std::ostream &o, const Note &n) |
output operator for Note The format is as follow : the Pitch followed by num/denom where num/denom is the fraction of beat. If num or denum is 1, they do not appear. More... | |
std::istream & | operator>> (std::istream &i, Note &n) |
input operator for Note The format is as follow : the Pitch followed by the fraction of beat. If the denominator is not given, it is supposed to be 2. The details of the possibilities are given in the ABC notations. The web page of the examples is http://abcnotation.com/examples#Note-lengths More... | |
std::ostream & | operator<< (std::ostream &o, const Measure &m) |
output operator for Measure The format is as follows : The notes, separated by spaces. Silences are written zFractionofbeat More... | |
std::istream & | operator>> (std::istream &i, Measure &m) |
input operator for Measure The format is as follows : The notes, separated by spaces (or not). Silences are written zFractionofbeat More... | |
std::ostream & | operator<< (std::ostream &o, const Key &k) |
output operator for Key The format is as shown in ABC notation Link is : http://abcnotation.com/wiki/abc:standard:v2.1#kkey More... | |
Key | readKey (const std::string &str) |
input parser for Key The format is as shown in ABC notation Link is : http://abcnotation.com/wiki/abc:standard:v2.1#kkey More... | |
std::ostream & | operator<< (std::ostream &o, const Chord &c) |
output operator for Chord More... | |
Chord | readChord (const std::string &s) |
parser for chord The format follows the guitar chord format More... | |
std::ostream & | operator<< (std::ostream &o, const ChordProgression &c) |
output operator for ChordProgression The format is as follows : Chord1;Chord2;...LastChord; More... | |
ChordProgression | readChordProgression (const std::string &str) |
parser for ChordProgression The format is as follows : Chord1;Chord2;...LastChord; More... | |
ChordProgression | moveCP (const ChordProgression &cp, int i, const Key &k) |
change the base notes of a chord progression More... | |
std::ostream & | operator<< (std::ostream &o, const Melody &m) |
output operator for Melody The format is as follows : M : 4/4 if binary, M : 12/8 if not K : Key L : 1/4 Measure1 | Measure2 | ... More... | |
Melody | readMelody (const std::string &str) |
parser for Melody The format is the ABC format. We ignore |, :, >, ... when reading something that is not a header More... | |
This file defines all the data structures related to music objects.
|
strong |
|
strong |
Describe the name of the note.
The name is given in the english notation, where C == Do
ChordProgression moveCP | ( | const ChordProgression & | cp, |
int | i, | ||
const Key & | k | ||
) |
change the base notes of a chord progression
i | is the number of half tones to add |
cp | is the chordprogression to change |
k | is the key in which we transpose the chord progression |
std::ostream& operator<< | ( | std::ostream & | o, |
NoteName | n | ||
) |
output operator for NoteName The format is capital letters for the NoteName
o | the stream to write in |
n | the NoteName to write |
std::ostream& operator<< | ( | std::ostream & | o, |
Accidental | a | ||
) |
output operator for Accidental The format is ^ for sharp, _ for flat and nothing for none
o | the stream to write in |
a | the Accidental to write |
std::ostream& operator<< | ( | std::ostream & | o, |
const CompleteNoteName & | n | ||
) |
output operator for CompleteNoteName The format is as follow : the modifier (if any) followed by the NoteName
o | the stream to write in |
n | the CompleteNoteName to write |
std::ostream& operator<< | ( | std::ostream & | o, |
const Pitch & | n | ||
) |
output operator for Pitch The format is as follow : the CompleteNoteName followed by (Octave-4) ' or (4-Octave) , Without specification, a note is assumed to be in the forth octave. The string "A" thus refer to a A 440Hz. From this reference, one can add or subtract octave. The character "'" corresponds to the addition of one octave, and "," to the subtraction. For example, "_G,," represents a G flat in the second octave (4-2) and "B'''" represents a B in the seventh octave (4+3)
o | the stream to write in |
n | the Pitch to write |
std::ostream& operator<< | ( | std::ostream & | o, |
const Note & | n | ||
) |
std::ostream& operator<< | ( | std::ostream & | o, |
const Measure & | m | ||
) |
std::ostream& operator<< | ( | std::ostream & | o, |
const Key & | k | ||
) |
output operator for Key The format is as shown in ABC notation Link is : http://abcnotation.com/wiki/abc:standard:v2.1#kkey
o | the stream to write in |
k | the Key to write |
std::ostream& operator<< | ( | std::ostream & | o, |
const Chord & | c | ||
) |
std::ostream& operator<< | ( | std::ostream & | o, |
const ChordProgression & | c | ||
) |
output operator for ChordProgression The format is as follows : Chord1;Chord2;...LastChord;
o | the stream to write in |
c | the ChordProgression to write |
std::ostream& operator<< | ( | std::ostream & | o, |
const Melody & | m | ||
) |
std::istream& operator>> | ( | std::istream & | i, |
NoteName & | n | ||
) |
input operator for NoteName The format is capital or small letters for the NoteName
i | the stream to read from |
n | the NoteName to write in |
std::domain_error | if not a NoteName |
std::istream& operator>> | ( | std::istream & | i, |
Accidental & | a | ||
) |
input operator for Accidental The format is ^ for sharp, _ for flat and nothing or = for none
i | the stream to read from |
a | the Accidental to write in |
std::istream& operator>> | ( | std::istream & | i, |
CompleteNoteName & | n | ||
) |
input operator for CompleteNoteName The format is as follow : the modifier (if any) followed by the NoteName
i | the stream to read from |
n | the CompleteNoteName to write in |
std::istream& operator>> | ( | std::istream & | i, |
Pitch & | n | ||
) |
input operator for Pitch The format is as follow : the CompleteNoteName followed by (Octave-4) ' or (4-Octave) , Without specification, a note is assumed to be in the forth octave. The string "A" thus refer to a A 440Hz. From this reference, one can add or subtract octave. The character "'" corresponds to the addition of one octave, and "," to the subtraction. For example, "_G,," represents a G flat in the second octave (4-2) and "B'''" represents a G in the seventh octave (4+3) If the pitch is A,,,,,, which does not exist, the parsing stops at A,,,, as any standard operator >> behaves
i | the stream to read from |
n | the Pitch to write in |
std::istream& operator>> | ( | std::istream & | i, |
Note & | n | ||
) |
input operator for Note The format is as follow : the Pitch followed by the fraction of beat. If the denominator is not given, it is supposed to be 2. The details of the possibilities are given in the ABC notations. The web page of the examples is http://abcnotation.com/examples#Note-lengths
i | the stream to read from |
n | the Note to write in |
std::istream& operator>> | ( | std::istream & | i, |
Measure & | m | ||
) |
Chord readChord | ( | const std::string & | s | ) |
parser for chord The format follows the guitar chord format
s | the string to parse |
std::runtime_error |
ChordProgression readChordProgression | ( | const std::string & | str | ) |
parser for ChordProgression The format is as follows : Chord1;Chord2;...LastChord;
str | the string to read from |
std::runtime_error |
Key readKey | ( | const std::string & | str | ) |
input parser for Key The format is as shown in ABC notation Link is : http://abcnotation.com/wiki/abc:standard:v2.1#kkey
str | the string to read from |
std::runtime_error |