Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
fmnote.c
00001 // fmnote.c 00002 #include "fmtype.h" 00003 #include "fmnote.h" 00004 #include "fmpart.h" 00005 #include "fmtone.h" 00006 #include "fmasgn.h" 00007 00008 // Prototype 00009 static void obtainNecessaryVoice(Note* _this); 00010 00011 // setter 00012 void Note_setPrevPtr( Note* _this, Note* pn ){ _this->_prevPtr = pn; } 00013 void Note_setNextPtr( Note* _this, Note* nn ){ _this->_nextPtr = nn; } 00014 void Note_setPart( Note* _this, void* pt ){ _this->_parent = pt; } 00015 void Note_setHold( Note* _this, bool hold ){ _this->_hold = hold; } 00016 // getter 00017 bool Note_isInUse( Note* _this ){ return _this->_inUse; } 00018 bool Note_isKeyOn( Note* _this ){ return _this->_keyon; } 00019 bool Note_isHeld( Note* _this ){ return _this->_hold; } 00020 Note* Note_prevPtr( Note* _this ){ return _this->_prevPtr;} 00021 Note* Note_nextPtr( Note* _this ){ return _this->_nextPtr;} 00022 unsigned char Note_note(Note* _this){ return _this->_note; } 00023 unsigned char Note_velocity(Note* _this){ return _this->_velocity; } 00024 00025 void Note_init( Note* _this ) 00026 { 00027 _this->_prevPtr = 0; 00028 _this->_nextPtr = 0; 00029 _this->_inUse = false; 00030 _this->_keyon = false; 00031 _this->_hold = false; 00032 _this->_note = 0; 00033 _this->_parent = 0; 00034 _this->_velocity = 0; 00035 } 00036 00037 bool Note_keyon( Note* _this, ToneData* newTone, unsigned char newNote, unsigned char newVelocity ) 00038 { 00039 if ( _this->_parent == FMNULL){ return false; } 00040 00041 _this->_note = newNote; 00042 _this->_velocity = newVelocity; 00043 00044 // obtain necessary voices 00045 obtainNecessaryVoice( _this); 00046 00047 Fmvoice_keyon(_this->_vc, _this, _this->_parent, newTone, newNote, newVelocity); 00048 00049 // set variables 00050 _this->_keyon = true; 00051 _this->_inUse = true; 00052 _this->_hold = false; 00053 return true; 00054 } 00055 void Note_keyoff( Note* _this ) 00056 { 00057 Fmvoice_keyoff( _this->_vc ); 00058 _this->_keyon = false; 00059 _this->_hold = false; 00060 } 00061 void Note_damp( Note* _this ) 00062 { 00063 if (_this->_vc != FMNULL) { 00064 Asgn_releaseParticularVc(_this->_vc); 00065 } 00066 } 00067 void Note_releaseVc( Note* _this, Fmvoice* rlsVc ) 00068 { 00069 if ( rlsVc == _this->_vc ) { 00070 _this->_vc = FMNULL; 00071 } 00072 Note_release(_this); 00073 } 00074 void Note_release( Note* _this ) 00075 { 00076 if (_this->_parent == FMNULL){ return; } 00077 Part_releaseNote((Part*)_this->_parent,_this); 00078 _this->_prevPtr = _this->_nextPtr = FMNULL; 00079 _this->_keyon = false; 00080 _this->_inUse = false; 00081 _this->_hold = false; 00082 } 00083 void Note_chgVibDpt( Note* _this ) 00084 { 00085 if (_this->_parent == FMNULL){ return; } 00086 Part* pt = (Part*)_this->_parent; 00087 if (pt == FMNULL) { return; } 00088 Fmvoice_chgVibDpt(_this->_vc, Part_cc1(pt)); 00089 } 00090 void Note_chgPit( Note* _this ) 00091 { 00092 if (_this->_parent == FMNULL) { return; } 00093 Part* pt = (Part*)_this->_parent; 00094 if (pt == FMNULL) { return; } 00095 Fmvoice_chgPit(_this->_vc, Part_pb(pt)); 00096 } 00097 static void obtainNecessaryVoice(Note* _this) 00098 { 00099 while (Asgn_chkEmpty() != true) { 00100 Asgn_releaseOneVc(); 00101 } 00102 _this->_vc = Asgn_getEmptyVc(); 00103 }
Generated on Wed Jul 13 2022 08:46:10 by
1.7.2