#include <keysig.h>
Public Member Functions | |
| MIDIKeySignature () | |
| MIDIKeySignature (const MIDIKeySignature &k) | |
| void | Reset () |
| bool | IsMajor () |
| void | SetSharpFlats (int sf, bool maj=true) |
| int | GetSharpFlats () |
| MIDIAccidentalType | GetNoteStatus (int white_note) |
| bool | ConvertMIDINote (int in_note, int *out_note) |
Protected Member Functions | |
| bool | ProcessWhiteNote (int in_note, int *out_note) |
| bool | ProcessBlackNote (int in_note, int *out_note) |
Protected Attributes | |
| MIDIAccidentalType | state [7] |
| bool | use_sharps |
| int | sharp_flat |
| bool | major |
Static Protected Attributes | |
| int | sharp_list [7] = { 3, 0, 4, 1, 5, 2, 6 } |
| int | flat_list [7] = { 6, 2, 5, 1, 4, 0, 3 } |
|
|
Definition at line 57 of file jdkmidi_keysig.cpp. References ENTER, major, Reset(), sharp_flat, and use_sharps.
00058 {
00059 ENTER( "MIDIKeySignature::MIDIKeySignature()" );
00060 use_sharps=true;
00061 sharp_flat=0;
00062 major=true;
00063 Reset();
00064 }
|
|
|
Definition at line 66 of file jdkmidi_keysig.cpp. References ENTER, major, Reset(), sharp_flat, and use_sharps.
00067 {
00068 ENTER( "MIDIKeySignature::MIDIKeySignature()" );
00069 use_sharps=k.use_sharps;
00070 sharp_flat=k.sharp_flat;
00071 major=k.major;
00072
00073 Reset();
00074 }
|
|
||||||||||||
|
Definition at line 250 of file jdkmidi_keysig.cpp. References ENTER, ProcessBlackNote(), and ProcessWhiteNote().
00254 {
00255 ENTER( "MIDIKeySignature::ConvertMIDINote()" );
00256
00257 int octave=in_note/12;
00258 int midi_note=in_note%12;
00259 int actual_note=0;
00260 bool changed=false;
00261
00262 switch( midi_note )
00263 {
00264 case 0: // C
00265 changed=ProcessWhiteNote(0,&actual_note);
00266 break;
00267 case 2: // D
00268 changed=ProcessWhiteNote(1,&actual_note);
00269 break;
00270 case 4: // E
00271 changed=ProcessWhiteNote(2,&actual_note);
00272 break;
00273 case 5: // F
00274 changed=ProcessWhiteNote(3,&actual_note);
00275 break;
00276 case 7: // G
00277 changed=ProcessWhiteNote(4,&actual_note);
00278 break;
00279 case 9: // A
00280 changed=ProcessWhiteNote(5,&actual_note);
00281 break;
00282 case 11: // B
00283 changed=ProcessWhiteNote(6,&actual_note);
00284 break;
00285
00286 case 1: // C#
00287 changed=ProcessBlackNote(0,&actual_note);
00288 break;
00289 case 3: // D#
00290 changed=ProcessBlackNote(1,&actual_note);
00291 break;
00292 case 6: // F#
00293 changed=ProcessBlackNote(3,&actual_note);
00294 break;
00295 case 8: // G#
00296 changed=ProcessBlackNote(4,&actual_note);
00297 break;
00298 case 10: // A#
00299 changed=ProcessBlackNote(5,&actual_note);
00300 break;
00301 };
00302
00303 *out_note = (octave*7) + actual_note;
00304 return changed;
00305
00306 }
|
|
|
Definition at line 65 of file keysig.h. References jdkmidi::MIDIAccidentalType, and state.
00066 { return state[white_note%7]; }
|
|
|
Definition at line 63 of file keysig.h. References sharp_flat.
00063 { return sharp_flat; }
|
|
|
Definition at line 58 of file keysig.h. References major.
00058 { return major; }
|
|
||||||||||||
|
Definition at line 183 of file jdkmidi_keysig.cpp. References jdkmidi::ACCFlat, jdkmidi::ACCSharp, ENTER, state, and use_sharps.
00184 {
00185 ENTER( "MIDIKeySignature::ProcessBlackNote()" );
00186 //
00187 // if this note is already sharped,
00188 // return the note unchanged and return false
00189 // because no accidental was required
00190
00191 if( state[in_note]==ACCSharp )
00192 {
00193 *out_note=in_note;
00194 return false;
00195 }
00196
00197 //
00198 // if the next note is flatted, then we could use it
00199 // instead.
00200 //
00201
00202 if( state[in_note+1]==ACCFlat )
00203 {
00204 *out_note=in_note+1;
00205 return false;
00206 }
00207
00208 //
00209 // Couldn't find a black note. we gotta make one.
00210 // make a sharp if use_sharps==1
00211
00212 if( use_sharps )
00213 {
00214 //
00215 // make this white note a sharp.
00216 //
00217
00218 state[in_note]=ACCSharp;
00219 *out_note=in_note;
00220
00221 //
00222 // Accidental required. return true.
00223 //
00224 return true;
00225 }
00226 else
00227 {
00228 //
00229 // make the next white note a flat.
00230 //
00231
00232 state[in_note+1]=ACCFlat;
00233 *out_note=in_note+1;
00234
00235 //
00236 // Accidental required. Return true.
00237 //
00238
00239 return true;
00240 }
00241 }
|
|
||||||||||||
|
Definition at line 136 of file jdkmidi_keysig.cpp. References jdkmidi::ACCNatural, ENTER, and state.
00137 {
00138 ENTER( "MIDIKeySignature::ProcessWhiteNote()" );
00139 //
00140 // check to see if this white note is allowed in the current
00141 // state.
00142 //
00143
00144 if( state[in_note]==ACCNatural )
00145 {
00146 //
00147 // yes it is allowed, return it.
00148 //
00149
00150 *out_note=in_note;
00151
00152 //
00153 // return false to signify that this note doesn't need
00154 // an accidental.
00155 //
00156
00157 return false;
00158 }
00159 else
00160 {
00161 //
00162 // no it was not allowed. We must change our state.
00163 // to allow it. return it.
00164 //
00165
00166 *out_note=in_note;
00167
00168 //
00169 // change the desired note to a natural
00170 //
00171
00172 state[in_note]=ACCNatural;
00173
00174 //
00175 // return true because it needed an accidental
00176 //
00177
00178 return true;
00179 }
00180 }
|
|
|
Definition at line 82 of file jdkmidi_keysig.cpp. References jdkmidi::ACCFlat, jdkmidi::ACCNatural, jdkmidi::ACCSharp, ENTER, flat_list, sharp_flat, sharp_list, state, and use_sharps.
00083 {
00084 ENTER( "MIDIKeySignature::Reset()" );
00085 if( sharp_flat < -7 )
00086 sharp_flat=-7;
00087 if( sharp_flat >7 )
00088 sharp_flat=7;
00089
00090 for( int note=0; note<7; ++note )
00091 state[note]=ACCNatural;
00092
00093 if( sharp_flat==0 )
00094 {
00095 // Key of C has no sharps or flats.
00096 // and any accidentals will be sharp
00097
00098 use_sharps=true;
00099 }
00100 else if( sharp_flat>0 )
00101 {
00102 //
00103 // this key has a number of sharps in it.
00104 //
00105
00106 use_sharps=true;
00107
00108 for( short i=0; i<sharp_flat; ++i )
00109 {
00110 state[sharp_list[i]]=ACCSharp;
00111 }
00112 }
00113 else if( sharp_flat<0 )
00114 {
00115 //
00116 // this key has flats in it.
00117 // -sharp_flat is how many flats.
00118 //
00119
00120 int flats= -sharp_flat;
00121
00122 use_sharps=false;
00123
00124 for( int i=0; i<flats; ++i )
00125 {
00126 state[ flat_list[i] ]=ACCFlat;
00127 }
00128
00129 }
00130
00131 }
|
|
||||||||||||
|
Definition at line 60 of file keysig.h. References major, Reset(), and sharp_flat.
00061 { sharp_flat=sf; major=maj; Reset(); }
|
|
|
Definition at line 54 of file jdkmidi_keysig.cpp. |
|
|
|
|
|
|
|
|
Definition at line 53 of file jdkmidi_keysig.cpp. |
|
|
|
|
|
|