/[svn]/linuxsampler/trunk/src/drivers/midi/VirtualMidiDevice.cpp
ViewVC logotype

Diff of /linuxsampler/trunk/src/drivers/midi/VirtualMidiDevice.cpp

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

revision 3018 by schoenebeck, Wed Oct 19 17:22:28 2016 UTC revision 3986 by schoenebeck, Wed Aug 4 18:04:12 2021 UTC
# Line 1  Line 1 
1  /*  /*
2      Copyright (C) 2008 - 2016 Christian Schoenebeck      Copyright (C) 2008 - 2021 Christian Schoenebeck
3   */   */
4    
5  #include "VirtualMidiDevice.h"  #include "VirtualMidiDevice.h"
# Line 15  Line 15 
15  // by mouse (and the user not being Billy the Kid)  // by mouse (and the user not being Billy the Kid)
16  #define MAX_EVENTS  12  #define MAX_EVENTS  12
17    
18    #define DEFAULT_CC_VALUE 0
19    #define DEFAULT_VELOCITY 127
20    
21  namespace LinuxSampler {  namespace LinuxSampler {
22    
23      struct VirtualMidiDevice::private_data_t {      struct VirtualMidiDevice::private_data_t {
# Line 29  namespace LinuxSampler { Line 32  namespace LinuxSampler {
32          RingBuffer<VirtualMidiDevice::event_t,false> events;          RingBuffer<VirtualMidiDevice::event_t,false> events;
33    
34          private_data_t() : events(MAX_EVENTS, 0) {}          private_data_t() : events(MAX_EVENTS, 0) {}
35    
36            void resetNotes() {
37                for (int i = 0; i < MIDI_KEYS; i++) {
38                    atomic_set( &pNoteOnVelocity[i], DEFAULT_VELOCITY );
39                    atomic_set( &pNoteOffVelocity[i], DEFAULT_VELOCITY );
40                    atomic_set( &pNoteIsActive[i], 0 );
41                    // should be non zero, because we changed the state above, that
42                    // way forcing the virtual MIDI device user (e.g. UI) to refresh
43                    atomic_inc( &pNoteChanged[i] );
44                }
45                // this should also be non zero, for the same reason as above
46                atomic_inc( &notesChanged );
47            }
48    
49            void resetCCs() {
50                for (int i = 0; i < MIDI_CONTROLLERS; i++) {
51                    atomic_set( &pCCValue[i], DEFAULT_CC_VALUE );
52                    // should be non zero, because we changed the state above, that
53                    // way forcing the virtual MIDI device user (e.g. UI) to refresh
54                    atomic_inc( &pCCChanged[i] );
55                }
56                // this should also be non zero, for the same reason as above
57                atomic_inc( &ccsChanged );
58            }
59      };      };
60    
61      VirtualMidiDevice::VirtualMidiDevice() : p(new private_data_t) {      VirtualMidiDevice::VirtualMidiDevice() : p(new private_data_t) {
# Line 184  namespace LinuxSampler { Line 211  namespace LinuxSampler {
211          atomic_inc( &p->ccsChanged );          atomic_inc( &p->ccsChanged );
212      }      }
213    
214        void VirtualMidiDevice::Reset() {
215            p->resetNotes();
216            p->resetCCs();
217        }
218    
219  } // namespace LinuxSampler  } // namespace LinuxSampler

Legend:
Removed from v.3018  
changed lines
  Added in v.3986

  ViewVC Help
Powered by ViewVC