/[svn]/gigedit/trunk/src/plugin/linuxsamplerplugin.cpp
ViewVC logotype

Contents of /gigedit/trunk/src/plugin/linuxsamplerplugin.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1654 - (show annotations) (download)
Wed Jan 30 02:20:48 2008 UTC (16 years, 2 months ago) by schoenebeck
File size: 4506 byte(s)
* first step to make the virtual keyboard interactive: active keys of the
  sampler (in live-mode only of course) are highlighted on the virtual
  keyboard - NOTE: yet inaccurate draw of the keys and this mechanism
  yet only works on the first gigedit invocation by the sampler process,
  so this still has to be fixed

1 /*
2 * Copyright (C) 2007, 2008 Andreas Persson
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2, or (at
7 * your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with program; see the file COPYING. If not, write to the Free
16 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
17 * 02110-1301 USA.
18 */
19
20 #include "linuxsamplerplugin.h"
21
22 #include <linuxsampler/plugins/InstrumentEditorFactory.h>
23
24 #include <iostream>
25 #include <sigc++/bind.h>
26
27 REGISTER_INSTRUMENT_EDITOR(LinuxSamplerPlugin)
28
29 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) {
38 std::cout << "Entered Gigedit Main() loop :)\n" << std::flush;
39 gig::Instrument* pGigInstr = static_cast<gig::Instrument*>(pInstrument);
40 GigEdit* app = (GigEdit*) pApp;
41
42 // connect notification signals
43 app->signal_file_structure_to_be_changed().connect(
44 sigc::bind(
45 sigc::mem_fun(
46 *this, &LinuxSamplerPlugin::NotifyDataStructureToBeChanged
47 ),
48 "gig::File"
49 )
50 );
51 app->signal_file_structure_changed().connect(
52 sigc::bind(
53 sigc::mem_fun(
54 *this, &LinuxSamplerPlugin::NotifyDataStructureChanged
55 ),
56 "gig::File"
57 )
58 );
59 app->signal_samples_to_be_removed().connect(
60 sigc::mem_fun(*this, &LinuxSamplerPlugin::__onSamplesToBeRemoved)
61 );
62 app->signal_samples_removed().connect(
63 sigc::mem_fun(*this, &LinuxSamplerPlugin::NotifySamplesRemoved)
64 );
65 app->signal_region_to_be_changed().connect(
66 sigc::bind(
67 sigc::mem_fun(
68 *this, &LinuxSamplerPlugin::NotifyDataStructureToBeChanged
69 ),
70 "gig::Region"
71 )
72 );
73 app->signal_region_changed().connect(
74 sigc::bind(
75 sigc::mem_fun(
76 *this, &LinuxSamplerPlugin::NotifyDataStructureChanged
77 ),
78 "gig::Region"
79 )
80 );
81 app->signal_dimreg_to_be_changed().connect(
82 sigc::bind(
83 sigc::mem_fun(
84 *this, &LinuxSamplerPlugin::NotifyDataStructureToBeChanged
85 ),
86 "gig::DimensionRegion"
87 )
88 );
89 app->signal_dimreg_changed().connect(
90 sigc::bind(
91 sigc::mem_fun(
92 *this, &LinuxSamplerPlugin::NotifyDataStructureChanged
93 ),
94 "gig::DimensionRegion"
95 )
96 );
97 app->signal_sample_ref_changed().connect(
98 sigc::mem_fun(*this, &LinuxSamplerPlugin::NotifySampleReferenceChanged)
99 );
100
101 app->add_timeout_job(this);
102
103 // run gigedit application
104 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) {
119 // we have to convert the gig::Sample* list to a void* list first
120 std::set<void*> samples;
121 for (
122 std::list<gig::Sample*>::iterator iter = lSamples.begin();
123 iter != lSamples.end(); iter++
124 ) samples.insert((void*)*iter);
125 // finally send notification to sampler
126 NotifySamplesToBeRemoved(samples);
127 }
128
129 bool LinuxSamplerPlugin::IsTypeSupported(String sTypeName, String sTypeVersion) {
130 return sTypeName == gig::libraryName() &&
131 sTypeVersion == gig::libraryVersion();
132 }
133
134 String LinuxSamplerPlugin::Name() {
135 return "gigedit";
136 }
137
138 String LinuxSamplerPlugin::Version() {
139 return VERSION; // gigedit's version
140 }
141
142 String LinuxSamplerPlugin::Description() {
143 return "Gigedit is an instrument editor for gig files.";
144 }

  ViewVC Help
Powered by ViewVC