jdkmidi class library documentation

Copyright © 2004 J.D. Koftinoff Software, Ltd.

Released under the GNU General Public License (GPL)




Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

include/jdkmidi/keysig.h

Go to the documentation of this file.
00001 /*
00002  *  libjdkmidi-2004 C++ Class Library for MIDI
00003  *
00004  *  Copyright (C) 2004  J.D. Koftinoff Software, Ltd.
00005  *  www.jdkoftinoff.com
00006  *  jeffk@jdkoftinoff.com
00007  *
00008  *  *** RELEASED UNDER THE GNU GENERAL PUBLIC LICENSE (GPL) April 27, 2004 ***
00009  *
00010  *  This program is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; either version 2 of the License, or
00013  *  (at your option) any later version.
00014  *
00015  *  This program is distributed in the hope that it will be useful,
00016  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  *  GNU General Public License for more details.
00019  *
00020  *  You should have received a copy of the GNU General Public License
00021  *  along with this program; if not, write to the Free Software
00022  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00023 */
00024 /*
00025 **  Copyright 1986 to 1998 By J.D. Koftinoff Software, Ltd.
00026 **
00027 **  All rights reserved.
00028 **
00029 **  No one may duplicate this source code in any form for any reason
00030 **  without the written permission given by J.D. Koftinoff Software, Ltd.
00031 **
00032 */
00033 
00034 #ifndef _JDKMIDI_KEYSIG_H
00035 #define _JDKMIDI_KEYSIG_H
00036 
00037 #include "jdkmidi/midi.h"
00038 
00039 namespace jdkmidi
00040 {
00041   enum MIDIAccidentalType
00042     {
00043       ACCFlat=0,
00044       ACCNatural,
00045       ACCSharp  
00046     };
00047   
00048   class MIDIKeySignature
00049     {
00050     public:
00051       
00052       MIDIKeySignature();
00053       MIDIKeySignature( const MIDIKeySignature &k );
00054       
00055       void  Reset();
00056       
00057       
00058       bool  IsMajor()     { return major;   }
00059       
00060       void  SetSharpFlats( int sf, bool maj=true )
00061         { sharp_flat=sf; major=maj; Reset();  }
00062       
00063       int GetSharpFlats()     { return sharp_flat;  }
00064       
00065       MIDIAccidentalType  GetNoteStatus( int white_note )
00066         { return state[white_note%7];   }
00067       
00068       
00069       bool  ConvertMIDINote( int in_note, int *out_note );
00070       
00071     protected:
00072       
00073       bool  ProcessWhiteNote( int in_note, int *out_note );
00074       bool  ProcessBlackNote( int in_note, int *out_note );
00075       
00076       MIDIAccidentalType  state[7];
00077       bool    use_sharps;
00078       int   sharp_flat;
00079       bool    major;
00080       
00081       static  int sharp_list[7];
00082       static  int flat_list[7];
00083       
00084       
00085     };
00086 }
00087 
00088 #endif
00089 
00090