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. |
170 |
} |
} |
171 |
|
|
172 |
|
|
173 |
|
// Instrument name accessor. |
174 |
|
QString& qsamplerChannel::instrumentName (void) |
175 |
|
{ |
176 |
|
return m_sInstrumentName; |
177 |
|
} |
178 |
|
|
179 |
// Instrument filename accessor. |
// Instrument filename accessor. |
180 |
QString& qsamplerChannel::instrumentFile (void) |
QString& qsamplerChannel::instrumentFile (void) |
181 |
{ |
{ |
205 |
return false; |
return false; |
206 |
} |
} |
207 |
|
|
208 |
|
m_sInstrumentName = getInstrumentName(sInstrumentFile, iInstrumentNr, true); |
209 |
m_sInstrumentFile = sInstrumentFile; |
m_sInstrumentFile = sInstrumentFile; |
210 |
m_iInstrumentNr = iInstrumentNr; |
m_iInstrumentNr = iInstrumentNr; |
211 |
m_iInstrumentStatus = 0; |
m_iInstrumentStatus = 0; |
361 |
} |
} |
362 |
|
|
363 |
|
|
364 |
|
// Istrument name remapper. |
365 |
|
void qsamplerChannel::updateInstrumentName (void) |
366 |
|
{ |
367 |
|
m_sInstrumentName = getInstrumentName(m_sInstrumentFile, |
368 |
|
m_iInstrumentNr, (options() && options()->bInstrumentNames)); |
369 |
|
} |
370 |
|
|
371 |
|
|
372 |
// Update whole channel info state. |
// Update whole channel info state. |
373 |
bool qsamplerChannel::updateChannelInfo (void) |
bool qsamplerChannel::updateChannelInfo (void) |
374 |
{ |
{ |
383 |
return false; |
return false; |
384 |
} |
} |
385 |
|
|
386 |
// Cache in channel information. |
// First, check if intrument name has changed, |
387 |
|
// taking care that instrument name lookup might be expensive, |
388 |
|
// so we better make it only once and when really needed... |
389 |
|
if ((m_sInstrumentFile != pChannelInfo->instrument_file) || |
390 |
|
(m_iInstrumentNr != pChannelInfo->instrument_nr)) { |
391 |
|
m_sInstrumentFile = pChannelInfo->instrument_file; |
392 |
|
m_iInstrumentNr = pChannelInfo->instrument_nr; |
393 |
|
updateInstrumentName(); |
394 |
|
} |
395 |
|
// Cache in other channel information. |
396 |
m_sEngineName = pChannelInfo->engine_name; |
m_sEngineName = pChannelInfo->engine_name; |
|
m_sInstrumentFile = pChannelInfo->instrument_file; |
|
|
m_iInstrumentNr = pChannelInfo->instrument_nr; |
|
397 |
m_iInstrumentStatus = pChannelInfo->instrument_status; |
m_iInstrumentStatus = pChannelInfo->instrument_status; |
398 |
m_iMidiDevice = pChannelInfo->midi_device; |
m_iMidiDevice = pChannelInfo->midi_device; |
399 |
m_iMidiPort = pChannelInfo->midi_port; |
m_iMidiPort = pChannelInfo->midi_port; |
403 |
// Some sanity checks. |
// Some sanity checks. |
404 |
if (m_sEngineName == "NONE") |
if (m_sEngineName == "NONE") |
405 |
m_sEngineName = QString::null; |
m_sEngineName = QString::null; |
406 |
if (m_sInstrumentFile == "NONE") |
if (m_sInstrumentFile == "NONE") { |
407 |
m_sInstrumentFile = QString::null; |
m_sInstrumentFile = QString::null; |
408 |
|
m_sInstrumentName = QString::null; |
409 |
|
} |
410 |
|
|
411 |
return true; |
return true; |
412 |
} |
} |
479 |
|
|
480 |
|
|
481 |
// Retrieve the instrument list of a instrument file (.gig). |
// Retrieve the instrument list of a instrument file (.gig). |
482 |
QStringList qsamplerChannel::getInstrumentList( const QString& sInstrumentFile ) |
QStringList qsamplerChannel::getInstrumentList( const QString& sInstrumentFile, |
483 |
|
bool bInstrumentNames ) |
484 |
{ |
{ |
485 |
QFileInfo fileinfo(sInstrumentFile); |
QFileInfo fileinfo(sInstrumentFile); |
486 |
QString sInstrumentName = fileinfo.fileName(); |
QString sInstrumentName = fileinfo.fileName(); |
488 |
|
|
489 |
if (fileinfo.exists()) { |
if (fileinfo.exists()) { |
490 |
#ifdef CONFIG_LIBGIG |
#ifdef CONFIG_LIBGIG |
491 |
if (g_bInstrumentNames) { |
if (bInstrumentNames) { |
492 |
RIFF::File *pRiff = new RIFF::File(sInstrumentFile); |
RIFF::File *pRiff = new RIFF::File(sInstrumentFile); |
493 |
gig::File *pGig = new gig::File(pRiff); |
gig::File *pGig = new gig::File(pRiff); |
494 |
gig::Instrument *pInstrument = pGig->GetFirstInstrument(); |
gig::Instrument *pInstrument = pGig->GetFirstInstrument(); |
511 |
|
|
512 |
|
|
513 |
// 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. |
514 |
QString qsamplerChannel::getInstrumentName( const QString& sInstrumentFile, int iInstrumentNr ) |
QString qsamplerChannel::getInstrumentName( const QString& sInstrumentFile, |
515 |
|
int iInstrumentNr, bool bInstrumentNames ) |
516 |
{ |
{ |
517 |
QFileInfo fileinfo(sInstrumentFile); |
QFileInfo fileinfo(sInstrumentFile); |
518 |
QString sInstrumentName = fileinfo.fileName(); |
QString sInstrumentName = fileinfo.fileName(); |
519 |
|
|
520 |
if (fileinfo.exists()) { |
if (fileinfo.exists()) { |
521 |
#ifdef CONFIG_LIBGIG |
#ifdef CONFIG_LIBGIG |
522 |
if (g_bInstrumentNames) { |
if (bInstrumentNames) { |
523 |
RIFF::File *pRiff = new RIFF::File(sInstrumentFile); |
RIFF::File *pRiff = new RIFF::File(sInstrumentFile); |
524 |
gig::File *pGig = new gig::File(pRiff); |
gig::File *pGig = new gig::File(pRiff); |
525 |
int iIndex = 0; |
int iIndex = 0; |
544 |
} |
} |
545 |
|
|
546 |
|
|
|
// Instrument name(s) retrieval mode--global option. |
|
|
bool qsamplerChannel::instrumentNames (void) |
|
|
{ |
|
|
return g_bInstrumentNames; |
|
|
} |
|
|
|
|
|
void qsamplerChannel::setInstrumentNames ( bool bInstrumentNames ) |
|
|
{ |
|
|
g_bInstrumentNames = bInstrumentNames; |
|
|
} |
|
|
|
|
|
|
|
547 |
// end of qsamplerChannel.cpp |
// end of qsamplerChannel.cpp |