Programming Details
Classes and Functions
class Note
{
private :
int midiNote; // values 1 to 127; 0 reserved for "undefined"
char dynamic; // ppp=1-16, pp=17-31, p=32-47, mp=48-63 mf=64-79, f=80-95, ff=96-111, fff=112-127; 0 reserved for "undefined or Niente"
char rythmicValue; // 1= whole, 2=half, 4= qtr, 8=8th, 16=16th...; 0 reserved for "undefined"
char pitch; // vales 'A' to 'G', 0 reserved for "undefined"
char accidental; // 'n' = natural; 's' = sharp; 't' = double sharp; 'f' = flat; 'e' = double flat; 0 reserved for "no accidental"
unsigned int octave; // values 1 to 10; 0 reserved for "undefined"
unsigned int scaleDegree; // values 1 to 12; 0 reserved for "undefined"
public :
Note(); // default constructor
Note(Key &, unsigned int , unsigned int ); // arguments are Key, scale degree and octave (for range)
~Note(); // destructor
void setMidiNote( int );
void setDynamic( char );
void setRythmicValue( char );
void setPitch( char );
void setAccidental( char );
void setOctave( unsigned int );
void setScaleDegree( unsigned int );
int getMidiNote() const ;
char getDynamic() const ;
char getRythmicValue() const ;
char getPitch() const ;
char getAccidental() const ;
unsigned int getOctave() const ;
unsigned int getScaleDegree() const ;
void printAllProperties() const ;
void printMusicalProperties() const ;
void printPitch() const ;
};
class Key
{
private :
char pitches[ 7 ]; // 7 diatonic pitches of a key signature
char accidentals[ 7 ]; // 7 related accidentals of that key (natural when no accidental)
bool isMajor; // key quality
public :
Key();
Key( char , char , bool );
~Key();
void setPitches( char ); // argument is the tonic pitch
void setAccidentals( char ); // argument is the tonic accidental
char getPitch( unsigned int ) const ; // returns the pitch name of specified scale degree
char getAccidental( unsigned int ) const ; // returns the accidental of specified scale degree
bool getQuality() const ;
void printKeyName() const ;
};
class Chord
{
private :
Note chord[ 4 ]; // the 4 notes of the chord
unsigned int rootScaleDegree; // scale degree of the root of the chord (values 1 to 7)
Quality quality; // quality of the chord (Major, Minor, Diminished, etc...)
bool isSeventhChord; // whether the chord is 7th or not
Inversion inversion; // inversion of the chord
public :
Chord ();
Chord( unsigned int , Quality, bool , Inversion, Key &);
~Chord();
void buildChord(Key &); // main algorithm that builds the chord
unsigned int getRootScaleDegree() const ;
Inversion getInversion() const ;
Note getNote( unsigned int ) const ; //argument is the index of the note in the chord (0-3)
void printRomanChordName() const ;
void printChordMusicalProperties() const ;
void printAllProperties() const ;
};
class Progression
{
private :
unsigned int numChords; // the number of chords in the chord progression
std::vector<HarmonicFunction> harmonicFunctions; // vector will hold harmonic function for each chord of the progression
std::vector<Chord> chordProgression; // vector of chords
public :
Progression();
Progression(Key &, unsigned int ); // arguments are key signature and number of chords in the chord progression
~Progression();
Chord getChord( unsigned int ) const ; // argument is the index within the progression
unsigned int getNumChords() const ;
void generateTonic( unsigned int , Key &); // function that randomly generate chords of the Tonic family
void generatePredominant( unsigned int , Key &); // function that randomly generate chords of the Predominant family
void generateDominant( unsigned int index, Key &k); // function that randomly generate chords of the Dominant family
};
|