Generate an accompaniement for a given melody
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Melody Class Reference

Describes a melody. More...

#include <Music.hpp>

Public Types

using ConstIterator = std::vector< Measure >::const_iterator
 Allows to iterate on the measures of the Melody.
 

Public Member Functions

 Melody (const std::vector< Measure > &v, Key k, unsigned tempo=120)
 Constructor with initializations. More...
 
 Melody (const Key &k=Key(NoteName::C))
 Creates an empty melody.
 
std::vector< MeasureconvertToMeasures () const __attribute__((pure))
 Returns the measures of the melody. More...
 
const KeygetKey () const __attribute__((pure))
 
ConstIterator begin () const __attribute__((pure))
 Returns a measure iterator at the beginning of the Melody. More...
 
ConstIterator end () const __attribute__((pure))
 Returns a measure iterator at the end of the Melody. More...
 
unsigned size () const
 Returns The number of measures in the Melody. More...
 
Melody transpose (const Key &k) const
 Transpose a melody into a given key. More...
 
bool isBinary () const
 returns if the melody is binary (looks at first measure) More...
 
bool operator== (const Melody &o) const __attribute__((pure))
 Equality operator for Melody. More...
 
bool operator!= (const Melody &o) const __attribute__((pure))
 Inequality operator for Melody. More...
 
std::ostream & createABCChordFile (std::ostream &out, const ChordProgression &chords) const
 Adds a Chord Progression to a file. More...
 

Public Attributes

unsigned m_BPM
 

Detailed Description

Describes a melody.

A melody is simply a set of bars. Invariants such as key may be checked (although they are by no means required) Carefull : If some notes of the key are sharp, you still need to put Accidental::Sharp in these notes.

Constructor & Destructor Documentation

Melody::Melody ( const std::vector< Measure > &  v,
Key  k,
unsigned  tempo = 120 
)

Constructor with initializations.

Parameters
vThe vector of measures composing the melody
kThe key of the melody

Member Function Documentation

ConstIterator Melody::begin ( ) const

Returns a measure iterator at the beginning of the Melody.

Note
done
std::vector<Measure> Melody::convertToMeasures ( ) const

Returns the measures of the melody.

Returns
A vector of measures
Note
should not be used
done
std::ostream& Melody::createABCChordFile ( std::ostream &  out,
const ChordProgression chords 
) const

Adds a Chord Progression to a file.

Parameters
outis the stream to write the ChordProgression to
chordsis the ChordProgression to add
ConstIterator Melody::end ( ) const

Returns a measure iterator at the end of the Melody.

Note
done
const Key& Melody::getKey ( ) const

Returns the key of the melody

Returns
The key of the melody
bool Melody::isBinary ( ) const

returns if the melody is binary (looks at first measure)

Exceptions
runtime_error("Unknown");
bool Melody::operator!= ( const Melody o) const

Inequality operator for Melody.

Note
done
bool Melody::operator== ( const Melody o) const

Equality operator for Melody.

Note
done
unsigned Melody::size ( ) const

Returns The number of measures in the Melody.

Returns
The number of measures in the Melody
Melody Melody::transpose ( const Key k) const

Transpose a melody into a given key.

Parameters
kThe target key
Returns
A new melody object, in key k

The documentation for this class was generated from the following file: