/[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 1654 by schoenebeck, Wed Jan 30 01:51:46 2008 UTC revision 1655 by schoenebeck, Wed Jan 30 20:22:47 2008 UTC
# Line 28  Line 28 
28    
29  #define MIDI_KEYS       128  #define MIDI_KEYS       128
30    
31    struct _private_data_t {
32        atomic_t notesChanged; // whether some key changed at all
33        atomic_t pNoteChanged[MIDI_KEYS]; // which key(s) changed
34        atomic_t pNoteIsActive[MIDI_KEYS]; // status of each key (either active or inactive)
35    };
36    
37  namespace LinuxSampler {  namespace LinuxSampler {
38    
39      InstrumentEditor::InstrumentEditor() : Thread(false, false, -1, 0) {      InstrumentEditor::InstrumentEditor() : Thread(false, false, -1, 0) {
40          pInstrument = NULL;          pInstrument = NULL;
41          pNotesChanged = new atomic_t;          _private_data_t* p = new _private_data_t;
42          pNoteChanged  = new atomic_t[MIDI_KEYS];          pPrivateData = p;
         pNoteIsActive = new atomic_t[MIDI_KEYS];  
43          atomic_t zero = ATOMIC_INIT(0);          atomic_t zero = ATOMIC_INIT(0);
44            p->notesChanged = zero;
45          for (int i = 0; i < MIDI_KEYS; i++) {          for (int i = 0; i < MIDI_KEYS; i++) {
46              ((atomic_t*)pNoteChanged)[i]  = zero;              p->pNoteChanged[i]  = zero;
47              ((atomic_t*)pNoteIsActive)[i] = zero;              p->pNoteIsActive[i] = zero;
48          }          }
         *((atomic_t*)pNotesChanged) = zero;  
49      }      }
50    
51      InstrumentEditor::~InstrumentEditor() {      InstrumentEditor::~InstrumentEditor() {
52          if (pNoteIsActive) delete[] (atomic_t*)pNoteIsActive;          if (pPrivateData) delete (_private_data_t*)pPrivateData;
         if (pNoteChanged)  delete[] (atomic_t*)pNoteChanged;  
         if (pNotesChanged) delete (atomic_t*)pNotesChanged;  
53      }      }
54    
55      void InstrumentEditor::Launch(void* pInstrument, String sTypeName, String sTypeVersion) {      void InstrumentEditor::Launch(void* pInstrument, String sTypeName, String sTypeVersion) {
# Line 79  namespace LinuxSampler { Line 82  namespace LinuxSampler {
82    
83      void InstrumentEditor::SendNoteOnToEditor(uint8_t Key, uint8_t /*Velocity*/) {      void InstrumentEditor::SendNoteOnToEditor(uint8_t Key, uint8_t /*Velocity*/) {
84          if (Key >= MIDI_KEYS) return;          if (Key >= MIDI_KEYS) return;
85          atomic_inc( &((atomic_t*)pNoteIsActive)[Key] );          _private_data_t* p = (_private_data_t*)pPrivateData;
86          atomic_inc( &((atomic_t*)pNoteChanged)[Key] );          atomic_inc( &(p->pNoteIsActive)[Key] );
87          atomic_inc( (atomic_t*)pNotesChanged );          atomic_inc( &(p->pNoteChanged)[Key] );
88            atomic_inc( &p->notesChanged );
89      }      }
90    
91      void InstrumentEditor::SendNoteOffToEditor(uint8_t Key, uint8_t /*Velocity*/) {      void InstrumentEditor::SendNoteOffToEditor(uint8_t Key, uint8_t /*Velocity*/) {
92          if (Key >= MIDI_KEYS) return;          if (Key >= MIDI_KEYS) return;
93          atomic_dec( &((atomic_t*)pNoteIsActive)[Key] );          _private_data_t* p = (_private_data_t*)pPrivateData;
94          atomic_inc( &((atomic_t*)pNoteChanged)[Key] );          atomic_dec( &(p->pNoteIsActive)[Key] );
95          atomic_inc( (atomic_t*)pNotesChanged );          atomic_inc( &(p->pNoteChanged)[Key] );
96            atomic_inc( &p->notesChanged );
97      }      }
98    
99      bool InstrumentEditor::NotesChanged() {      bool InstrumentEditor::NotesChanged() {
100          int c = atomic_read( (atomic_t*)pNotesChanged );          _private_data_t* p = (_private_data_t*)pPrivateData;
101          atomic_sub(c, (atomic_t*)pNotesChanged );          int c = atomic_read( &p->notesChanged );
102            atomic_sub(c, &p->notesChanged );
103          return c;          return c;
104      }      }
105    
106      bool InstrumentEditor::NoteChanged(uint8_t Key) {      bool InstrumentEditor::NoteChanged(uint8_t Key) {
107          int c = atomic_read( &((atomic_t*)pNoteChanged)[Key] );          _private_data_t* p = (_private_data_t*)pPrivateData;
108          atomic_sub(c, &((atomic_t*)pNoteChanged)[Key] );          int c = atomic_read( &(p->pNoteChanged)[Key] );
109            atomic_sub(c, &(p->pNoteChanged)[Key] );
110          return c;          return c;
111      }      }
112    
113      bool InstrumentEditor::NoteIsActive(uint8_t Key) {      bool InstrumentEditor::NoteIsActive(uint8_t Key) {
114          return atomic_read( &((atomic_t*)pNoteIsActive)[Key] );          _private_data_t* p = (_private_data_t*)pPrivateData;
115            return atomic_read( &(p->pNoteIsActive)[Key] );
116      }      }
117    
118      void InstrumentEditor::AddListener(InstrumentEditorListener* pListener) {      void InstrumentEditor::AddListener(InstrumentEditorListener* pListener) {

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

  ViewVC Help
Powered by ViewVC