10 #ifndef MUSIC_HPP_INCLUDED
11 #define MUSIC_HPP_INCLUDED
23 #pragma GCC diagnostic push
24 #pragma GCC diagnostic ignored "-Wall"
25 #pragma GCC diagnostic ignored "-Wextra"
26 #pragma GCC diagnostic ignored "-Wconversion"
27 #pragma GCC diagnostic ignored "-Wunused-parameter"
28 #pragma GCC diagnostic ignored "-Wsign-conversion"
29 #pragma GCC diagnostic ignored "-Wsuggest-attribute=const"
30 #pragma GCC diagnostic ignored "-Wsuggest-attribute=pure"
31 #pragma GCC diagnostic ignored "-Wstrict-overflow"
32 #pragma GCC diagnostic ignored "-Weffc++"
33 #include <boost/rational.hpp>
34 #pragma GCC diagnostic pop
97 using Fraction = boost::rational<int>;
100 #warning "Not using boost is a problem"
149 #pragma GCC diagnostic push
150 #pragma GCC diagnostic ignored "-Weffc++"
228 std::ostream& operator <<(std::ostream& o, const
Pitch& n);
244 std::istream& operator >>(std::istream& i,
Pitch& n);
278 static unsigned noteToHalfTone(
const CompleteNoteName& n) __attribute__((
const));
281 #pragma GCC diagnostic pop
329 Measure(
bool binary =
true,
unsigned duration = 4);
345 unsigned getDuration() const __attribute__((pure));
353 void changeDuration(
unsigned d);
358 bool isBinary() const __attribute__((pure));
365 void setBinary(
bool b);
396 bool operator==(const
Measure& o) const __attribute__((pure));
402 bool operator!=(const
Measure& o) const __attribute__((pure));
420 std::ostream& operator <<(std::ostream& o, const
Measure& m);
430 std::istream& operator >>(std::istream& i,
Measure& m);
454 std::vector<CompleteNoteName> getNotes()
const;
466 bool operator==(
const Key& k)
const __attribute__((pure));
472 bool operator!=(
const Key& k)
const __attribute__((pure));
484 std::ostream&
operator <<(std::ostream& o,
const Key& k);
494 Key
readKey(
const std::string& str);
542 std::vector<CompleteNoteName> getNotes() const __attribute__((pure));
558 bool operator==(const
Chord& o) const __attribute__((pure));
563 bool operator!=(const
Chord& o) const __attribute__((pure));
565 using ChordID =
unsigned;
566 explicit
Chord(ChordID
id);
567 explicit operator ChordID() const;
568 static const
unsigned nbChords = 6*4*12;
569 static const std::vector<CompleteNoteName>& getNotes(ChordID c);
580 std::ostream& operator <<(std::ostream& o, const
Chord& c);
640 Melody(
const std::vector<Measure>& v,Key k,
unsigned tempo = 120);
645 Melody(
const Key& k = Key(NoteName::C));
653 std::vector<Measure> convertToMeasures() const __attribute__((pure));
658 const Key& getKey() const __attribute__((pure));
677 unsigned size() const;
685 Melody transpose(const Key& k) const;
690 bool isBinary() const;
696 bool operator==(const Melody& o) const __attribute__((pure));
701 bool operator!=(const Melody& o) const __attribute__((pure));
708 std::ostream& createABCChordFile(std::ostream& out, const
ChordProgression& chords) const;
712 std::vector<
Measure> m_measures;
727 std::ostream& operator <<(std::ostream& o, const Melody& m);
738 #endif // MUSIC_HPP_INCLUDED
Pitch & operator-=(int nb)
Substract half tones to pitch.
ChordType m_type
Type of the chord.
Definition: Music.hpp:536
ChordProgression readChordProgression(const std::string &str)
parser for ChordProgression The format is as follows : Chord1;Chord2;...LastChord; ...
bool operator==(const CompleteNoteName &o) const __attribute__((pure))
Comparison operator for CompleteNoteName.
Accidental m_modifier
Accidental of the note (sharp, flat,none)
Definition: Music.hpp:109
Chord readChord(const std::string &s)
parser for chord The format follows the guitar chord format
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
Melody readMelody(const std::string &str)
parser for Melody The format is the ABC format. We ignore |, :, >, ... when reading something that is...
Pitch operator-(int nb) const __attribute__((pure))
Creates new Pitch by substracting nb half tones to this one.
boost::rational< int > Fraction
Fraction class to easily manipulate fractions of beats, measures,...
Definition: Music.hpp:98
Fraction m_duration
Hold the duration of the chord, in fraction of the bar it is played in. SHOULD BE DELETED ...
Definition: Music.hpp:523
Means that we use the natural note (no accidental)
NoteName
Describe the name of the note.
Definition: Music.hpp:43
ChordProgression moveCP(const ChordProgression &cp, int i, const Key &k)
change the base notes of a chord progression
Fraction m_duration
Duration of the note, as a fraction of a beat.
Definition: Music.hpp:251
CompleteNoteName getNoteName() const __attribute__((pure))
Returns the name of the note, ommiting the octave.
CompleteNoteName m_base
Name of the base name of the note.
Definition: Music.hpp:524
Describes a melody.
Definition: Music.hpp:629
std::map< Position, Note >::const_iterator ConstIterator
Allows to iterate on the notes of the measure.
Definition: Music.hpp:318
std::istream & operator>>(std::istream &i, NoteName &n)
input operator for NoteName The format is capital or small letters for the NoteName ...
Describe a note with its absolute pitch.
Definition: Music.hpp:153
NoteName m_name
Name of the note (C,D,...)
Definition: Music.hpp:108
Pitch operator+(int nb) const __attribute__((pure))
Creates new Pitch by adding nb half tones to this one.
bool operator==(const Pitch &o) const __attribute__((pure))
Comparison operator for Pitch done.
Describe a chord.
Definition: Music.hpp:502
Describe the key of a melody.
Definition: Music.hpp:438
CompleteNoteName m_base
Base note of the key.
Definition: Music.hpp:440
NoteName m_mode
Mode of the key.
Definition: Music.hpp:441
std::vector< Chord > ChordProgression
ChordProgression is the class used to give the set of chords used.
Definition: Music.hpp:592
bool operator!=(const Pitch &o) const __attribute__((pure))
Difference operator for Pitch done.
Octave m_octave
octave of the note (absolute height of the note)
Definition: Music.hpp:155
Fully describes a note (name + accidental)
Definition: Music.hpp:106
ChordType
Describes the type of the third note in the chord.
Definition: Music.hpp:514
SeventhType m_seventh
if it's not None, the seventh is added according to this value (Dim = double Flat) ...
Definition: Music.hpp:535
CompleteNoteName(NoteName n=NoteName::C, Accidental mod=Accidental::None)
Constructor for CompleteNoteName.
Describe a musical bar.
Definition: Music.hpp:312
std::ostream & operator<<(std::ostream &o, NoteName n)
output operator for NoteName The format is capital letters for the NoteName
bool operator!=(const CompleteNoteName &o) const __attribute__((pure))
Difference operator for CompleteNoteName.
Fraction Position
The Position type is a Fraction of Measure.
Definition: Music.hpp:317
SeventhType
Describes the Type of the fourth note of the chord.
Definition: Music.hpp:528
Pitch & operator+=(int nb)
Adds half tones to pitch.
Pitch(const CompleteNoteName &n, Octave o=4)
Construtor for Pitch with a CompleteNotename.
Describe a note as a musical event (pitch + duration)
Definition: Music.hpp:249
Accidental
Describe the accidental of the note.
Definition: Music.hpp:70
unsigned Octave
Octave 4 is A 440Hz.
Definition: Music.hpp:95
std::vector< Measure >::const_iterator ConstIterator
Allows to iterate on the measures of the Melody.
Definition: Music.hpp:633
Means that we add a semitone.
Means that we subtract a semitone.