// Note: Instrumentation statements are highlighted in green 

#ifndef __NOTE_HPP
#define __NOTE_HPP

#include <stl\vvector>
#include <vutility.hpp>

using namespace std;
using namespace visibility;

///////////////////////////////////////////////////////////////////////////////
// Status flags key flags and scale flags
///////////////////////////////////////////////////////////////////////////////

const unsigned short ROOT        = 0x0001;
const unsigned short IS_VALID    = 0x0002;

const unsigned short E_KEY       = 0x0001;
const unsigned short F_KEY       = 0x0002;
const unsigned short FG_KEY      = 0x0004;
const unsigned short G_KEY       = 0x0008;
const unsigned short GA_KEY      = 0x0010;
const unsigned short A_KEY       = 0x0020;
const unsigned short AB_KEY      = 0x0040;
const unsigned short B_KEY       = 0x0080;
const unsigned short C_KEY       = 0x0100;
const unsigned short CD_KEY      = 0x0200;
const unsigned short D_KEY      = 0x0400;
const unsigned short DE_KEY      = 0x0800;
const unsigned short ALL_KEYS   = 0x0fff;

const unsigned short ALL_NOTES          = 0x0001;
const unsigned short MAJOR               = 0x0002;
const unsigned short MINOR               = 0x0004;
const unsigned short MAJOR_PENTATONIC   = 0x0008;
const unsigned short MINOR_PENTATONIC   = 0x0010;
const unsigned short BLUES              = 0x0020;
const unsigned short ALL_SCALES          = 0x003F;


///////////////////////////////////////////////////////////////////////////////
// Bitset definitions
///////////////////////////////////////////////////////////////////////////////

VBITSET_START(NoteStatus)
VINCLUSIVE_VALUE(ROOT, "Root", 0)
VINCLUSIVE_VALUE(IS_VALID, "Is valid", 0)
VBITSET_END

VBITSET_START(KeyFlags)
VEXCLUSIVE_VALUE(E_KEY, ALL_KEYS, "E", 0)
VEXCLUSIVE_VALUE(F_KEY, ALL_KEYS, "F", 0)
VEXCLUSIVE_VALUE(FG_KEY, ALL_KEYS, "F#/Gb", 0)
VEXCLUSIVE_VALUE(G_KEY, ALL_KEYS, "G", 0)
VEXCLUSIVE_VALUE(GA_KEY, ALL_KEYS, "G#/Ab", 0)
VEXCLUSIVE_VALUE(A_KEY, ALL_KEYS, "A", 0)
VEXCLUSIVE_VALUE(AB_KEY, ALL_KEYS, "A#/Bb", 0)
VEXCLUSIVE_VALUE(B_KEY, ALL_KEYS, "B", 0)
VEXCLUSIVE_VALUE(C_KEY, ALL_KEYS, "C", 0)
VEXCLUSIVE_VALUE(CD_KEY, ALL_KEYS, "C#/Db", 0)
VEXCLUSIVE_VALUE(D_KEY, ALL_KEYS, "D", 0)
VEXCLUSIVE_VALUE(DE_KEY, ALL_KEYS, "D#/Eb", 0)
VBITSET_END

VBITSET_START(ScaleFlags)
VEXCLUSIVE_VALUE(ALL_NOTES, ALL_SCALES, "All notes", 0)
VEXCLUSIVE_VALUE(MAJOR, ALL_SCALES, "Major", 0)
VEXCLUSIVE_VALUE(MINOR, ALL_SCALES, "Minor", 0)
VEXCLUSIVE_VALUE(MAJOR_PENTATONIC, ALL_SCALES, "Major Pentatonic", 0)
VEXCLUSIVE_VALUE(MINOR_PENTATONIC, ALL_SCALES, "Minor Pentatonic", 0)
VEXCLUSIVE_VALUE(BLUES, ALL_SCALES, "Blues", 0)
VBITSET_END

///////////////////////////////////////////////////////////////////////////////
// Note class
///////////////////////////////////////////////////////////////////////////////

class Note : public VObject  // Add VObject to the inheritance chain
{
DECLARE_VISIBILITY(Note)  // Instrumentation statement

public:    // data
  string relativeName;
  string absoluteName;
  unsigned short midiNumber;
  unsigned short frequency;
  unsigned short status;

public:    // functions
  Note(void);
  Note(char * relative_name, char * absolute_name, unsigned short midi_number, unsigned short _frequency, unsigned short _status = IS_VALID);
  Note(const Note & note);
  virtual ~Note(void);
  Note & operator=(const Note &note);
  bool operator==(const Note &note) const;

};
DECLARE_VISIBILITY_CREATOR(Note) // Instrumentation statement

///////////////////////////////////////////////////////////////////////////////
// MusicalNoteTable class
///////////////////////////////////////////////////////////////////////////////

typedef vvector<Note> NoteVector;

class MusicalNoteTable : public VObject // Add VObject to the inheritance chain
{
DECLARE_VISIBILITY(MusicalNoteTable)  // Instrumentation statement

public:    // data

  NoteVector noteTable;
  typedef NoteVector::iterator iterator;

public:    // functions
  MusicalNoteTable(void);
  MusicalNoteTable(const MusicalNoteTable & note);
  virtual ~MusicalNoteTable(void);
  MusicalNoteTable & operator=(const MusicalNoteTable &note);
  iterator GetNoteIterator(Note & a_note);
  Note * GetAbsoluteNote(char * note_name);
  iterator GetRelativeNoteIterator(char * note_name);
  void CreateValidNoteVector(unsigned short scale_flags, unsigned short key_flags, NoteVector & valid_notes);
  bool IsValidNote(Note & a_note, NoteVector & valid_notes);
  bool IsRootNote(Note & a_note, NoteVector & valid_notes);

};
DECLARE_VISIBILITY_CREATOR(MusicalNoteTable)  // Instrumentation statement

#endif // __NOTE_HPP



Copyright 2002-2007 Outerface Technologies, Inc.