| 1 | /* |
|---|
| 2 | * libjdkmidi-2004 C++ Class Library for MIDI |
|---|
| 3 | * |
|---|
| 4 | * Copyright (C) 2004 J.D. Koftinoff Software, Ltd. |
|---|
| 5 | * www.jdkoftinoff.com |
|---|
| 6 | * jeffk@jdkoftinoff.com |
|---|
| 7 | * |
|---|
| 8 | * *** RELEASED UNDER THE GNU GENERAL PUBLIC LICENSE (GPL) April 27, 2004 *** |
|---|
| 9 | * |
|---|
| 10 | * This program is free software; you can redistribute it and/or modify |
|---|
| 11 | * it under the terms of the GNU General Public License as published by |
|---|
| 12 | * the Free Software Foundation; either version 2 of the License, or |
|---|
| 13 | * (at your option) any later version. |
|---|
| 14 | * |
|---|
| 15 | * This program is distributed in the hope that it will be useful, |
|---|
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 18 | * GNU General Public License for more details. |
|---|
| 19 | * |
|---|
| 20 | * You should have received a copy of the GNU General Public License |
|---|
| 21 | * along with this program; if not, write to the Free Software |
|---|
| 22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 23 | */ |
|---|
| 24 | /* |
|---|
| 25 | ** Copyright 1986 to 1998 By J.D. Koftinoff Software, Ltd. |
|---|
| 26 | ** |
|---|
| 27 | ** All rights reserved. |
|---|
| 28 | ** |
|---|
| 29 | ** No one may duplicate this source code in any form for any reason |
|---|
| 30 | ** without the written permission given by J.D. Koftinoff Software, Ltd. |
|---|
| 31 | ** |
|---|
| 32 | */ |
|---|
| 33 | |
|---|
| 34 | #ifndef JDKMIDI_KEYSIG_H |
|---|
| 35 | #define JDKMIDI_KEYSIG_H |
|---|
| 36 | |
|---|
| 37 | #include "jdkmidi/midi.h" |
|---|
| 38 | |
|---|
| 39 | namespace jdkmidi |
|---|
| 40 | { |
|---|
| 41 | enum MIDIAccidentalType |
|---|
| 42 | { |
|---|
| 43 | ACCFlat=0, |
|---|
| 44 | ACCNatural, |
|---|
| 45 | ACCSharp |
|---|
| 46 | }; |
|---|
| 47 | |
|---|
| 48 | class MIDIKeySignature |
|---|
| 49 | { |
|---|
| 50 | public: |
|---|
| 51 | |
|---|
| 52 | MIDIKeySignature(); |
|---|
| 53 | MIDIKeySignature ( const MIDIKeySignature &k ); |
|---|
| 54 | |
|---|
| 55 | void Reset(); |
|---|
| 56 | |
|---|
| 57 | |
|---|
| 58 | bool IsMajor() |
|---|
| 59 | { |
|---|
| 60 | return major; |
|---|
| 61 | } |
|---|
| 62 | |
|---|
| 63 | void SetSharpFlats ( int sf, bool maj=true ) |
|---|
| 64 | { |
|---|
| 65 | sharp_flat=sf; |
|---|
| 66 | major=maj; |
|---|
| 67 | Reset(); |
|---|
| 68 | } |
|---|
| 69 | |
|---|
| 70 | int GetSharpFlats() |
|---|
| 71 | { |
|---|
| 72 | return sharp_flat; |
|---|
| 73 | } |
|---|
| 74 | |
|---|
| 75 | MIDIAccidentalType GetNoteStatus ( int white_note ) |
|---|
| 76 | { |
|---|
| 77 | return state[white_note%7]; |
|---|
| 78 | } |
|---|
| 79 | |
|---|
| 80 | |
|---|
| 81 | bool ConvertMIDINote ( int in_note, int *out_note ); |
|---|
| 82 | |
|---|
| 83 | protected: |
|---|
| 84 | |
|---|
| 85 | bool ProcessWhiteNote ( int in_note, int *out_note ); |
|---|
| 86 | bool ProcessBlackNote ( int in_note, int *out_note ); |
|---|
| 87 | |
|---|
| 88 | MIDIAccidentalType state[7]; |
|---|
| 89 | bool use_sharps; |
|---|
| 90 | int sharp_flat; |
|---|
| 91 | bool major; |
|---|
| 92 | |
|---|
| 93 | static int sharp_list[7]; |
|---|
| 94 | static int flat_list[7]; |
|---|
| 95 | |
|---|
| 96 | |
|---|
| 97 | }; |
|---|
| 98 | } |
|---|
| 99 | |
|---|
| 100 | #endif |
|---|
| 101 | |
|---|