25 |
|
|
26 |
#include "global.h" |
#include "global.h" |
27 |
|
|
|
GigEditJob::GigEditJob() { |
|
|
_msecs = 100; // 100ms by default |
|
|
} |
|
|
|
|
|
int GigEditJob::msecs() { |
|
|
return _msecs; |
|
|
} |
|
|
|
|
28 |
namespace { |
namespace { |
29 |
|
|
30 |
// State for a gigedit thread. |
// State for a gigedit thread. |
40 |
GigEditState(GigEdit* parent) : parent(parent) { } |
GigEditState(GigEdit* parent) : parent(parent) { } |
41 |
void run(gig::Instrument* pInstrument); |
void run(gig::Instrument* pInstrument); |
42 |
|
|
|
static std::vector< GigEditJob* > timeoutJobs; |
|
43 |
MainWindow* window; |
MainWindow* window; |
44 |
|
|
45 |
private: |
private: |
130 |
mainwindow->signal_sample_ref_changed().connect( |
mainwindow->signal_sample_ref_changed().connect( |
131 |
gigedit->signal_sample_ref_changed().make_slot() |
gigedit->signal_sample_ref_changed().make_slot() |
132 |
); |
); |
133 |
|
mainwindow->signal_keyboard_key_hit().connect( |
134 |
|
gigedit->signal_keyboard_key_hit().make_slot() |
135 |
|
); |
136 |
|
mainwindow->signal_keyboard_key_released().connect( |
137 |
|
gigedit->signal_keyboard_key_released().make_slot() |
138 |
|
); |
139 |
} |
} |
140 |
|
|
141 |
} // namespace |
} // namespace |
165 |
return 0; |
return 0; |
166 |
} |
} |
167 |
|
|
|
void GigEdit::add_timeout_job(GigEditJob* job) { |
|
|
GigEditState::timeoutJobs.push_back(job); |
|
|
} |
|
|
|
|
168 |
void GigEdit::on_note_on_event(int key, int velocity) { |
void GigEdit::on_note_on_event(int key, int velocity) { |
169 |
if (!this->state) return; |
if (!this->state) return; |
170 |
GigEditState* state = (GigEditState*) this->state; |
GigEditState* state = (GigEditState*) this->state; |
213 |
return sample_ref_changed_signal; |
return sample_ref_changed_signal; |
214 |
} |
} |
215 |
|
|
216 |
|
sigc::signal<void, int/*key*/, int/*velocity*/>& GigEdit::signal_keyboard_key_hit() { |
217 |
|
return keyboard_key_hit_signal; |
218 |
|
} |
219 |
|
|
220 |
|
sigc::signal<void, int/*key*/, int/*velocity*/>& GigEdit::signal_keyboard_key_released() { |
221 |
|
return keyboard_key_released_signal; |
222 |
|
} |
223 |
|
|
224 |
Glib::StaticMutex GigEditState::mutex = GLIBMM_STATIC_MUTEX_INIT; |
Glib::StaticMutex GigEditState::mutex = GLIBMM_STATIC_MUTEX_INIT; |
225 |
Glib::Dispatcher* GigEditState::dispatcher = 0; |
Glib::Dispatcher* GigEditState::dispatcher = 0; |
226 |
GigEditState* GigEditState::current = 0; |
GigEditState* GigEditState::current = 0; |
|
std::vector<GigEditJob*> GigEditState::timeoutJobs; |
|
227 |
|
|
228 |
void GigEditState::open_window_static() { |
void GigEditState::open_window_static() { |
229 |
GigEditState* c = GigEditState::current; |
GigEditState* c = GigEditState::current; |
257 |
dispatcher->connect(sigc::ptr_fun(&GigEditState::open_window_static)); |
dispatcher->connect(sigc::ptr_fun(&GigEditState::open_window_static)); |
258 |
initialized->signal(); |
initialized->signal(); |
259 |
|
|
|
for (int i = 0; i < GigEditState::timeoutJobs.size(); i++) { |
|
|
GigEditJob* job = timeoutJobs[i]; |
|
|
const Glib::RefPtr<Glib::TimeoutSource> timeout_source = |
|
|
Glib::TimeoutSource::create(job->msecs()); |
|
|
timeout_source->connect( |
|
|
sigc::mem_fun(*job, &GigEditJob::runGigEditJob) |
|
|
); |
|
|
timeout_source->attach(Glib::MainContext::get_default()); |
|
|
} |
|
|
|
|
260 |
main_loop.run(); |
main_loop.run(); |
261 |
} |
} |
262 |
|
|