1 |
// qsamplerChannel.cpp |
// qsamplerChannel.cpp |
2 |
// |
// |
3 |
/**************************************************************************** |
/**************************************************************************** |
4 |
Copyright (C) 2003-2004, rncbc aka Rui Nuno Capela. All rights reserved. |
Copyright (C) 2003-2005, rncbc aka Rui Nuno Capela. All rights reserved. |
5 |
|
|
6 |
This program is free software; you can redistribute it and/or |
This program is free software; you can redistribute it and/or |
7 |
modify it under the terms of the GNU General Public License |
modify it under the terms of the GNU General Public License |
22 |
#include "qsamplerChannel.h" |
#include "qsamplerChannel.h" |
23 |
|
|
24 |
#include "qsamplerMainForm.h" |
#include "qsamplerMainForm.h" |
25 |
|
#include "qsamplerChannelForm.h" |
26 |
|
|
27 |
#include "config.h" |
#include "config.h" |
28 |
|
|
30 |
|
|
31 |
#ifdef CONFIG_LIBGIG |
#ifdef CONFIG_LIBGIG |
32 |
#include "gig.h" |
#include "gig.h" |
|
#else |
|
|
#define QSAMPLER_INSTRUMENT_MAX 8 |
|
33 |
#endif |
#endif |
34 |
|
|
35 |
|
#define QSAMPLER_INSTRUMENT_MAX 8 |
36 |
|
|
37 |
|
|
38 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
39 |
// qsamplerChannel - Sampler channel structure. |
// qsamplerChannel - Sampler channel structure. |
40 |
// |
// |
41 |
|
bool qsamplerChannel::g_bInstrumentNames = false; |
42 |
|
|
43 |
// Constructor. |
// Constructor. |
44 |
qsamplerChannel::qsamplerChannel ( qsamplerMainForm *pMainForm, int iChannelID ) |
qsamplerChannel::qsamplerChannel ( qsamplerMainForm *pMainForm, int iChannelID ) |
404 |
} |
} |
405 |
|
|
406 |
|
|
407 |
|
// Channel setup dialog form. |
408 |
|
bool qsamplerChannel::channelSetup ( QWidget *pParent ) |
409 |
|
{ |
410 |
|
bool bResult = false; |
411 |
|
|
412 |
|
qsamplerChannelForm *pChannelForm = new qsamplerChannelForm(pParent); |
413 |
|
if (pChannelForm) { |
414 |
|
pChannelForm->setup(this); |
415 |
|
bResult = pChannelForm->exec(); |
416 |
|
delete pChannelForm; |
417 |
|
} |
418 |
|
|
419 |
|
return bResult; |
420 |
|
} |
421 |
|
|
422 |
|
|
423 |
// Redirected messages output methods. |
// Redirected messages output methods. |
424 |
void qsamplerChannel::appendMessages( const QString& s ) |
void qsamplerChannel::appendMessages( const QString& s ) |
425 |
{ |
{ |
426 |
m_pMainForm->appendMessages(s); |
if (m_pMainForm) m_pMainForm->appendMessages(s); |
427 |
} |
} |
428 |
|
|
429 |
void qsamplerChannel::appendMessagesColor( const QString& s, const QString& c ) |
void qsamplerChannel::appendMessagesColor( const QString& s, const QString& c ) |
430 |
{ |
{ |
431 |
m_pMainForm->appendMessagesColor(s, c); |
if (m_pMainForm) m_pMainForm->appendMessagesColor(s, c); |
432 |
} |
} |
433 |
|
|
434 |
void qsamplerChannel::appendMessagesText( const QString& s ) |
void qsamplerChannel::appendMessagesText( const QString& s ) |
435 |
{ |
{ |
436 |
m_pMainForm->appendMessagesText(s); |
if (m_pMainForm) m_pMainForm->appendMessagesText(s); |
437 |
} |
} |
438 |
|
|
439 |
void qsamplerChannel::appendMessagesError( const QString& s ) |
void qsamplerChannel::appendMessagesError( const QString& s ) |
440 |
{ |
{ |
441 |
m_pMainForm->appendMessagesError(s); |
if (m_pMainForm) m_pMainForm->appendMessagesError(s); |
442 |
} |
} |
443 |
|
|
444 |
void qsamplerChannel::appendMessagesClient( const QString& s ) |
void qsamplerChannel::appendMessagesClient( const QString& s ) |
445 |
{ |
{ |
446 |
m_pMainForm->appendMessagesClient(s); |
if (m_pMainForm) m_pMainForm->appendMessagesClient(s); |
447 |
|
} |
448 |
|
|
449 |
|
|
450 |
|
// Context menu event handler. |
451 |
|
void qsamplerChannel::contextMenuEvent( QContextMenuEvent *pEvent ) |
452 |
|
{ |
453 |
|
if (m_pMainForm) m_pMainForm->contextMenuEvent(pEvent); |
454 |
} |
} |
455 |
|
|
456 |
|
|
463 |
|
|
464 |
if (fileinfo.exists()) { |
if (fileinfo.exists()) { |
465 |
#ifdef CONFIG_LIBGIG |
#ifdef CONFIG_LIBGIG |
466 |
RIFF::File *pRiff = new RIFF::File(sInstrumentFile); |
if (g_bInstrumentNames) { |
467 |
gig::File *pGig = new gig::File(pRiff); |
RIFF::File *pRiff = new RIFF::File(sInstrumentFile); |
468 |
gig::Instrument *pInstrument = pGig->GetFirstInstrument(); |
gig::File *pGig = new gig::File(pRiff); |
469 |
while (pInstrument) { |
gig::Instrument *pInstrument = pGig->GetFirstInstrument(); |
470 |
sInstrumentName = (pInstrument->pInfo)->Name; |
while (pInstrument) { |
471 |
instlist.append(sInstrumentName); |
instlist.append((pInstrument->pInfo)->Name.c_str()); |
472 |
pInstrument = pGig->GetNextInstrument(); |
pInstrument = pGig->GetNextInstrument(); |
473 |
} |
} |
474 |
delete pGig; |
delete pGig; |
475 |
delete pRiff; |
delete pRiff; |
476 |
#else |
} |
477 |
|
else |
478 |
|
#endif |
479 |
for (int iInstrumentNr = 0; iInstrumentNr < QSAMPLER_INSTRUMENT_MAX; iInstrumentNr++) |
for (int iInstrumentNr = 0; iInstrumentNr < QSAMPLER_INSTRUMENT_MAX; iInstrumentNr++) |
480 |
instlist.append(sInstrumentName + " [" + QString::number(iInstrumentNr) + "]"); |
instlist.append(sInstrumentName + " [" + QString::number(iInstrumentNr) + "]"); |
|
#endif |
|
481 |
} |
} |
482 |
else instlist.append(sInstrumentName); |
else instlist.append(sInstrumentName); |
483 |
|
|
484 |
return instlist; |
return instlist; |
485 |
} |
} |
486 |
|
|
493 |
|
|
494 |
if (fileinfo.exists()) { |
if (fileinfo.exists()) { |
495 |
#ifdef CONFIG_LIBGIG |
#ifdef CONFIG_LIBGIG |
496 |
RIFF::File *pRiff = new RIFF::File(sInstrumentFile); |
if (g_bInstrumentNames) { |
497 |
gig::File *pGig = new gig::File(pRiff); |
RIFF::File *pRiff = new RIFF::File(sInstrumentFile); |
498 |
int iIndex = 0; |
gig::File *pGig = new gig::File(pRiff); |
499 |
gig::Instrument *pInstrument = pGig->GetFirstInstrument(); |
int iIndex = 0; |
500 |
while (pInstrument) { |
gig::Instrument *pInstrument = pGig->GetFirstInstrument(); |
501 |
if (iIndex == iInstrumentNr) { |
while (pInstrument) { |
502 |
sInstrumentName = (pInstrument->pInfo)->Name; |
if (iIndex == iInstrumentNr) { |
503 |
break; |
sInstrumentName = (pInstrument->pInfo)->Name.c_str(); |
504 |
} |
break; |
505 |
iIndex++; |
} |
506 |
pInstrument = pGig->GetNextInstrument(); |
iIndex++; |
507 |
} |
pInstrument = pGig->GetNextInstrument(); |
508 |
delete pGig; |
} |
509 |
delete pRiff; |
delete pGig; |
510 |
#else |
delete pRiff; |
511 |
sInstrumentName += " [" + QString::number(iInstrumentNr) + "]"; |
} |
512 |
|
else |
513 |
#endif |
#endif |
514 |
|
sInstrumentName += " [" + QString::number(iInstrumentNr) + "]"; |
515 |
} |
} |
516 |
|
|
517 |
return sInstrumentName; |
return sInstrumentName; |
518 |
} |
} |
519 |
|
|
520 |
|
|
521 |
|
// Instrument name(s) retrieval mode--global option. |
522 |
|
bool qsamplerChannel::instrumentNames (void) |
523 |
|
{ |
524 |
|
return g_bInstrumentNames; |
525 |
|
} |
526 |
|
|
527 |
|
void qsamplerChannel::setInstrumentNames ( bool bInstrumentNames ) |
528 |
|
{ |
529 |
|
g_bInstrumentNames = bInstrumentNames; |
530 |
|
} |
531 |
|
|
532 |
|
|
533 |
// end of qsamplerChannel.cpp |
// end of qsamplerChannel.cpp |