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 |
|
|
29 |
|
#include <qfileinfo.h> |
30 |
|
|
31 |
|
#ifdef CONFIG_LIBGIG |
32 |
|
#include "gig.h" |
33 |
|
#else |
34 |
|
#define QSAMPLER_INSTRUMENT_MAX 8 |
35 |
|
#endif |
36 |
|
|
37 |
|
|
38 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
39 |
// qsamplerChannel - Sampler channel structure. |
// qsamplerChannel - Sampler channel structure. |
403 |
} |
} |
404 |
|
|
405 |
|
|
406 |
|
// Channel setup dialog form. |
407 |
|
bool qsamplerChannel::channelSetup ( QWidget *pParent ) |
408 |
|
{ |
409 |
|
bool bResult = false; |
410 |
|
|
411 |
|
qsamplerChannelForm *pChannelForm = new qsamplerChannelForm(pParent); |
412 |
|
if (pChannelForm) { |
413 |
|
pChannelForm->setup(this); |
414 |
|
bResult = pChannelForm->exec(); |
415 |
|
delete pChannelForm; |
416 |
|
} |
417 |
|
|
418 |
|
return bResult; |
419 |
|
} |
420 |
|
|
421 |
|
|
422 |
// Redirected messages output methods. |
// Redirected messages output methods. |
423 |
void qsamplerChannel::appendMessages( const QString& s ) |
void qsamplerChannel::appendMessages( const QString& s ) |
424 |
{ |
{ |
425 |
m_pMainForm->appendMessages(s); |
if (m_pMainForm) m_pMainForm->appendMessages(s); |
426 |
} |
} |
427 |
|
|
428 |
void qsamplerChannel::appendMessagesColor( const QString& s, const QString& c ) |
void qsamplerChannel::appendMessagesColor( const QString& s, const QString& c ) |
429 |
{ |
{ |
430 |
m_pMainForm->appendMessagesColor(s, c); |
if (m_pMainForm) m_pMainForm->appendMessagesColor(s, c); |
431 |
} |
} |
432 |
|
|
433 |
void qsamplerChannel::appendMessagesText( const QString& s ) |
void qsamplerChannel::appendMessagesText( const QString& s ) |
434 |
{ |
{ |
435 |
m_pMainForm->appendMessagesText(s); |
if (m_pMainForm) m_pMainForm->appendMessagesText(s); |
436 |
} |
} |
437 |
|
|
438 |
void qsamplerChannel::appendMessagesError( const QString& s ) |
void qsamplerChannel::appendMessagesError( const QString& s ) |
439 |
{ |
{ |
440 |
m_pMainForm->appendMessagesError(s); |
if (m_pMainForm) m_pMainForm->appendMessagesError(s); |
441 |
} |
} |
442 |
|
|
443 |
void qsamplerChannel::appendMessagesClient( const QString& s ) |
void qsamplerChannel::appendMessagesClient( const QString& s ) |
444 |
{ |
{ |
445 |
m_pMainForm->appendMessagesClient(s); |
if (m_pMainForm) m_pMainForm->appendMessagesClient(s); |
446 |
|
} |
447 |
|
|
448 |
|
|
449 |
|
// Context menu event handler. |
450 |
|
void qsamplerChannel::contextMenuEvent( QContextMenuEvent *pEvent ) |
451 |
|
{ |
452 |
|
if (m_pMainForm) m_pMainForm->contextMenuEvent(pEvent); |
453 |
|
} |
454 |
|
|
455 |
|
|
456 |
|
// Retrieve the instrument list of a instrument file (.gig). |
457 |
|
QStringList qsamplerChannel::getInstrumentList( const QString& sInstrumentFile ) |
458 |
|
{ |
459 |
|
QFileInfo fileinfo(sInstrumentFile); |
460 |
|
QString sInstrumentName = fileinfo.fileName(); |
461 |
|
QStringList instlist; |
462 |
|
|
463 |
|
if (fileinfo.exists()) { |
464 |
|
#ifdef CONFIG_LIBGIG |
465 |
|
RIFF::File *pRiff = new RIFF::File(sInstrumentFile); |
466 |
|
gig::File *pGig = new gig::File(pRiff); |
467 |
|
gig::Instrument *pInstrument = pGig->GetFirstInstrument(); |
468 |
|
while (pInstrument) { |
469 |
|
sInstrumentName = (pInstrument->pInfo)->Name; |
470 |
|
instlist.append(sInstrumentName); |
471 |
|
pInstrument = pGig->GetNextInstrument(); |
472 |
|
} |
473 |
|
delete pGig; |
474 |
|
delete pRiff; |
475 |
|
#else |
476 |
|
for (int iInstrumentNr = 0; iInstrumentNr < QSAMPLER_INSTRUMENT_MAX; iInstrumentNr++) |
477 |
|
instlist.append(sInstrumentName + " [" + QString::number(iInstrumentNr) + "]"); |
478 |
|
#endif |
479 |
|
} |
480 |
|
else instlist.append(sInstrumentName); |
481 |
|
|
482 |
|
return instlist; |
483 |
|
} |
484 |
|
|
485 |
|
|
486 |
|
// Retrieve the spacific instrument name of a instrument file (.gig), given its index. |
487 |
|
QString qsamplerChannel::getInstrumentName( const QString& sInstrumentFile, int iInstrumentNr ) |
488 |
|
{ |
489 |
|
QFileInfo fileinfo(sInstrumentFile); |
490 |
|
QString sInstrumentName = fileinfo.fileName(); |
491 |
|
|
492 |
|
if (fileinfo.exists()) { |
493 |
|
#ifdef CONFIG_LIBGIG |
494 |
|
RIFF::File *pRiff = new RIFF::File(sInstrumentFile); |
495 |
|
gig::File *pGig = new gig::File(pRiff); |
496 |
|
int iIndex = 0; |
497 |
|
gig::Instrument *pInstrument = pGig->GetFirstInstrument(); |
498 |
|
while (pInstrument) { |
499 |
|
if (iIndex == iInstrumentNr) { |
500 |
|
sInstrumentName = (pInstrument->pInfo)->Name; |
501 |
|
break; |
502 |
|
} |
503 |
|
iIndex++; |
504 |
|
pInstrument = pGig->GetNextInstrument(); |
505 |
|
} |
506 |
|
delete pGig; |
507 |
|
delete pRiff; |
508 |
|
#else |
509 |
|
sInstrumentName += " [" + QString::number(iInstrumentNr) + "]"; |
510 |
|
#endif |
511 |
|
} |
512 |
|
|
513 |
|
return sInstrumentName; |
514 |
} |
} |
515 |
|
|
516 |
|
|