1 |
/* |
/* |
2 |
* Copyright (C) 2007 Andreas Persson |
* Copyright (C) 2007, 2008 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 |
20 |
#include "linuxsamplerplugin.h" |
#include "linuxsamplerplugin.h" |
21 |
|
|
22 |
#include <linuxsampler/plugins/InstrumentEditorFactory.h> |
#include <linuxsampler/plugins/InstrumentEditorFactory.h> |
|
#include "../gigedit/gigedit.h" |
|
23 |
|
|
24 |
#include <iostream> |
#include <iostream> |
25 |
#include <sigc++/bind.h> |
#include <sigc++/bind.h> |
27 |
REGISTER_INSTRUMENT_EDITOR(LinuxSamplerPlugin) |
REGISTER_INSTRUMENT_EDITOR(LinuxSamplerPlugin) |
28 |
|
|
29 |
LinuxSamplerPlugin::LinuxSamplerPlugin() { |
LinuxSamplerPlugin::LinuxSamplerPlugin() { |
30 |
|
pApp = new GigEdit; |
31 |
|
} |
32 |
|
|
33 |
|
LinuxSamplerPlugin::~LinuxSamplerPlugin() { |
34 |
|
if (pApp) delete (GigEdit*) pApp; |
35 |
} |
} |
36 |
|
|
37 |
int LinuxSamplerPlugin::Main(void* pInstrument, String sTypeName, String sTypeVersion) { |
int LinuxSamplerPlugin::Main(void* pInstrument, String sTypeName, String sTypeVersion) { |
38 |
std::cout << "Entered Gigedit Main() loop :)\n" << std::flush; |
std::cout << "Entered Gigedit Main() loop :)\n" << std::flush; |
39 |
gig::Instrument* pGigInstr = static_cast<gig::Instrument*>(pInstrument); |
gig::Instrument* pGigInstr = static_cast<gig::Instrument*>(pInstrument); |
40 |
GigEdit app; |
GigEdit* app = (GigEdit*) pApp; |
41 |
|
|
42 |
// connect notification signals |
// connect notification signals |
43 |
app.signal_file_structure_to_be_changed().connect( |
app->signal_file_structure_to_be_changed().connect( |
44 |
sigc::bind( |
sigc::bind( |
45 |
sigc::mem_fun( |
sigc::mem_fun( |
46 |
*this, &LinuxSamplerPlugin::NotifyDataStructureToBeChanged |
*this, &LinuxSamplerPlugin::NotifyDataStructureToBeChanged |
48 |
"gig::File" |
"gig::File" |
49 |
) |
) |
50 |
); |
); |
51 |
app.signal_file_structure_changed().connect( |
app->signal_file_structure_changed().connect( |
52 |
sigc::bind( |
sigc::bind( |
53 |
sigc::mem_fun( |
sigc::mem_fun( |
54 |
*this, &LinuxSamplerPlugin::NotifyDataStructureChanged |
*this, &LinuxSamplerPlugin::NotifyDataStructureChanged |
56 |
"gig::File" |
"gig::File" |
57 |
) |
) |
58 |
); |
); |
59 |
app.signal_samples_to_be_removed().connect( |
app->signal_samples_to_be_removed().connect( |
60 |
sigc::mem_fun(*this, &LinuxSamplerPlugin::__onSamplesToBeRemoved) |
sigc::mem_fun(*this, &LinuxSamplerPlugin::__onSamplesToBeRemoved) |
61 |
); |
); |
62 |
app.signal_samples_removed().connect( |
app->signal_samples_removed().connect( |
63 |
sigc::mem_fun(*this, &LinuxSamplerPlugin::NotifySamplesRemoved) |
sigc::mem_fun(*this, &LinuxSamplerPlugin::NotifySamplesRemoved) |
64 |
); |
); |
65 |
app.signal_region_to_be_changed().connect( |
app->signal_region_to_be_changed().connect( |
66 |
sigc::bind( |
sigc::bind( |
67 |
sigc::mem_fun( |
sigc::mem_fun( |
68 |
*this, &LinuxSamplerPlugin::NotifyDataStructureToBeChanged |
*this, &LinuxSamplerPlugin::NotifyDataStructureToBeChanged |
70 |
"gig::Region" |
"gig::Region" |
71 |
) |
) |
72 |
); |
); |
73 |
app.signal_region_changed().connect( |
app->signal_region_changed().connect( |
74 |
sigc::bind( |
sigc::bind( |
75 |
sigc::mem_fun( |
sigc::mem_fun( |
76 |
*this, &LinuxSamplerPlugin::NotifyDataStructureChanged |
*this, &LinuxSamplerPlugin::NotifyDataStructureChanged |
78 |
"gig::Region" |
"gig::Region" |
79 |
) |
) |
80 |
); |
); |
81 |
app.signal_dimreg_to_be_changed().connect( |
app->signal_dimreg_to_be_changed().connect( |
82 |
sigc::bind( |
sigc::bind( |
83 |
sigc::mem_fun( |
sigc::mem_fun( |
84 |
*this, &LinuxSamplerPlugin::NotifyDataStructureToBeChanged |
*this, &LinuxSamplerPlugin::NotifyDataStructureToBeChanged |
86 |
"gig::DimensionRegion" |
"gig::DimensionRegion" |
87 |
) |
) |
88 |
); |
); |
89 |
app.signal_dimreg_changed().connect( |
app->signal_dimreg_changed().connect( |
90 |
sigc::bind( |
sigc::bind( |
91 |
sigc::mem_fun( |
sigc::mem_fun( |
92 |
*this, &LinuxSamplerPlugin::NotifyDataStructureChanged |
*this, &LinuxSamplerPlugin::NotifyDataStructureChanged |
94 |
"gig::DimensionRegion" |
"gig::DimensionRegion" |
95 |
) |
) |
96 |
); |
); |
97 |
app.signal_sample_ref_changed().connect( |
app->signal_sample_ref_changed().connect( |
98 |
sigc::mem_fun(*this, &LinuxSamplerPlugin::NotifySampleReferenceChanged) |
sigc::mem_fun(*this, &LinuxSamplerPlugin::NotifySampleReferenceChanged) |
99 |
); |
); |
100 |
|
|
101 |
|
app->add_timeout_job(this); |
102 |
|
|
103 |
// run gigedit application |
// run gigedit application |
104 |
return app.run(pGigInstr); |
return app->run(pGigInstr); |
105 |
|
} |
106 |
|
|
107 |
|
bool LinuxSamplerPlugin::runGigEditJob() { |
108 |
|
GigEdit* app = (GigEdit*) pApp; |
109 |
|
if (!NotesChanged()) return true; |
110 |
|
for (int iKey = 0; iKey < 128; iKey++) |
111 |
|
if (NoteChanged(iKey)) |
112 |
|
NoteIsActive(iKey) ? // we don't care about velocity yet |
113 |
|
app->on_note_on_event(iKey, 127) : |
114 |
|
app->on_note_off_event(iKey, 127); |
115 |
|
return true; |
116 |
} |
} |
117 |
|
|
118 |
void LinuxSamplerPlugin::__onSamplesToBeRemoved(std::list<gig::Sample*> lSamples) { |
void LinuxSamplerPlugin::__onSamplesToBeRemoved(std::list<gig::Sample*> lSamples) { |