/[svn]/linuxsampler/trunk/src/plugins/InstrumentEditor.cpp
ViewVC logotype

Diff of /linuxsampler/trunk/src/plugins/InstrumentEditor.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1655 by schoenebeck, Wed Jan 30 20:22:47 2008 UTC revision 1659 by schoenebeck, Sun Feb 3 00:13:27 2008 UTC
# Line 26  Line 26 
26  #include <algorithm>  #include <algorithm>
27  #include <functional>  #include <functional>
28    
 #define MIDI_KEYS       128  
   
 struct _private_data_t {  
     atomic_t notesChanged; // whether some key changed at all  
     atomic_t pNoteChanged[MIDI_KEYS]; // which key(s) changed  
     atomic_t pNoteIsActive[MIDI_KEYS]; // status of each key (either active or inactive)  
 };  
   
29  namespace LinuxSampler {  namespace LinuxSampler {
30    
31      InstrumentEditor::InstrumentEditor() : Thread(false, false, -1, 0) {      InstrumentEditor::InstrumentEditor() : Thread(false, false, -1, 0) {
32          pInstrument = NULL;          pInstrument = NULL;
         _private_data_t* p = new _private_data_t;  
         pPrivateData = p;  
         atomic_t zero = ATOMIC_INIT(0);  
         p->notesChanged = zero;  
         for (int i = 0; i < MIDI_KEYS; i++) {  
             p->pNoteChanged[i]  = zero;  
             p->pNoteIsActive[i] = zero;  
         }  
33      }      }
34    
35      InstrumentEditor::~InstrumentEditor() {      InstrumentEditor::~InstrumentEditor() {
         if (pPrivateData) delete (_private_data_t*)pPrivateData;  
36      }      }
37    
38      void InstrumentEditor::Launch(void* pInstrument, String sTypeName, String sTypeVersion) {      void InstrumentEditor::Launch(void* pInstrument, String sTypeName, String sTypeVersion) {
# Line 80  namespace LinuxSampler { Line 63  namespace LinuxSampler {
63          return iResult;          return iResult;
64      }      }
65    
     void InstrumentEditor::SendNoteOnToEditor(uint8_t Key, uint8_t /*Velocity*/) {  
         if (Key >= MIDI_KEYS) return;  
         _private_data_t* p = (_private_data_t*)pPrivateData;  
         atomic_inc( &(p->pNoteIsActive)[Key] );  
         atomic_inc( &(p->pNoteChanged)[Key] );  
         atomic_inc( &p->notesChanged );  
     }  
   
     void InstrumentEditor::SendNoteOffToEditor(uint8_t Key, uint8_t /*Velocity*/) {  
         if (Key >= MIDI_KEYS) return;  
         _private_data_t* p = (_private_data_t*)pPrivateData;  
         atomic_dec( &(p->pNoteIsActive)[Key] );  
         atomic_inc( &(p->pNoteChanged)[Key] );  
         atomic_inc( &p->notesChanged );  
     }  
   
     bool InstrumentEditor::NotesChanged() {  
         _private_data_t* p = (_private_data_t*)pPrivateData;  
         int c = atomic_read( &p->notesChanged );  
         atomic_sub(c, &p->notesChanged );  
         return c;  
     }  
   
     bool InstrumentEditor::NoteChanged(uint8_t Key) {  
         _private_data_t* p = (_private_data_t*)pPrivateData;  
         int c = atomic_read( &(p->pNoteChanged)[Key] );  
         atomic_sub(c, &(p->pNoteChanged)[Key] );  
         return c;  
     }  
   
     bool InstrumentEditor::NoteIsActive(uint8_t Key) {  
         _private_data_t* p = (_private_data_t*)pPrivateData;  
         return atomic_read( &(p->pNoteIsActive)[Key] );  
     }  
   
66      void InstrumentEditor::AddListener(InstrumentEditorListener* pListener) {      void InstrumentEditor::AddListener(InstrumentEditorListener* pListener) {
67          listeners.insert(pListener);          listeners.insert(pListener);
68      }      }

Legend:
Removed from v.1655  
changed lines
  Added in v.1659

  ViewVC Help
Powered by ViewVC