Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
Assetto armonico - note.h

note.h

Caricato da: AldoBaldo
Scarica il programma completo

  1. #ifndef NOTA_H
  2. #define NOTA_H
  3.  
  4. /*==============================================================================
  5. CLASSI NOTA E SCALA, di Aldo Carpanelli, maggio 2016
  6.  
  7. Questo file riguarda DUE classi principali, la classe NOTA e la classe SCALA,
  8. piu' due classi "ausiliarie" vuote, per la segnalazione degli errori, NOTA_Err e
  9. SCALA_Err.
  10. ==============================================================================*/
  11.  
  12.  
  13. #include "stdio.h"
  14.  
  15.  
  16. // ===> CLASSI NOTA_Err e NOTA <================================================
  17.  
  18. class NOTA_Err{};
  19.  
  20. class NOTA {
  21.     public:
  22.         NOTA() { Imposta( 3, 0, 0 ); }
  23.         NOTA( char ottava, char nota, char alterazione )
  24.             { if( !Imposta(ottava,nota,alterazione) ) throw NOTA_Err(); }
  25.         NOTA( char midi ) { if( !Imposta(midi) ) throw NOTA_Err(); }
  26.  
  27.         bool Imposta( char ottava, char nota, char alterazione );
  28.         bool Imposta( char midi );
  29.  
  30.         char Ottava() { return o; }
  31.         char Nota() { return n; }
  32.         char Alterazione() { return a; }
  33.         char Midi();
  34.  
  35.         bool NotaValida();
  36.  
  37.         const char *Str();
  38.  
  39.         const NOTA& operator ++();   // prefissa
  40.         const NOTA operator ++(int); // postfissa
  41.         const NOTA& operator --();   // prefissa
  42.         const NOTA operator --(int); // postfissa
  43.         NOTA& operator +=( int n );
  44.         NOTA& operator -=( int n );
  45.         const NOTA operator +( int n );
  46.         const NOTA operator -( int n );
  47.         bool operator==(const NOTA& right);
  48.         bool operator!=(const NOTA& right);
  49.         bool operator<(const NOTA& right);
  50.         bool operator>(const NOTA& right);
  51.  
  52.     protected:
  53.  
  54.     private:
  55.         char o; // ottava
  56.         char n; // nota
  57.         char a; // alterazione
  58.         char f; // "filler", inutilizzato
  59. };
  60.  
  61.  
  62. // ===> CLASSI SCALA_Err e SCALA <==============================================
  63.  
  64. class SCALA_Err{};
  65.  
  66. class SCALA{
  67.     public:
  68.         SCALA();
  69.         SCALA( char nota, char alterazione, char schema[7] );
  70.         SCALA( char midi, char schema[7] );
  71.  
  72.         bool Imposta( char nota, char alterazione, char schema[7] );
  73.         bool Imposta( char midi, char schema[7] );
  74.         NOTA Grado( int grado ) { return g[grado%7]; }
  75.         char GradoMidi( int grado ) { return g[grado%7].Midi(); }
  76.         void Triade( int grado, NOTA *nn );
  77.  
  78.         const char *Str();
  79.  
  80.     protected:
  81.  
  82.     private:
  83.         NOTA g[7];
  84. };
  85.  
  86.  
  87. // ===> FUNZIONI NON MEMBRO <===================================================
  88.  
  89. bool DatiValidi( char ottava, char nota, char alterazione );
  90. void OttavaVisibile( bool ottavaVisibile );
  91.  
  92. #endif // NOTA_H