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 |
// |
// |
|
bool qsamplerChannel::g_bInstrumentNames = false; |
|
41 |
|
|
42 |
// Constructor. |
// Constructor. |
43 |
qsamplerChannel::qsamplerChannel ( qsamplerMainForm *pMainForm, int iChannelID ) |
qsamplerChannel::qsamplerChannel ( qsamplerMainForm *pMainForm, int iChannelID ) |
46 |
m_iChannelID = iChannelID; |
m_iChannelID = iChannelID; |
47 |
|
|
48 |
// m_sEngineName = QObject::tr("(No engine)"); |
// m_sEngineName = QObject::tr("(No engine)"); |
49 |
// m_sInstrumentFile = QObject::tr("(No instrument)"); |
// m_sInstrumentName = QObject::tr("(No instrument)"); |
50 |
|
// m_sInstrumentFile = m_sInstrumentName; |
51 |
m_iInstrumentNr = -1; |
m_iInstrumentNr = -1; |
52 |
m_iInstrumentStatus = -1; |
m_iInstrumentStatus = -1; |
53 |
m_sMidiDriver = "Alsa"; // DEPRECATED. |
m_sMidiDriver = "Alsa"; // DEPRECATED. |
182 |
return m_iInstrumentNr; |
return m_iInstrumentNr; |
183 |
} |
} |
184 |
|
|
185 |
|
// Instrument name accessor. |
186 |
|
QString& qsamplerChannel::instrumentName (void) |
187 |
|
{ |
188 |
|
return m_sInstrumentName; |
189 |
|
} |
190 |
|
|
191 |
// Instrument status accessor. |
// Instrument status accessor. |
192 |
int qsamplerChannel::instrumentStatus (void) |
int qsamplerChannel::instrumentStatus (void) |
193 |
{ |
{ |
207 |
|
|
208 |
m_sInstrumentFile = sInstrumentFile; |
m_sInstrumentFile = sInstrumentFile; |
209 |
m_iInstrumentNr = iInstrumentNr; |
m_iInstrumentNr = iInstrumentNr; |
210 |
|
#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 |
m_iInstrumentStatus = 0; |
m_iInstrumentStatus = 0; |
216 |
|
|
217 |
return true; |
return true; |
365 |
} |
} |
366 |
|
|
367 |
|
|
368 |
|
// Istrument name remapper. |
369 |
|
void qsamplerChannel::updateInstrumentName (void) |
370 |
|
{ |
371 |
|
#ifndef CONFIG_INSTRUMENT_NAME |
372 |
|
m_sInstrumentName = getInstrumentName(m_sInstrumentFile, |
373 |
|
m_iInstrumentNr, (options() && options()->bInstrumentNames)); |
374 |
|
#endif |
375 |
|
} |
376 |
|
|
377 |
|
|
378 |
// Update whole channel info state. |
// Update whole channel info state. |
379 |
bool qsamplerChannel::updateChannelInfo (void) |
bool qsamplerChannel::updateChannelInfo (void) |
380 |
{ |
{ |
389 |
return false; |
return false; |
390 |
} |
} |
391 |
|
|
392 |
// Cache in channel information. |
#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 |
|
// 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 |
|
} |
407 |
|
#endif |
408 |
|
// Cache in other channel information. |
409 |
m_sEngineName = pChannelInfo->engine_name; |
m_sEngineName = pChannelInfo->engine_name; |
|
m_sInstrumentFile = pChannelInfo->instrument_file; |
|
|
m_iInstrumentNr = pChannelInfo->instrument_nr; |
|
410 |
m_iInstrumentStatus = pChannelInfo->instrument_status; |
m_iInstrumentStatus = pChannelInfo->instrument_status; |
411 |
m_iMidiDevice = pChannelInfo->midi_device; |
m_iMidiDevice = pChannelInfo->midi_device; |
412 |
m_iMidiPort = pChannelInfo->midi_port; |
m_iMidiPort = pChannelInfo->midi_port; |
416 |
// Some sanity checks. |
// Some sanity checks. |
417 |
if (m_sEngineName == "NONE") |
if (m_sEngineName == "NONE") |
418 |
m_sEngineName = QString::null; |
m_sEngineName = QString::null; |
419 |
if (m_sInstrumentFile == "NONE") |
if (m_sInstrumentFile == "NONE") { |
420 |
m_sInstrumentFile = QString::null; |
m_sInstrumentFile = QString::null; |
421 |
|
m_sInstrumentName = QString::null; |
422 |
|
} |
423 |
|
|
424 |
return true; |
return true; |
425 |
} |
} |
492 |
|
|
493 |
|
|
494 |
// Retrieve the instrument list of a instrument file (.gig). |
// Retrieve the instrument list of a instrument file (.gig). |
495 |
QStringList qsamplerChannel::getInstrumentList( const QString& sInstrumentFile ) |
QStringList qsamplerChannel::getInstrumentList( const QString& sInstrumentFile, |
496 |
|
bool bInstrumentNames ) |
497 |
{ |
{ |
498 |
QFileInfo fileinfo(sInstrumentFile); |
QFileInfo fileinfo(sInstrumentFile); |
499 |
QString sInstrumentName = fileinfo.fileName(); |
QString sInstrumentName = fileinfo.fileName(); |
501 |
|
|
502 |
if (fileinfo.exists()) { |
if (fileinfo.exists()) { |
503 |
#ifdef CONFIG_LIBGIG |
#ifdef CONFIG_LIBGIG |
504 |
if (g_bInstrumentNames) { |
if (bInstrumentNames) { |
505 |
RIFF::File *pRiff = new RIFF::File(sInstrumentFile); |
RIFF::File *pRiff = new RIFF::File(sInstrumentFile); |
506 |
gig::File *pGig = new gig::File(pRiff); |
gig::File *pGig = new gig::File(pRiff); |
507 |
gig::Instrument *pInstrument = pGig->GetFirstInstrument(); |
gig::Instrument *pInstrument = pGig->GetFirstInstrument(); |
513 |
delete pRiff; |
delete pRiff; |
514 |
} |
} |
515 |
else |
else |
516 |
#else |
#endif |
517 |
for (int iInstrumentNr = 0; iInstrumentNr < QSAMPLER_INSTRUMENT_MAX; iInstrumentNr++) |
for (int iInstrumentNr = 0; iInstrumentNr < QSAMPLER_INSTRUMENT_MAX; iInstrumentNr++) |
518 |
instlist.append(sInstrumentName + " [" + QString::number(iInstrumentNr) + "]"); |
instlist.append(sInstrumentName + " [" + QString::number(iInstrumentNr) + "]"); |
|
#endif |
|
519 |
} |
} |
520 |
else instlist.append(sInstrumentName); |
else instlist.append(sInstrumentName); |
521 |
|
|
524 |
|
|
525 |
|
|
526 |
// Retrieve the spacific instrument name of a instrument file (.gig), given its index. |
// Retrieve the spacific instrument name of a instrument file (.gig), given its index. |
527 |
QString qsamplerChannel::getInstrumentName( const QString& sInstrumentFile, int iInstrumentNr ) |
QString qsamplerChannel::getInstrumentName( const QString& sInstrumentFile, |
528 |
|
int iInstrumentNr, bool bInstrumentNames ) |
529 |
{ |
{ |
530 |
QFileInfo fileinfo(sInstrumentFile); |
QFileInfo fileinfo(sInstrumentFile); |
531 |
QString sInstrumentName = fileinfo.fileName(); |
QString sInstrumentName = fileinfo.fileName(); |
532 |
|
|
533 |
if (fileinfo.exists()) { |
if (fileinfo.exists()) { |
534 |
#ifdef CONFIG_LIBGIG |
#ifdef CONFIG_LIBGIG |
535 |
if (g_bInstrumentNames) { |
if (bInstrumentNames) { |
536 |
RIFF::File *pRiff = new RIFF::File(sInstrumentFile); |
RIFF::File *pRiff = new RIFF::File(sInstrumentFile); |
537 |
gig::File *pGig = new gig::File(pRiff); |
gig::File *pGig = new gig::File(pRiff); |
538 |
int iIndex = 0; |
int iIndex = 0; |
549 |
delete pRiff; |
delete pRiff; |
550 |
} |
} |
551 |
else |
else |
|
#else |
|
|
sInstrumentName += " [" + QString::number(iInstrumentNr) + "]"; |
|
552 |
#endif |
#endif |
553 |
|
sInstrumentName += " [" + QString::number(iInstrumentNr) + "]"; |
554 |
} |
} |
555 |
|
|
556 |
return sInstrumentName; |
return sInstrumentName; |
557 |
} |
} |
558 |
|
|
559 |
|
|
|
// Instrument name(s) retrieval mode--global option. |
|
|
bool qsamplerChannel::instrumentNames (void) |
|
|
{ |
|
|
return g_bInstrumentNames; |
|
|
} |
|
|
|
|
|
void qsamplerChannel::setInstrumentNames ( bool bInstrumentNames ) |
|
|
{ |
|
|
g_bInstrumentNames = bInstrumentNames; |
|
|
} |
|
|
|
|
|
|
|
560 |
// end of qsamplerChannel.cpp |
// end of qsamplerChannel.cpp |