1 |
/* |
/* |
2 |
* Copyright (C) 2007 - 2015 Andreas Persson |
* Copyright (C) 2007 - 2017 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 |
19 |
|
|
20 |
#include "linuxsamplerplugin.h" |
#include "linuxsamplerplugin.h" |
21 |
|
|
22 |
#include <linuxsampler/plugins/InstrumentEditorFactory.h> |
#ifdef LIBLINUXSAMPLER_HEADER_FILE |
23 |
#include <linuxsampler/engines/Engine.h> |
# include LIBLINUXSAMPLER_HEADER_FILE(plugins/InstrumentEditorFactory.h) |
24 |
#include <linuxsampler/engines/EngineChannel.h> |
# include LIBLINUXSAMPLER_HEADER_FILE(engines/Engine.h) |
25 |
|
# include LIBLINUXSAMPLER_HEADER_FILE(engines/EngineChannel.h) |
26 |
|
#else |
27 |
|
# include <linuxsampler/plugins/InstrumentEditorFactory.h> |
28 |
|
# include <linuxsampler/engines/Engine.h> |
29 |
|
# include <linuxsampler/engines/EngineChannel.h> |
30 |
|
#endif |
31 |
|
|
32 |
#include "../gigedit/gigedit.h" |
#include "../gigedit/gigedit.h" |
33 |
#include "../gigedit/global.h" |
#include "../gigedit/global.h" |
34 |
|
|
43 |
} |
} |
44 |
|
|
45 |
LinuxSamplerPlugin::~LinuxSamplerPlugin() { |
LinuxSamplerPlugin::~LinuxSamplerPlugin() { |
46 |
if (pApp) delete (GigEdit*) pApp; |
if (pApp) delete static_cast<GigEdit*>(pApp); |
47 |
} |
} |
48 |
|
|
49 |
int LinuxSamplerPlugin::Main(void* pInstrument, String sTypeName, String sTypeVersion, void* /*pUserData*/) { |
int LinuxSamplerPlugin::Main(void* pInstrument, String sTypeName, String sTypeVersion, void* /*pUserData*/) { |
53 |
int LinuxSamplerPlugin::Main(void* pInstrument, String sTypeName, String sTypeVersion) { |
int LinuxSamplerPlugin::Main(void* pInstrument, String sTypeName, String sTypeVersion) { |
54 |
std::cout << "Entered Gigedit Main() loop :)\n" << std::flush; |
std::cout << "Entered Gigedit Main() loop :)\n" << std::flush; |
55 |
gig::Instrument* pGigInstr = static_cast<gig::Instrument*>(pInstrument); |
gig::Instrument* pGigInstr = static_cast<gig::Instrument*>(pInstrument); |
56 |
GigEdit* app = (GigEdit*) pApp; |
GigEdit* app = static_cast<GigEdit*>(pApp); |
57 |
|
|
58 |
// connect notification signals |
// connect notification signals |
59 |
app->signal_file_structure_to_be_changed().connect( |
app->signal_file_structure_to_be_changed().connect( |
131 |
app->signal_switch_sampler_instrument().connect( |
app->signal_switch_sampler_instrument().connect( |
132 |
sigc::mem_fun(*this, &LinuxSamplerPlugin::__requestSamplerToSwitchInstrument) |
sigc::mem_fun(*this, &LinuxSamplerPlugin::__requestSamplerToSwitchInstrument) |
133 |
); |
); |
134 |
|
app->signal_script_to_be_changed.connect( |
135 |
|
sigc::bind( |
136 |
|
sigc::mem_fun( |
137 |
|
*this, &LinuxSamplerPlugin::NotifyDataStructureToBeChanged |
138 |
|
), |
139 |
|
"gig::Script" |
140 |
|
) |
141 |
|
); |
142 |
|
app->signal_script_changed.connect( |
143 |
|
sigc::bind( |
144 |
|
sigc::mem_fun( |
145 |
|
*this, &LinuxSamplerPlugin::NotifyDataStructureChanged |
146 |
|
), |
147 |
|
"gig::Script" |
148 |
|
) |
149 |
|
); |
150 |
|
|
151 |
// 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 |
152 |
// the sampler periodically for MIDI events (I HOPE it works on all |
// the sampler periodically for MIDI events (I HOPE it works on all |
165 |
|
|
166 |
bool LinuxSamplerPlugin::__onPollPeriod() { |
bool LinuxSamplerPlugin::__onPollPeriod() { |
167 |
#if HAVE_LINUXSAMPLER_VIRTUAL_MIDI_DEVICE |
#if HAVE_LINUXSAMPLER_VIRTUAL_MIDI_DEVICE |
168 |
GigEdit* app = (GigEdit*) pApp; |
GigEdit* app = static_cast<GigEdit*>(pApp); |
169 |
if (!NotesChanged()) return true; |
if (!NotesChanged()) return true; |
170 |
for (int iKey = 0; iKey < 128; iKey++) |
for (int iKey = 0; iKey < 128; iKey++) |
171 |
if (NoteChanged(iKey)) |
if (NoteChanged(iKey)) |
183 |
std::set<void*> samples; |
std::set<void*> samples; |
184 |
for ( |
for ( |
185 |
std::list<gig::Sample*>::iterator iter = lSamples.begin(); |
std::list<gig::Sample*>::iterator iter = lSamples.begin(); |
186 |
iter != lSamples.end(); iter++ |
iter != lSamples.end(); ++iter |
187 |
) samples.insert((void*)*iter); |
) samples.insert((void*)*iter); |
188 |
// finally send notification to sampler |
// finally send notification to sampler |
189 |
NotifySamplesToBeRemoved(samples); |
NotifySamplesToBeRemoved(samples); |