/[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 1877 by schoenebeck, Fri Mar 27 12:18:12 2009 UTC revision 2689 by schoenebeck, Sun Jan 4 17:19:19 2015 UTC
# Line 1  Line 1 
1  /*  /*
2   * Copyright (C) 2007, 2008 Andreas Persson   * Copyright (C) 2007 - 2015 Andreas Persson
3   *   *
4   * This program is free software; you can redistribute it and/or   * This program is free software; you can redistribute it and/or
5   * modify it under the terms of the GNU General Public License as   * modify it under the terms of the GNU General Public License as
# 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 <linuxsampler/engines/Engine.h>
24    #include <linuxsampler/engines/EngineChannel.h>
25  #include "../gigedit/gigedit.h"  #include "../gigedit/gigedit.h"
26  #include "../gigedit/global.h"  #include "../gigedit/global.h"
27    
# Line 119  int LinuxSamplerPlugin::Main(void* pInst Line 121  int LinuxSamplerPlugin::Main(void* pInst
121      app->signal_keyboard_key_released().connect(      app->signal_keyboard_key_released().connect(
122          sigc::mem_fun(*this, &LinuxSamplerPlugin::__onVirtualKeyboardKeyReleased)          sigc::mem_fun(*this, &LinuxSamplerPlugin::__onVirtualKeyboardKeyReleased)
123      );      );
124        app->signal_switch_sampler_instrument().connect(
125            sigc::mem_fun(*this, &LinuxSamplerPlugin::__requestSamplerToSwitchInstrument)
126        );
127    
128      // register a timeout job to gigedit's main loop, so we can poll the      // register a timeout job to gigedit's main loop, so we can poll the
129      // the sampler periodically for MIDI events (I HOPE it works on all      // the sampler periodically for MIDI events (I HOPE it works on all
# Line 173  void LinuxSamplerPlugin::__onVirtualKeyb Line 178  void LinuxSamplerPlugin::__onVirtualKeyb
178      #endif      #endif
179  }  }
180    
181    void LinuxSamplerPlugin::__requestSamplerToSwitchInstrument(gig::Instrument* pInstrument) {
182        if (!pInstrument) return;
183    
184        LinuxSampler::EngineChannel* pEngineChannel = GetEngineChannel();
185        if (!pEngineChannel) return;
186    
187        LinuxSampler::Engine* pEngine = pEngineChannel->GetEngine();
188        if (!pEngine) return;
189    
190        LinuxSampler::InstrumentManager* pInstrumentManager = pEngine->GetInstrumentManager();
191        if (!pInstrumentManager) return;
192    
193        gig::File* pFile = (gig::File*) pInstrument->GetParent();
194    
195        // resolve instrument's index number in its gig file
196        int index = -1;
197        for (int i = 0; pFile->GetInstrument(i); ++i) {
198            if (pFile->GetInstrument(i) == pInstrument) {
199                index = i;
200                break;
201            }
202        }
203        if (index < 0) return;
204    
205        LinuxSampler::InstrumentManager::instrument_id_t id;
206        id.FileName = pFile->GetFileName();
207        id.Index    = index;
208        pInstrumentManager->LoadInstrumentInBackground(id, pEngineChannel);
209    }
210    
211  bool LinuxSamplerPlugin::IsTypeSupported(String sTypeName, String sTypeVersion) {  bool LinuxSamplerPlugin::IsTypeSupported(String sTypeName, String sTypeVersion) {
212      return sTypeName == gig::libraryName() &&      return sTypeName == gig::libraryName() &&
213             sTypeVersion == gig::libraryVersion();             sTypeVersion == gig::libraryVersion();

Legend:
Removed from v.1877  
changed lines
  Added in v.2689

  ViewVC Help
Powered by ViewVC