1 |
// qsamplerInstrumentForm.cpp |
// qsamplerInstrumentForm.cpp |
2 |
// |
// |
3 |
/**************************************************************************** |
/**************************************************************************** |
4 |
Copyright (C) 2003-2007, rncbc aka Rui Nuno Capela. All rights reserved. |
Copyright (C) 2003-2009, rncbc aka Rui Nuno Capela. All rights reserved. |
5 |
Copyright (C) 2007, Christian Schoenebeck |
Copyright (C) 2007, Christian Schoenebeck |
6 |
|
|
7 |
This program is free software; you can redistribute it and/or |
This program is free software; you can redistribute it and/or |
33 |
// Needed for lroundf() |
// Needed for lroundf() |
34 |
#include <math.h> |
#include <math.h> |
35 |
|
|
|
|
|
|
namespace QSampler { |
|
|
|
|
36 |
#ifndef CONFIG_ROUND |
#ifndef CONFIG_ROUND |
37 |
static inline long lroundf ( float x ) |
static inline long lroundf ( float x ) |
38 |
{ |
{ |
43 |
} |
} |
44 |
#endif |
#endif |
45 |
|
|
46 |
|
|
47 |
|
namespace QSampler { |
48 |
|
|
49 |
|
//------------------------------------------------------------------------- |
50 |
|
// QSampler::InstrumentForm -- Instrument map item form implementation. |
51 |
|
// |
52 |
|
|
53 |
InstrumentForm::InstrumentForm ( QWidget* pParent ) |
InstrumentForm::InstrumentForm ( QWidget* pParent ) |
54 |
: QDialog(pParent) |
: QDialog(pParent) |
55 |
{ |
{ |
111 |
|
|
112 |
|
|
113 |
// Channel dialog setup formal initializer. |
// Channel dialog setup formal initializer. |
114 |
void InstrumentForm::setup ( qsamplerInstrument *pInstrument ) |
void InstrumentForm::setup ( Instrument *pInstrument ) |
115 |
{ |
{ |
116 |
m_pInstrument = pInstrument; |
m_pInstrument = pInstrument; |
117 |
|
|
129 |
if (pMainForm->client() == NULL) |
if (pMainForm->client() == NULL) |
130 |
return; |
return; |
131 |
|
|
132 |
qsamplerOptions *pOptions = pMainForm->options(); |
Options *pOptions = pMainForm->options(); |
133 |
if (pOptions == NULL) |
if (pOptions == NULL) |
134 |
return; |
return; |
135 |
|
|
148 |
|
|
149 |
// Populate maps list. |
// Populate maps list. |
150 |
m_ui.MapComboBox->clear(); |
m_ui.MapComboBox->clear(); |
151 |
m_ui.MapComboBox->insertItems(0, qsamplerInstrument::getMapNames()); |
m_ui.MapComboBox->insertItems(0, Instrument::getMapNames()); |
152 |
|
|
153 |
// Populate Engines list. |
// Populate Engines list. |
154 |
const char **ppszEngines |
const char **ppszEngines |
167 |
int iMap = (bNew ? pOptions->iMidiMap : m_pInstrument->map()); |
int iMap = (bNew ? pOptions->iMidiMap : m_pInstrument->map()); |
168 |
if (iMap < 0) |
if (iMap < 0) |
169 |
iMap = 0; |
iMap = 0; |
170 |
const QString& sMapName = qsamplerInstrument::getMapName(iMap); |
const QString& sMapName = Instrument::getMapName(iMap); |
171 |
if (!sMapName.isEmpty()) { |
if (!sMapName.isEmpty()) { |
172 |
m_ui.MapComboBox->setItemText( |
m_ui.MapComboBox->setCurrentIndex( |
173 |
m_ui.MapComboBox->currentIndex(), |
m_ui.MapComboBox->findText(sMapName, |
174 |
sMapName); |
Qt::MatchExactly | Qt::MatchCaseSensitive)); |
175 |
} |
} |
176 |
|
|
177 |
// It might be no maps around... |
// It might be no maps around... |
178 |
bool bMapEnabled = (m_ui.MapComboBox->count() > 0); |
bool bMapEnabled = (m_ui.MapComboBox->count() > 0); |
179 |
m_ui.MapTextLabel->setEnabled(bMapEnabled); |
m_ui.MapTextLabel->setEnabled(bMapEnabled); |
197 |
if (sEngineName.isEmpty() || bNew) |
if (sEngineName.isEmpty() || bNew) |
198 |
sEngineName = pOptions->sEngineName; |
sEngineName = pOptions->sEngineName; |
199 |
if (sEngineName.isEmpty()) |
if (sEngineName.isEmpty()) |
200 |
sEngineName = qsamplerChannel::noEngineName(); |
sEngineName = Channel::noEngineName(); |
201 |
if (m_ui.EngineNameComboBox->findText(sEngineName, |
if (m_ui.EngineNameComboBox->findText(sEngineName, |
202 |
Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) { |
Qt::MatchExactly | Qt::MatchCaseSensitive) < 0) { |
203 |
m_ui.EngineNameComboBox->addItem(sEngineName); |
m_ui.EngineNameComboBox->addItem(sEngineName); |
209 |
// Instrument filename and index... |
// Instrument filename and index... |
210 |
QString sInstrumentFile = m_pInstrument->instrumentFile(); |
QString sInstrumentFile = m_pInstrument->instrumentFile(); |
211 |
if (sInstrumentFile.isEmpty()) |
if (sInstrumentFile.isEmpty()) |
212 |
sInstrumentFile = qsamplerChannel::noInstrumentName(); |
sInstrumentFile = Channel::noInstrumentName(); |
213 |
m_ui.InstrumentFileComboBox->setEditText(sInstrumentFile); |
m_ui.InstrumentFileComboBox->setEditText(sInstrumentFile); |
214 |
m_ui.InstrumentNrComboBox->clear(); |
m_ui.InstrumentNrComboBox->clear(); |
215 |
m_ui.InstrumentNrComboBox->insertItems(0, |
m_ui.InstrumentNrComboBox->insertItems(0, |
216 |
qsamplerChannel::getInstrumentList(sInstrumentFile, |
Channel::getInstrumentList(sInstrumentFile, |
217 |
pOptions->bInstrumentNames)); |
pOptions->bInstrumentNames)); |
218 |
m_ui.InstrumentNrComboBox->setCurrentIndex(m_pInstrument->instrumentNr()); |
m_ui.InstrumentNrComboBox->setCurrentIndex(m_pInstrument->instrumentNr()); |
219 |
|
|
255 |
if (pMainForm == NULL) |
if (pMainForm == NULL) |
256 |
return; |
return; |
257 |
|
|
258 |
qsamplerOptions *pOptions = pMainForm->options(); |
Options *pOptions = pMainForm->options(); |
259 |
if (pOptions == NULL) |
if (pOptions == NULL) |
260 |
return; |
return; |
261 |
|
|
282 |
if (pMainForm == NULL) |
if (pMainForm == NULL) |
283 |
return; |
return; |
284 |
|
|
285 |
qsamplerOptions *pOptions = pMainForm->options(); |
Options *pOptions = pMainForm->options(); |
286 |
if (pOptions == NULL) |
if (pOptions == NULL) |
287 |
return; |
return; |
288 |
|
|
290 |
// to retrieve the REAL instrument names. |
// to retrieve the REAL instrument names. |
291 |
m_ui.InstrumentNrComboBox->clear(); |
m_ui.InstrumentNrComboBox->clear(); |
292 |
m_ui.InstrumentNrComboBox->insertItems(0, |
m_ui.InstrumentNrComboBox->insertItems(0, |
293 |
qsamplerChannel::getInstrumentList( |
Channel::getInstrumentList( |
294 |
m_ui.InstrumentFileComboBox->currentText(), |
m_ui.InstrumentFileComboBox->currentText(), |
295 |
pOptions->bInstrumentNames) |
pOptions->bInstrumentNames) |
296 |
); |
); |
326 |
if (pMainForm->client() == NULL) |
if (pMainForm->client() == NULL) |
327 |
return; |
return; |
328 |
|
|
329 |
qsamplerOptions *pOptions = pMainForm->options(); |
Options *pOptions = pMainForm->options(); |
330 |
if (pOptions == NULL) |
if (pOptions == NULL) |
331 |
return; |
return; |
332 |
|
|
369 |
QSAMPLER_TITLE ": " + tr("Warning"), |
QSAMPLER_TITLE ": " + tr("Warning"), |
370 |
tr("Some channel settings have been changed.\n\n" |
tr("Some channel settings have been changed.\n\n" |
371 |
"Do you want to apply the changes?"), |
"Do you want to apply the changes?"), |
372 |
tr("Apply"), tr("Discard"), tr("Cancel"))) { |
QMessageBox::Apply | |
373 |
case 0: // Apply... |
QMessageBox::Discard | |
374 |
|
QMessageBox::Cancel)) { |
375 |
|
case QMessageBox::Apply: |
376 |
accept(); |
accept(); |
377 |
return; |
return; |
378 |
case 1: // Discard |
case QMessageBox::Discard: |
379 |
break; |
break; |
380 |
default: // Cancel. |
default: // Cancel. |
381 |
bReject = false; |
bReject = false; |
406 |
!m_ui.NameLineEdit->text().isEmpty() && |
!m_ui.NameLineEdit->text().isEmpty() && |
407 |
m_ui.EngineNameComboBox->currentIndex() >= 0 && |
m_ui.EngineNameComboBox->currentIndex() >= 0 && |
408 |
m_ui.EngineNameComboBox->currentText() != |
m_ui.EngineNameComboBox->currentText() != |
409 |
qsamplerChannel::noEngineName(); |
Channel::noEngineName(); |
410 |
|
|
411 |
const QString& sPath = m_ui.InstrumentFileComboBox->currentText(); |
const QString& sPath = m_ui.InstrumentFileComboBox->currentText(); |
412 |
bValid = bValid && !sPath.isEmpty() && QFileInfo(sPath).exists(); |
bValid = bValid && !sPath.isEmpty() && QFileInfo(sPath).exists(); |