/[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 1425 by schoenebeck, Sun Oct 14 22:01:28 2007 UTC revision 1655 by schoenebeck, Wed Jan 30 20:22:47 2008 UTC
# Line 1  Line 1 
1  /***************************************************************************  /***************************************************************************
2   *                                                                         *   *                                                                         *
3   *   Copyright (C) 2007 Christian Schoenebeck                              *   *   Copyright (C) 2007, 2008 Christian Schoenebeck                        *
4   *                                                                         *   *                                                                         *
5   *   This program is free software; you can redistribute it and/or modify  *   *   This program is free software; you can redistribute it and/or modify  *
6   *   it under the terms of the GNU General Public License as published by  *   *   it under the terms of the GNU General Public License as published by  *
# Line 21  Line 21 
21  #include "InstrumentEditor.h"  #include "InstrumentEditor.h"
22    
23  #include "../common/global_private.h"  #include "../common/global_private.h"
24    #include "../common/atomic.h"
25    
26  #include <algorithm>  #include <algorithm>
27  #include <functional>  #include <functional>
28    
29    #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            _private_data_t* p = new _private_data_t;
42            pPrivateData = p;
43            atomic_t zero = ATOMIC_INIT(0);
44            p->notesChanged = zero;
45            for (int i = 0; i < MIDI_KEYS; i++) {
46                p->pNoteChanged[i]  = zero;
47                p->pNoteIsActive[i] = zero;
48            }
49        }
50    
51        InstrumentEditor::~InstrumentEditor() {
52            if (pPrivateData) delete (_private_data_t*)pPrivateData;
53      }      }
54    
55      void InstrumentEditor::Launch(void* pInstrument, String sTypeName, String sTypeVersion) {      void InstrumentEditor::Launch(void* pInstrument, String sTypeName, String sTypeVersion) {
# Line 59  namespace LinuxSampler { Line 80  namespace LinuxSampler {
80          return iResult;          return iResult;
81      }      }
82    
83        void InstrumentEditor::SendNoteOnToEditor(uint8_t Key, uint8_t /*Velocity*/) {
84            if (Key >= MIDI_KEYS) return;
85            _private_data_t* p = (_private_data_t*)pPrivateData;
86            atomic_inc( &(p->pNoteIsActive)[Key] );
87            atomic_inc( &(p->pNoteChanged)[Key] );
88            atomic_inc( &p->notesChanged );
89        }
90    
91        void InstrumentEditor::SendNoteOffToEditor(uint8_t Key, uint8_t /*Velocity*/) {
92            if (Key >= MIDI_KEYS) return;
93            _private_data_t* p = (_private_data_t*)pPrivateData;
94            atomic_dec( &(p->pNoteIsActive)[Key] );
95            atomic_inc( &(p->pNoteChanged)[Key] );
96            atomic_inc( &p->notesChanged );
97        }
98    
99        bool InstrumentEditor::NotesChanged() {
100            _private_data_t* p = (_private_data_t*)pPrivateData;
101            int c = atomic_read( &p->notesChanged );
102            atomic_sub(c, &p->notesChanged );
103            return c;
104        }
105    
106        bool InstrumentEditor::NoteChanged(uint8_t Key) {
107            _private_data_t* p = (_private_data_t*)pPrivateData;
108            int c = atomic_read( &(p->pNoteChanged)[Key] );
109            atomic_sub(c, &(p->pNoteChanged)[Key] );
110            return c;
111        }
112    
113        bool InstrumentEditor::NoteIsActive(uint8_t Key) {
114            _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) {
119          listeners.insert(pListener);          listeners.insert(pListener);
120      }      }

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

  ViewVC Help
Powered by ViewVC