25 |
|
|
26 |
#include "config.h" |
#include "config.h" |
27 |
|
|
28 |
|
#include <qfileinfo.h> |
29 |
|
|
30 |
|
#ifdef CONFIG_LIBGIG |
31 |
|
#include "gig.h" |
32 |
|
#else |
33 |
|
#define QSAMPLER_INSTRUMENT_MAX 10 |
34 |
|
#endif |
35 |
|
|
36 |
|
|
37 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
38 |
// qsamplerChannel - Sampler channel structure. |
// qsamplerChannel - Sampler channel structure. |
429 |
} |
} |
430 |
|
|
431 |
|
|
432 |
|
// Retrieve the instrument list of a instrument file (.gig). |
433 |
|
QStringList qsamplerChannel::getInstrumentList( const QString& sInstrumentFile ) |
434 |
|
{ |
435 |
|
QFileInfo fileinfo(sInstrumentFile); |
436 |
|
QString sInstrumentName = fileinfo.fileName(); |
437 |
|
QStringList instlist; |
438 |
|
|
439 |
|
if (fileinfo.exists()) { |
440 |
|
#ifdef CONFIG_LIBGIG |
441 |
|
RIFF::File *pRiff = new RIFF::File(sInstrumentFile); |
442 |
|
gig::File *pGig = new gig::File(pRiff); |
443 |
|
gig::Instrument *pInstrument = pGig->GetFirstInstrument(); |
444 |
|
while (pInstrument) { |
445 |
|
sInstrumentName = (pInstrument->pInfo)->Name; |
446 |
|
instlist.append(sInstrumentName); |
447 |
|
pInstrument = pGig->GetNextInstrument(); |
448 |
|
} |
449 |
|
delete pGig; |
450 |
|
delete pRiff; |
451 |
|
#else |
452 |
|
for (int iInstrumentNr = 0; iInstrumentNr < QSAMPLER_INSTRUMENT_MAX; iInstrumentNr++) |
453 |
|
instlist.append(sInstrumentName + " [" + QString::number(iInstrumentNr) + "]"); |
454 |
|
#endif |
455 |
|
} |
456 |
|
else instlist.append(sInstrumentName); |
457 |
|
|
458 |
|
return instlist; |
459 |
|
} |
460 |
|
|
461 |
|
|
462 |
|
// Retrieve the spacific instrument name of a instrument file (.gig), given its index. |
463 |
|
QString qsamplerChannel::getInstrumentName( const QString& sInstrumentFile, int iInstrumentNr ) |
464 |
|
{ |
465 |
|
QFileInfo fileinfo(sInstrumentFile); |
466 |
|
QString sInstrumentName = fileinfo.fileName(); |
467 |
|
|
468 |
|
if (fileinfo.exists()) { |
469 |
|
#ifdef CONFIG_LIBGIG |
470 |
|
RIFF::File *pRiff = new RIFF::File(sInstrumentFile); |
471 |
|
gig::File *pGig = new gig::File(pRiff); |
472 |
|
int iIndex = 0; |
473 |
|
gig::Instrument *pInstrument = pGig->GetFirstInstrument(); |
474 |
|
while (pInstrument) { |
475 |
|
if (iIndex == iInstrumentNr) { |
476 |
|
sInstrumentName = (pInstrument->pInfo)->Name; |
477 |
|
break; |
478 |
|
} |
479 |
|
iIndex++; |
480 |
|
pInstrument = pGig->GetNextInstrument(); |
481 |
|
} |
482 |
|
delete pGig; |
483 |
|
delete pRiff; |
484 |
|
#else |
485 |
|
sInstrumentName += " [" + QString::number(iInstrumentNr) + "]"; |
486 |
|
#endif |
487 |
|
} |
488 |
|
|
489 |
|
return sInstrumentName; |
490 |
|
} |
491 |
|
|
492 |
|
|
493 |
// end of qsamplerChannel.cpp |
// end of qsamplerChannel.cpp |