/[svn]/gigedit/trunk/src/plugin/linuxsamplerplugin.cpp
ViewVC logotype

Diff of /gigedit/trunk/src/plugin/linuxsamplerplugin.cpp

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

revision 1654 by schoenebeck, Wed Jan 30 02:20:48 2008 UTC revision 1680 by schoenebeck, Tue Feb 12 14:14:26 2008 UTC
# Line 20  Line 20 
20  #include "linuxsamplerplugin.h"  #include "linuxsamplerplugin.h"
21    
22  #include <linuxsampler/plugins/InstrumentEditorFactory.h>  #include <linuxsampler/plugins/InstrumentEditorFactory.h>
23    #include "../gigedit/gigedit.h"
24    #include "../gigedit/global.h"
25    
26  #include <iostream>  #include <iostream>
27  #include <sigc++/bind.h>  #include <sigc++/bind.h>
28    #include <glibmm/main.h>
29    
30  REGISTER_INSTRUMENT_EDITOR(LinuxSamplerPlugin)  REGISTER_INSTRUMENT_EDITOR(LinuxSamplerPlugin)
31    
# Line 98  int LinuxSamplerPlugin::Main(void* pInst Line 101  int LinuxSamplerPlugin::Main(void* pInst
101          sigc::mem_fun(*this, &LinuxSamplerPlugin::NotifySampleReferenceChanged)          sigc::mem_fun(*this, &LinuxSamplerPlugin::NotifySampleReferenceChanged)
102      );      );
103    
104      app->add_timeout_job(this);      app->signal_keyboard_key_hit().connect(
105            sigc::mem_fun(*this, &LinuxSamplerPlugin::__onVirtualKeyboardKeyHit)
106        );
107        app->signal_keyboard_key_released().connect(
108            sigc::mem_fun(*this, &LinuxSamplerPlugin::__onVirtualKeyboardKeyReleased)
109        );
110    
111        // register a timeout job to gigedit's main loop, so we can poll the
112        // the sampler periodically for MIDI events (I HOPE it works on all
113        // archs, because gigedit is actually running in another thread than
114        // the one that is calling this timeout handler register code)
115        const Glib::RefPtr<Glib::TimeoutSource> timeout_source =
116            Glib::TimeoutSource::create(100); // poll every 100ms
117        timeout_source->connect(
118            sigc::mem_fun(this, &LinuxSamplerPlugin::__onPollPeriod)
119        );
120        timeout_source->attach(Glib::MainContext::get_default());
121    
122      // run gigedit application      // run gigedit application
123      return app->run(pGigInstr);      return app->run(pGigInstr);
124  }  }
125    
126  bool LinuxSamplerPlugin::runGigEditJob() {  bool LinuxSamplerPlugin::__onPollPeriod() {
127        #if HAVE_LINUXSAMPLER_VIRTUAL_MIDI_DEVICE
128      GigEdit* app = (GigEdit*) pApp;      GigEdit* app = (GigEdit*) pApp;
129      if (!NotesChanged()) return true;      if (!NotesChanged()) return true;
130      for (int iKey = 0; iKey < 128; iKey++)      for (int iKey = 0; iKey < 128; iKey++)
131          if (NoteChanged(iKey))          if (NoteChanged(iKey))
132              NoteIsActive(iKey) ? // we don't care about velocity yet              NoteIsActive(iKey) ?
133                  app->on_note_on_event(iKey, 127) :                  app->on_note_on_event(iKey, NoteOnVelocity(iKey)) :
134                  app->on_note_off_event(iKey, 127);                  app->on_note_off_event(iKey, NoteOffVelocity(iKey));
135      return true;      return true;
136        #else
137        return false;
138        #endif
139  }  }
140    
141  void LinuxSamplerPlugin::__onSamplesToBeRemoved(std::list<gig::Sample*> lSamples) {  void LinuxSamplerPlugin::__onSamplesToBeRemoved(std::list<gig::Sample*> lSamples) {
# Line 126  void LinuxSamplerPlugin::__onSamplesToBe Line 149  void LinuxSamplerPlugin::__onSamplesToBe
149      NotifySamplesToBeRemoved(samples);      NotifySamplesToBeRemoved(samples);
150  }  }
151    
152    void LinuxSamplerPlugin::__onVirtualKeyboardKeyHit(int Key, int Velocity) {
153        #if HAVE_LINUXSAMPLER_VIRTUAL_MIDI_DEVICE
154        SendNoteOnToSampler(Key, Velocity);
155        #endif
156    }
157    
158    void LinuxSamplerPlugin::__onVirtualKeyboardKeyReleased(int Key, int Velocity) {
159        #if HAVE_LINUXSAMPLER_VIRTUAL_MIDI_DEVICE
160        SendNoteOffToSampler(Key, Velocity);
161        #endif
162    }
163    
164  bool LinuxSamplerPlugin::IsTypeSupported(String sTypeName, String sTypeVersion) {  bool LinuxSamplerPlugin::IsTypeSupported(String sTypeName, String sTypeVersion) {
165      return sTypeName == gig::libraryName() &&      return sTypeName == gig::libraryName() &&
166             sTypeVersion == gig::libraryVersion();             sTypeVersion == gig::libraryVersion();

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

  ViewVC Help
Powered by ViewVC