21 |
|
|
22 |
#include <linuxsampler/plugins/InstrumentEditorFactory.h> |
#include <linuxsampler/plugins/InstrumentEditorFactory.h> |
23 |
#include "../gigedit/gigedit.h" |
#include "../gigedit/gigedit.h" |
24 |
|
#include "../gigedit/global.h" |
25 |
|
|
26 |
#include <iostream> |
#include <iostream> |
27 |
#include <sigc++/bind.h> |
#include <sigc++/bind.h> |
97 |
"gig::DimensionRegion" |
"gig::DimensionRegion" |
98 |
) |
) |
99 |
); |
); |
100 |
|
app->signal_sample_changed().connect( |
101 |
|
sigc::bind( |
102 |
|
sigc::mem_fun( |
103 |
|
*this, &LinuxSamplerPlugin::NotifyDataStructureChanged |
104 |
|
), |
105 |
|
"gig::Sample" |
106 |
|
) |
107 |
|
); |
108 |
app->signal_sample_ref_changed().connect( |
app->signal_sample_ref_changed().connect( |
109 |
sigc::mem_fun(*this, &LinuxSamplerPlugin::NotifySampleReferenceChanged) |
sigc::mem_fun(*this, &LinuxSamplerPlugin::NotifySampleReferenceChanged) |
110 |
); |
); |
111 |
|
|
112 |
|
app->signal_keyboard_key_hit().connect( |
113 |
|
sigc::mem_fun(*this, &LinuxSamplerPlugin::__onVirtualKeyboardKeyHit) |
114 |
|
); |
115 |
|
app->signal_keyboard_key_released().connect( |
116 |
|
sigc::mem_fun(*this, &LinuxSamplerPlugin::__onVirtualKeyboardKeyReleased) |
117 |
|
); |
118 |
|
|
119 |
// 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 |
120 |
// the sampler periodically for MIDI events (I HOPE it works on all |
// the sampler periodically for MIDI events (I HOPE it works on all |
121 |
// archs, because gigedit is actually running in another thread than |
// archs, because gigedit is actually running in another thread than |
132 |
} |
} |
133 |
|
|
134 |
bool LinuxSamplerPlugin::__onPollPeriod() { |
bool LinuxSamplerPlugin::__onPollPeriod() { |
135 |
|
#if HAVE_LINUXSAMPLER_VIRTUAL_MIDI_DEVICE |
136 |
GigEdit* app = (GigEdit*) pApp; |
GigEdit* app = (GigEdit*) pApp; |
137 |
if (!NotesChanged()) return true; |
if (!NotesChanged()) return true; |
138 |
for (int iKey = 0; iKey < 128; iKey++) |
for (int iKey = 0; iKey < 128; iKey++) |
139 |
if (NoteChanged(iKey)) |
if (NoteChanged(iKey)) |
140 |
NoteIsActive(iKey) ? // we don't care about velocity yet |
NoteIsActive(iKey) ? |
141 |
app->on_note_on_event(iKey, 127) : |
app->on_note_on_event(iKey, NoteOnVelocity(iKey)) : |
142 |
app->on_note_off_event(iKey, 127); |
app->on_note_off_event(iKey, NoteOffVelocity(iKey)); |
143 |
return true; |
return true; |
144 |
|
#else |
145 |
|
return false; |
146 |
|
#endif |
147 |
} |
} |
148 |
|
|
149 |
void LinuxSamplerPlugin::__onSamplesToBeRemoved(std::list<gig::Sample*> lSamples) { |
void LinuxSamplerPlugin::__onSamplesToBeRemoved(std::list<gig::Sample*> lSamples) { |
157 |
NotifySamplesToBeRemoved(samples); |
NotifySamplesToBeRemoved(samples); |
158 |
} |
} |
159 |
|
|
160 |
|
void LinuxSamplerPlugin::__onVirtualKeyboardKeyHit(int Key, int Velocity) { |
161 |
|
#if HAVE_LINUXSAMPLER_VIRTUAL_MIDI_DEVICE |
162 |
|
SendNoteOnToSampler(Key, Velocity); |
163 |
|
#endif |
164 |
|
} |
165 |
|
|
166 |
|
void LinuxSamplerPlugin::__onVirtualKeyboardKeyReleased(int Key, int Velocity) { |
167 |
|
#if HAVE_LINUXSAMPLER_VIRTUAL_MIDI_DEVICE |
168 |
|
SendNoteOffToSampler(Key, Velocity); |
169 |
|
#endif |
170 |
|
} |
171 |
|
|
172 |
bool LinuxSamplerPlugin::IsTypeSupported(String sTypeName, String sTypeVersion) { |
bool LinuxSamplerPlugin::IsTypeSupported(String sTypeName, String sTypeVersion) { |
173 |
return sTypeName == gig::libraryName() && |
return sTypeName == gig::libraryName() && |
174 |
sTypeVersion == gig::libraryVersion(); |
sTypeVersion == gig::libraryVersion(); |