1 |
capela |
264 |
// qsamplerChannel.cpp |
2 |
|
|
// |
3 |
|
|
/**************************************************************************** |
4 |
capela |
341 |
Copyright (C) 2003-2005, rncbc aka Rui Nuno Capela. All rights reserved. |
5 |
capela |
264 |
|
6 |
|
|
This program is free software; you can redistribute it and/or |
7 |
|
|
modify it under the terms of the GNU General Public License |
8 |
|
|
as published by the Free Software Foundation; either version 2 |
9 |
|
|
of the License, or (at your option) any later version. |
10 |
|
|
|
11 |
|
|
This program is distributed in the hope that it will be useful, |
12 |
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
|
|
GNU General Public License for more details. |
15 |
|
|
|
16 |
|
|
You should have received a copy of the GNU General Public License |
17 |
|
|
along with this program; if not, write to the Free Software |
18 |
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 |
|
|
|
20 |
|
|
*****************************************************************************/ |
21 |
|
|
|
22 |
|
|
#include "qsamplerChannel.h" |
23 |
|
|
|
24 |
|
|
#include "qsamplerMainForm.h" |
25 |
capela |
303 |
#include "qsamplerChannelForm.h" |
26 |
capela |
264 |
|
27 |
|
|
#include "config.h" |
28 |
|
|
|
29 |
capela |
299 |
#include <qfileinfo.h> |
30 |
capela |
264 |
|
31 |
capela |
299 |
#ifdef CONFIG_LIBGIG |
32 |
|
|
#include "gig.h" |
33 |
|
|
#endif |
34 |
|
|
|
35 |
capela |
343 |
#define QSAMPLER_INSTRUMENT_MAX 8 |
36 |
capela |
299 |
|
37 |
capela |
343 |
|
38 |
capela |
264 |
//------------------------------------------------------------------------- |
39 |
|
|
// qsamplerChannel - Sampler channel structure. |
40 |
|
|
// |
41 |
|
|
|
42 |
|
|
// Constructor. |
43 |
|
|
qsamplerChannel::qsamplerChannel ( qsamplerMainForm *pMainForm, int iChannelID ) |
44 |
|
|
{ |
45 |
|
|
m_pMainForm = pMainForm; |
46 |
|
|
m_iChannelID = iChannelID; |
47 |
|
|
|
48 |
|
|
// m_sEngineName = QObject::tr("(No engine)"); |
49 |
capela |
344 |
// m_sInstrumentName = QObject::tr("(No instrument)"); |
50 |
|
|
// m_sInstrumentFile = m_sInstrumentName; |
51 |
capela |
264 |
m_iInstrumentNr = -1; |
52 |
|
|
m_iInstrumentStatus = -1; |
53 |
|
|
m_sMidiDriver = "Alsa"; // DEPRECATED. |
54 |
|
|
m_iMidiDevice = -1; |
55 |
|
|
m_iMidiPort = -1; |
56 |
|
|
m_iMidiChannel = -1; |
57 |
|
|
m_sAudioDriver = "Alsa"; // DEPRECATED. |
58 |
|
|
m_iAudioDevice = -1; |
59 |
|
|
m_fVolume = 0.0; |
60 |
|
|
|
61 |
|
|
} |
62 |
|
|
|
63 |
|
|
// Default destructor. |
64 |
|
|
qsamplerChannel::~qsamplerChannel (void) |
65 |
|
|
{ |
66 |
|
|
} |
67 |
|
|
|
68 |
|
|
|
69 |
|
|
// The global options settings delegated property. |
70 |
|
|
qsamplerOptions *qsamplerChannel::options (void) |
71 |
|
|
{ |
72 |
|
|
if (m_pMainForm == NULL) |
73 |
|
|
return NULL; |
74 |
|
|
|
75 |
|
|
return m_pMainForm->options(); |
76 |
|
|
} |
77 |
|
|
|
78 |
|
|
|
79 |
|
|
// The client descriptor delegated property. |
80 |
|
|
lscp_client_t *qsamplerChannel::client (void) |
81 |
|
|
{ |
82 |
|
|
if (m_pMainForm == NULL) |
83 |
|
|
return NULL; |
84 |
|
|
|
85 |
|
|
return m_pMainForm->client(); |
86 |
|
|
} |
87 |
|
|
|
88 |
|
|
|
89 |
capela |
295 |
// Create a new sampler channel, if not already. |
90 |
|
|
bool qsamplerChannel::addChannel (void) |
91 |
|
|
{ |
92 |
|
|
if (client() == NULL) |
93 |
|
|
return false; |
94 |
|
|
|
95 |
|
|
// Are we a new channel? |
96 |
|
|
if (m_iChannelID < 0) { |
97 |
|
|
m_iChannelID = ::lscp_add_channel(client()); |
98 |
|
|
if (m_iChannelID < 0) { |
99 |
|
|
appendMessagesClient("lscp_add_channel"); |
100 |
|
|
appendMessagesError(QObject::tr("Could not create the new channel.\n\nSorry.")); |
101 |
|
|
} // Otherwise it's created... |
102 |
|
|
else appendMessages(QObject::tr("Channel %1 created.").arg(m_iChannelID)); |
103 |
|
|
} |
104 |
|
|
|
105 |
|
|
// Return whether we're a valid channel... |
106 |
|
|
return (m_iChannelID >= 0); |
107 |
|
|
} |
108 |
|
|
|
109 |
|
|
|
110 |
|
|
// Remove sampler channel. |
111 |
|
|
bool qsamplerChannel::removeChannel (void) |
112 |
|
|
{ |
113 |
|
|
if (client() == NULL) |
114 |
|
|
return false; |
115 |
|
|
|
116 |
|
|
// Are we an existing channel? |
117 |
|
|
if (m_iChannelID >= 0) { |
118 |
|
|
if (::lscp_remove_channel(client(), m_iChannelID) != LSCP_OK) { |
119 |
|
|
appendMessagesClient("lscp_remove_channel"); |
120 |
|
|
appendMessagesError(QObject::tr("Could not remove channel.\n\nSorry.")); |
121 |
|
|
} else { |
122 |
|
|
// Otherwise it's removed. |
123 |
|
|
appendMessages(QObject::tr("Channel %1 removed.").arg(m_iChannelID)); |
124 |
|
|
m_iChannelID = -1; |
125 |
|
|
} |
126 |
|
|
} |
127 |
|
|
|
128 |
|
|
// Return whether we've removed the channel... |
129 |
|
|
return (m_iChannelID < 0); |
130 |
|
|
} |
131 |
|
|
|
132 |
|
|
|
133 |
capela |
264 |
// Channel-ID (aka Sammpler-Channel) accessors. |
134 |
|
|
int qsamplerChannel::channelID (void) |
135 |
|
|
{ |
136 |
|
|
return m_iChannelID; |
137 |
|
|
} |
138 |
|
|
|
139 |
|
|
void qsamplerChannel::setChannelID ( int iChannelID ) |
140 |
|
|
{ |
141 |
|
|
m_iChannelID = iChannelID; |
142 |
|
|
} |
143 |
|
|
|
144 |
|
|
|
145 |
capela |
295 |
// Readable channel name. |
146 |
|
|
QString qsamplerChannel::channelName (void) |
147 |
|
|
{ |
148 |
|
|
return (m_iChannelID < 0 ? QObject::tr("New Channel") : QObject::tr("Channel %1").arg(m_iChannelID)); |
149 |
|
|
} |
150 |
|
|
|
151 |
|
|
|
152 |
capela |
264 |
// Engine name accessors. |
153 |
|
|
QString& qsamplerChannel::engineName (void) |
154 |
|
|
{ |
155 |
|
|
return m_sEngineName; |
156 |
|
|
} |
157 |
|
|
|
158 |
|
|
bool qsamplerChannel::loadEngine ( const QString& sEngineName ) |
159 |
|
|
{ |
160 |
capela |
295 |
if (client() == NULL || m_iChannelID < 0) |
161 |
capela |
264 |
return false; |
162 |
|
|
|
163 |
|
|
if (::lscp_load_engine(client(), sEngineName.latin1(), m_iChannelID) != LSCP_OK) { |
164 |
|
|
appendMessagesClient("lscp_load_engine"); |
165 |
|
|
return false; |
166 |
|
|
} |
167 |
|
|
|
168 |
|
|
m_sEngineName = sEngineName; |
169 |
|
|
return true; |
170 |
|
|
} |
171 |
|
|
|
172 |
|
|
|
173 |
|
|
// Instrument filename accessor. |
174 |
|
|
QString& qsamplerChannel::instrumentFile (void) |
175 |
|
|
{ |
176 |
|
|
return m_sInstrumentFile; |
177 |
|
|
} |
178 |
|
|
|
179 |
|
|
// Instrument index accessor. |
180 |
|
|
int qsamplerChannel::instrumentNr (void) |
181 |
|
|
{ |
182 |
|
|
return m_iInstrumentNr; |
183 |
|
|
} |
184 |
|
|
|
185 |
capela |
382 |
// Instrument name accessor. |
186 |
|
|
QString& qsamplerChannel::instrumentName (void) |
187 |
|
|
{ |
188 |
|
|
return m_sInstrumentName; |
189 |
|
|
} |
190 |
|
|
|
191 |
capela |
264 |
// Instrument status accessor. |
192 |
|
|
int qsamplerChannel::instrumentStatus (void) |
193 |
|
|
{ |
194 |
|
|
return m_iInstrumentStatus; |
195 |
|
|
} |
196 |
|
|
|
197 |
|
|
// Instrument file loader. |
198 |
|
|
bool qsamplerChannel::loadInstrument ( const QString& sInstrumentFile, int iInstrumentNr ) |
199 |
|
|
{ |
200 |
capela |
295 |
if (client() == NULL || m_iChannelID < 0) |
201 |
capela |
264 |
return false; |
202 |
|
|
|
203 |
|
|
if (::lscp_load_instrument_non_modal(client(), sInstrumentFile.latin1(), iInstrumentNr, m_iChannelID) != LSCP_OK) { |
204 |
|
|
appendMessagesClient("lscp_load_instrument"); |
205 |
|
|
return false; |
206 |
|
|
} |
207 |
|
|
|
208 |
|
|
m_sInstrumentFile = sInstrumentFile; |
209 |
|
|
m_iInstrumentNr = iInstrumentNr; |
210 |
capela |
382 |
#ifdef CONFIG_INSTRUMENT_NAME |
211 |
|
|
m_sInstrumentName = QString::null; // We'll get it later on channel_info... |
212 |
|
|
#else |
213 |
|
|
m_sInstrumentName = getInstrumentName(sInstrumentFile, iInstrumentNr, true); |
214 |
|
|
#endif |
215 |
capela |
264 |
m_iInstrumentStatus = 0; |
216 |
|
|
|
217 |
|
|
return true; |
218 |
|
|
} |
219 |
|
|
|
220 |
|
|
|
221 |
|
|
// MIDI driver type accessors (DEPRECATED). |
222 |
|
|
QString& qsamplerChannel::midiDriver (void) |
223 |
|
|
{ |
224 |
|
|
return m_sMidiDriver; |
225 |
|
|
} |
226 |
|
|
|
227 |
|
|
bool qsamplerChannel::setMidiDriver ( const QString& sMidiDriver ) |
228 |
|
|
{ |
229 |
capela |
295 |
if (client() == NULL || m_iChannelID < 0) |
230 |
capela |
264 |
return false; |
231 |
|
|
|
232 |
|
|
if (::lscp_set_channel_midi_type(client(), m_iChannelID, sMidiDriver.latin1()) != LSCP_OK) { |
233 |
|
|
appendMessagesClient("lscp_set_channel_midi_type"); |
234 |
|
|
return false; |
235 |
|
|
} |
236 |
|
|
|
237 |
|
|
m_sMidiDriver = sMidiDriver; |
238 |
|
|
return true; |
239 |
|
|
} |
240 |
|
|
|
241 |
|
|
|
242 |
|
|
// MIDI device accessors. |
243 |
|
|
int qsamplerChannel::midiDevice (void) |
244 |
|
|
{ |
245 |
|
|
return m_iMidiDevice; |
246 |
|
|
} |
247 |
|
|
|
248 |
|
|
bool qsamplerChannel::setMidiDevice ( int iMidiDevice ) |
249 |
|
|
{ |
250 |
capela |
295 |
if (client() == NULL || m_iChannelID < 0) |
251 |
capela |
264 |
return false; |
252 |
|
|
|
253 |
|
|
if (::lscp_set_channel_midi_device(client(), m_iChannelID, iMidiDevice) != LSCP_OK) { |
254 |
|
|
appendMessagesClient("lscp_set_channel_midi_device"); |
255 |
|
|
return false; |
256 |
|
|
} |
257 |
|
|
|
258 |
|
|
m_iMidiDevice = iMidiDevice; |
259 |
|
|
return true; |
260 |
|
|
} |
261 |
|
|
|
262 |
|
|
|
263 |
|
|
// MIDI port number accessor. |
264 |
|
|
int qsamplerChannel::midiPort (void) |
265 |
|
|
{ |
266 |
|
|
return m_iMidiPort; |
267 |
|
|
} |
268 |
|
|
|
269 |
|
|
bool qsamplerChannel::setMidiPort ( int iMidiPort ) |
270 |
|
|
{ |
271 |
capela |
295 |
if (client() == NULL || m_iChannelID < 0) |
272 |
capela |
264 |
return false; |
273 |
|
|
|
274 |
|
|
if (::lscp_set_channel_midi_port(client(), m_iChannelID, iMidiPort) != LSCP_OK) { |
275 |
|
|
appendMessagesClient("lscp_set_channel_midi_port"); |
276 |
|
|
return false; |
277 |
|
|
} |
278 |
|
|
|
279 |
|
|
m_iMidiPort = iMidiPort; |
280 |
|
|
return true; |
281 |
|
|
} |
282 |
|
|
|
283 |
|
|
|
284 |
|
|
// MIDI channel accessor. |
285 |
|
|
int qsamplerChannel::midiChannel (void) |
286 |
|
|
{ |
287 |
|
|
return m_iMidiChannel; |
288 |
|
|
} |
289 |
|
|
|
290 |
|
|
bool qsamplerChannel::setMidiChannel ( int iMidiChannel ) |
291 |
|
|
{ |
292 |
capela |
295 |
if (client() == NULL || m_iChannelID < 0) |
293 |
capela |
264 |
return false; |
294 |
|
|
|
295 |
|
|
if (::lscp_set_channel_midi_channel(client(), m_iChannelID, iMidiChannel) != LSCP_OK) { |
296 |
|
|
appendMessagesClient("lscp_set_channel_midi_channel"); |
297 |
|
|
return false; |
298 |
|
|
} |
299 |
|
|
|
300 |
|
|
m_iMidiChannel = iMidiChannel; |
301 |
|
|
return true; |
302 |
|
|
} |
303 |
|
|
|
304 |
|
|
|
305 |
|
|
// Audio device accessor. |
306 |
|
|
int qsamplerChannel::audioDevice (void) |
307 |
|
|
{ |
308 |
|
|
return m_iAudioDevice; |
309 |
|
|
} |
310 |
|
|
|
311 |
|
|
bool qsamplerChannel::setAudioDevice ( int iAudioDevice ) |
312 |
|
|
{ |
313 |
capela |
295 |
if (client() == NULL || m_iChannelID < 0) |
314 |
capela |
264 |
return false; |
315 |
|
|
|
316 |
|
|
if (::lscp_set_channel_audio_device(client(), m_iChannelID, iAudioDevice) != LSCP_OK) { |
317 |
|
|
appendMessagesClient("lscp_set_channel_audio_device"); |
318 |
|
|
return false; |
319 |
|
|
} |
320 |
|
|
|
321 |
|
|
m_iAudioDevice = iAudioDevice; |
322 |
|
|
return true; |
323 |
|
|
} |
324 |
|
|
|
325 |
|
|
|
326 |
|
|
// Audio driver type accessors (DEPRECATED). |
327 |
|
|
QString& qsamplerChannel::audioDriver (void) |
328 |
|
|
{ |
329 |
|
|
return m_sAudioDriver; |
330 |
|
|
} |
331 |
|
|
|
332 |
|
|
bool qsamplerChannel::setAudioDriver ( const QString& sAudioDriver ) |
333 |
|
|
{ |
334 |
capela |
295 |
if (client() == NULL || m_iChannelID < 0) |
335 |
capela |
264 |
return false; |
336 |
|
|
|
337 |
|
|
if (::lscp_set_channel_audio_type(client(), m_iChannelID, sAudioDriver.latin1()) != LSCP_OK) { |
338 |
|
|
appendMessagesClient("lscp_set_channel_audio_type"); |
339 |
|
|
return false; |
340 |
|
|
} |
341 |
|
|
|
342 |
|
|
m_sAudioDriver = sAudioDriver; |
343 |
|
|
return true; |
344 |
|
|
} |
345 |
|
|
|
346 |
|
|
|
347 |
|
|
// Channel volume accessors. |
348 |
|
|
float qsamplerChannel::volume (void) |
349 |
|
|
{ |
350 |
|
|
return m_fVolume; |
351 |
|
|
} |
352 |
|
|
|
353 |
|
|
bool qsamplerChannel::setVolume ( float fVolume ) |
354 |
|
|
{ |
355 |
capela |
295 |
if (client() == NULL || m_iChannelID < 0) |
356 |
capela |
264 |
return false; |
357 |
|
|
|
358 |
|
|
if (::lscp_set_channel_volume(client(), m_iChannelID, fVolume) != LSCP_OK) { |
359 |
|
|
appendMessagesClient("lscp_set_channel_volume"); |
360 |
|
|
return false; |
361 |
|
|
} |
362 |
|
|
|
363 |
|
|
m_fVolume = fVolume; |
364 |
|
|
return true; |
365 |
|
|
} |
366 |
|
|
|
367 |
|
|
|
368 |
capela |
371 |
// Istrument name remapper. |
369 |
|
|
void qsamplerChannel::updateInstrumentName (void) |
370 |
|
|
{ |
371 |
capela |
382 |
#ifndef CONFIG_INSTRUMENT_NAME |
372 |
capela |
371 |
m_sInstrumentName = getInstrumentName(m_sInstrumentFile, |
373 |
|
|
m_iInstrumentNr, (options() && options()->bInstrumentNames)); |
374 |
capela |
382 |
#endif |
375 |
capela |
371 |
} |
376 |
|
|
|
377 |
|
|
|
378 |
capela |
264 |
// Update whole channel info state. |
379 |
capela |
295 |
bool qsamplerChannel::updateChannelInfo (void) |
380 |
capela |
264 |
{ |
381 |
capela |
295 |
if (client() == NULL || m_iChannelID < 0) |
382 |
|
|
return false; |
383 |
capela |
264 |
|
384 |
|
|
// Read channel information. |
385 |
|
|
lscp_channel_info_t *pChannelInfo = ::lscp_get_channel_info(client(), m_iChannelID); |
386 |
|
|
if (pChannelInfo == NULL) { |
387 |
|
|
appendMessagesClient("lscp_get_channel_info"); |
388 |
|
|
appendMessagesError(QObject::tr("Could not get channel information.\n\nSorry.")); |
389 |
capela |
295 |
return false; |
390 |
capela |
264 |
} |
391 |
capela |
295 |
|
392 |
capela |
382 |
#ifdef CONFIG_INSTRUMENT_NAME |
393 |
|
|
// We got all actual instrument datum... |
394 |
|
|
m_sInstrumentFile = pChannelInfo->instrument_file; |
395 |
|
|
m_iInstrumentNr = pChannelInfo->instrument_nr; |
396 |
|
|
m_sInstrumentName = pChannelInfo->instrument_name; |
397 |
|
|
#else |
398 |
capela |
371 |
// First, check if intrument name has changed, |
399 |
|
|
// taking care that instrument name lookup might be expensive, |
400 |
|
|
// so we better make it only once and when really needed... |
401 |
|
|
if ((m_sInstrumentFile != pChannelInfo->instrument_file) || |
402 |
|
|
(m_iInstrumentNr != pChannelInfo->instrument_nr)) { |
403 |
|
|
m_sInstrumentFile = pChannelInfo->instrument_file; |
404 |
|
|
m_iInstrumentNr = pChannelInfo->instrument_nr; |
405 |
|
|
updateInstrumentName(); |
406 |
capela |
344 |
} |
407 |
capela |
382 |
#endif |
408 |
capela |
344 |
// Cache in other channel information. |
409 |
capela |
295 |
m_sEngineName = pChannelInfo->engine_name; |
410 |
|
|
m_iInstrumentStatus = pChannelInfo->instrument_status; |
411 |
|
|
m_iMidiDevice = pChannelInfo->midi_device; |
412 |
|
|
m_iMidiPort = pChannelInfo->midi_port; |
413 |
|
|
m_iMidiChannel = pChannelInfo->midi_channel; |
414 |
|
|
m_iAudioDevice = pChannelInfo->audio_device; |
415 |
|
|
m_fVolume = pChannelInfo->volume; |
416 |
|
|
// Some sanity checks. |
417 |
|
|
if (m_sEngineName == "NONE") |
418 |
|
|
m_sEngineName = QString::null; |
419 |
capela |
344 |
if (m_sInstrumentFile == "NONE") { |
420 |
capela |
295 |
m_sInstrumentFile = QString::null; |
421 |
capela |
344 |
m_sInstrumentName = QString::null; |
422 |
|
|
} |
423 |
capela |
295 |
|
424 |
|
|
return true; |
425 |
capela |
264 |
} |
426 |
|
|
|
427 |
|
|
|
428 |
|
|
// Reset channel method. |
429 |
capela |
295 |
bool qsamplerChannel::resetChannel (void) |
430 |
capela |
264 |
{ |
431 |
capela |
295 |
if (client() == NULL || m_iChannelID < 0) |
432 |
|
|
return false; |
433 |
capela |
264 |
|
434 |
capela |
295 |
if (::lscp_reset_channel(client(), m_iChannelID) != LSCP_OK) { |
435 |
capela |
264 |
appendMessagesClient("lscp_reset_channel"); |
436 |
capela |
295 |
return false; |
437 |
|
|
} |
438 |
|
|
|
439 |
|
|
appendMessages(QObject::tr("Channel %1 reset.").arg(m_iChannelID)); |
440 |
|
|
return true; |
441 |
capela |
264 |
} |
442 |
|
|
|
443 |
|
|
|
444 |
capela |
303 |
// Channel setup dialog form. |
445 |
|
|
bool qsamplerChannel::channelSetup ( QWidget *pParent ) |
446 |
|
|
{ |
447 |
|
|
bool bResult = false; |
448 |
|
|
|
449 |
|
|
qsamplerChannelForm *pChannelForm = new qsamplerChannelForm(pParent); |
450 |
|
|
if (pChannelForm) { |
451 |
|
|
pChannelForm->setup(this); |
452 |
|
|
bResult = pChannelForm->exec(); |
453 |
|
|
delete pChannelForm; |
454 |
|
|
} |
455 |
|
|
|
456 |
|
|
return bResult; |
457 |
|
|
} |
458 |
|
|
|
459 |
|
|
|
460 |
capela |
264 |
// Redirected messages output methods. |
461 |
|
|
void qsamplerChannel::appendMessages( const QString& s ) |
462 |
|
|
{ |
463 |
capela |
303 |
if (m_pMainForm) m_pMainForm->appendMessages(s); |
464 |
capela |
264 |
} |
465 |
|
|
|
466 |
|
|
void qsamplerChannel::appendMessagesColor( const QString& s, const QString& c ) |
467 |
|
|
{ |
468 |
capela |
303 |
if (m_pMainForm) m_pMainForm->appendMessagesColor(s, c); |
469 |
capela |
264 |
} |
470 |
|
|
|
471 |
|
|
void qsamplerChannel::appendMessagesText( const QString& s ) |
472 |
|
|
{ |
473 |
capela |
303 |
if (m_pMainForm) m_pMainForm->appendMessagesText(s); |
474 |
capela |
264 |
} |
475 |
|
|
|
476 |
|
|
void qsamplerChannel::appendMessagesError( const QString& s ) |
477 |
|
|
{ |
478 |
capela |
303 |
if (m_pMainForm) m_pMainForm->appendMessagesError(s); |
479 |
capela |
264 |
} |
480 |
|
|
|
481 |
|
|
void qsamplerChannel::appendMessagesClient( const QString& s ) |
482 |
|
|
{ |
483 |
capela |
303 |
if (m_pMainForm) m_pMainForm->appendMessagesClient(s); |
484 |
capela |
264 |
} |
485 |
|
|
|
486 |
|
|
|
487 |
capela |
303 |
// Context menu event handler. |
488 |
|
|
void qsamplerChannel::contextMenuEvent( QContextMenuEvent *pEvent ) |
489 |
|
|
{ |
490 |
|
|
if (m_pMainForm) m_pMainForm->contextMenuEvent(pEvent); |
491 |
|
|
} |
492 |
|
|
|
493 |
|
|
|
494 |
capela |
299 |
// Retrieve the instrument list of a instrument file (.gig). |
495 |
capela |
344 |
QStringList qsamplerChannel::getInstrumentList( const QString& sInstrumentFile, |
496 |
|
|
bool bInstrumentNames ) |
497 |
capela |
299 |
{ |
498 |
|
|
QFileInfo fileinfo(sInstrumentFile); |
499 |
|
|
QString sInstrumentName = fileinfo.fileName(); |
500 |
|
|
QStringList instlist; |
501 |
|
|
|
502 |
|
|
if (fileinfo.exists()) { |
503 |
|
|
#ifdef CONFIG_LIBGIG |
504 |
capela |
344 |
if (bInstrumentNames) { |
505 |
capela |
341 |
RIFF::File *pRiff = new RIFF::File(sInstrumentFile); |
506 |
|
|
gig::File *pGig = new gig::File(pRiff); |
507 |
|
|
gig::Instrument *pInstrument = pGig->GetFirstInstrument(); |
508 |
|
|
while (pInstrument) { |
509 |
|
|
instlist.append((pInstrument->pInfo)->Name.c_str()); |
510 |
|
|
pInstrument = pGig->GetNextInstrument(); |
511 |
|
|
} |
512 |
|
|
delete pGig; |
513 |
|
|
delete pRiff; |
514 |
|
|
} |
515 |
|
|
else |
516 |
capela |
342 |
#endif |
517 |
capela |
299 |
for (int iInstrumentNr = 0; iInstrumentNr < QSAMPLER_INSTRUMENT_MAX; iInstrumentNr++) |
518 |
|
|
instlist.append(sInstrumentName + " [" + QString::number(iInstrumentNr) + "]"); |
519 |
|
|
} |
520 |
|
|
else instlist.append(sInstrumentName); |
521 |
capela |
306 |
|
522 |
capela |
299 |
return instlist; |
523 |
|
|
} |
524 |
|
|
|
525 |
|
|
|
526 |
|
|
// Retrieve the spacific instrument name of a instrument file (.gig), given its index. |
527 |
capela |
344 |
QString qsamplerChannel::getInstrumentName( const QString& sInstrumentFile, |
528 |
|
|
int iInstrumentNr, bool bInstrumentNames ) |
529 |
capela |
299 |
{ |
530 |
|
|
QFileInfo fileinfo(sInstrumentFile); |
531 |
|
|
QString sInstrumentName = fileinfo.fileName(); |
532 |
|
|
|
533 |
|
|
if (fileinfo.exists()) { |
534 |
|
|
#ifdef CONFIG_LIBGIG |
535 |
capela |
344 |
if (bInstrumentNames) { |
536 |
capela |
341 |
RIFF::File *pRiff = new RIFF::File(sInstrumentFile); |
537 |
|
|
gig::File *pGig = new gig::File(pRiff); |
538 |
|
|
int iIndex = 0; |
539 |
|
|
gig::Instrument *pInstrument = pGig->GetFirstInstrument(); |
540 |
|
|
while (pInstrument) { |
541 |
|
|
if (iIndex == iInstrumentNr) { |
542 |
|
|
sInstrumentName = (pInstrument->pInfo)->Name.c_str(); |
543 |
|
|
break; |
544 |
|
|
} |
545 |
|
|
iIndex++; |
546 |
|
|
pInstrument = pGig->GetNextInstrument(); |
547 |
|
|
} |
548 |
|
|
delete pGig; |
549 |
|
|
delete pRiff; |
550 |
|
|
} |
551 |
|
|
else |
552 |
capela |
342 |
#endif |
553 |
capela |
299 |
sInstrumentName += " [" + QString::number(iInstrumentNr) + "]"; |
554 |
|
|
} |
555 |
|
|
|
556 |
|
|
return sInstrumentName; |
557 |
|
|
} |
558 |
|
|
|
559 |
|
|
|
560 |
capela |
264 |
// end of qsamplerChannel.cpp |