25 |
#include "qsamplerInstrument.h" |
#include "qsamplerInstrument.h" |
26 |
#include "qsamplerInstrumentForm.h" |
#include "qsamplerInstrumentForm.h" |
27 |
|
|
28 |
|
#include "qsamplerOptions.h" |
29 |
#include "qsamplerMainForm.h" |
#include "qsamplerMainForm.h" |
30 |
|
|
31 |
|
#include <qmessagebox.h> |
32 |
#include <qaction.h> |
#include <qaction.h> |
33 |
#include <qfileinfo.h> |
#include <qfileinfo.h> |
34 |
#include <qpopupmenu.h> |
#include <qpopupmenu.h> |
36 |
// Needed for lroundf() |
// Needed for lroundf() |
37 |
#include <math.h> |
#include <math.h> |
38 |
|
|
39 |
#ifdef __BORLANDC__ |
#ifndef CONFIG_ROUND |
40 |
static long lroundf ( float fval ) |
static inline long lroundf ( float x ) |
41 |
{ |
{ |
42 |
double fint = 0.0; |
if (x >= 0.0f) |
43 |
float frac = float(::modf(fval, &fint)); |
return long(x + 0.5f); |
44 |
long lint = long(fint); |
else |
45 |
if (frac >= +0.5f) |
return long(x - 0.5f); |
|
lint++; |
|
|
else |
|
|
if (frac <= -0.5f) |
|
|
lint--; |
|
|
return lint; |
|
46 |
} |
} |
47 |
#endif |
#endif |
48 |
|
|
189 |
const QString s = "-"; |
const QString s = "-"; |
190 |
if (m_pInstrument) { |
if (m_pInstrument) { |
191 |
setText(0, m_pInstrument->name()); |
setText(0, m_pInstrument->name()); |
192 |
setText(1, QString::number(m_pInstrument->bank())); |
setText(1, QString::number(m_pInstrument->map())); |
193 |
setText(2, QString::number(m_pInstrument->program() + 1)); |
setText(2, QString::number(m_pInstrument->bank())); |
194 |
setText(3, m_pInstrument->engineName()); |
setText(3, QString::number(m_pInstrument->prog() + 1)); |
195 |
setText(4, QFileInfo(m_pInstrument->instrumentFile()).fileName()); |
setText(4, m_pInstrument->engineName()); |
196 |
setText(5, QString::number(m_pInstrument->instrumentNr())); |
setText(5, QFileInfo(m_pInstrument->instrumentFile()).fileName()); |
197 |
setText(6, QString::number(::lroundf(100.0f * m_pInstrument->volume()))); |
setText(6, QString::number(m_pInstrument->instrumentNr())); |
198 |
|
setText(7, QString::number(::lroundf(100.0f * m_pInstrument->volume()))); |
199 |
QString sLoadMode = s; |
QString sLoadMode = s; |
200 |
switch (m_pInstrument->loadMode()) { |
switch (m_pInstrument->loadMode()) { |
201 |
case 3: |
case 3: |
208 |
sLoadMode = QObject::tr("On Demand"); |
sLoadMode = QObject::tr("On Demand"); |
209 |
break; |
break; |
210 |
} |
} |
211 |
setText(7, sLoadMode); |
setText(8, sLoadMode); |
212 |
} else { |
} else { |
213 |
for (int i = 0; i < listView()->columns(); i++) |
for (int i = 0; i < listView()->columns(); i++) |
214 |
setText(i, s); |
setText(i, s); |
235 |
QListView::setSortColumn(-1); |
QListView::setSortColumn(-1); |
236 |
|
|
237 |
QListView::addColumn(tr("Name")); |
QListView::addColumn(tr("Name")); |
238 |
|
QListView::addColumn(tr("Map")); |
239 |
QListView::addColumn(tr("Bank")); |
QListView::addColumn(tr("Bank")); |
240 |
QListView::addColumn(tr("Prog")); |
QListView::addColumn(tr("Prog")); |
241 |
QListView::addColumn(tr("Engine")); |
QListView::addColumn(tr("Engine")); |
244 |
QListView::addColumn(tr("Vol")); |
QListView::addColumn(tr("Vol")); |
245 |
QListView::addColumn(tr("Mode")); |
QListView::addColumn(tr("Mode")); |
246 |
|
|
247 |
QListView::setColumnAlignment(1, Qt::AlignHCenter); // Bank |
QListView::setColumnAlignment(1, Qt::AlignHCenter); // Map |
248 |
QListView::setColumnAlignment(2, Qt::AlignHCenter); // Prog |
QListView::setColumnAlignment(2, Qt::AlignHCenter); // Bank |
249 |
QListView::setColumnAlignment(5, Qt::AlignHCenter); // Nr |
QListView::setColumnAlignment(3, Qt::AlignHCenter); // Prog |
250 |
QListView::setColumnAlignment(6, Qt::AlignHCenter); // Vol |
QListView::setColumnAlignment(6, Qt::AlignHCenter); // Nr |
251 |
|
QListView::setColumnAlignment(7, Qt::AlignHCenter); // Vol |
252 |
|
|
253 |
QListView::setColumnWidth(0, 60); // Name |
QListView::setColumnWidth(0, 120); // Name |
254 |
QListView::setColumnWidth(0, 120); // File |
QListView::setColumnWidth(5, 240); // File |
255 |
|
|
256 |
m_pNewGroupAction = new QAction(tr("New &Group"), tr("Ctrl+G"), this); |
m_pNewGroupAction = new QAction(tr("New &Group"), tr("Ctrl+G"), this); |
257 |
m_pNewItemAction = new QAction(tr("New &Instrument..."), tr("Ctrl+I"), this); |
m_pNewItemAction = new QAction(tr("New &Instrument..."), tr("Ins"), this); |
258 |
m_pEditItemAction = new QAction(tr("&Edit..."), tr("Ctrl+E"), this); |
m_pEditItemAction = new QAction(tr("&Edit..."), tr("Enter"), this); |
259 |
m_pRenameAction = new QAction(tr("&Rename"), tr("Ctrl+R"), this); |
m_pRenameAction = new QAction(tr("&Rename"), tr("F2"), this); |
260 |
m_pDeleteAction = new QAction(tr("&Delete"), tr("Ctrl+D"), this); |
m_pDeleteAction = new QAction(tr("&Delete"), tr("Del"), this); |
261 |
m_pRefreshAction = new QAction(tr("Re&fresh"), tr("Ctrl+F"), this); |
m_pRefreshAction = new QAction(tr("Re&fresh"), tr("F5"), this); |
262 |
|
|
263 |
QObject::connect(m_pNewGroupAction, |
QObject::connect(m_pNewGroupAction, |
264 |
SIGNAL(activated()), |
SIGNAL(activated()), |
372 |
qsamplerInstrumentItem *pItem |
qsamplerInstrumentItem *pItem |
373 |
= static_cast<qsamplerInstrumentItem *> (pListItem); |
= static_cast<qsamplerInstrumentItem *> (pListItem); |
374 |
if (pItem && pItem->instrument() |
if (pItem && pItem->instrument() |
375 |
|
&& pItem->instrument()->map() == pInstrument->map() |
376 |
&& pItem->instrument()->bank() == pInstrument->bank() |
&& pItem->instrument()->bank() == pInstrument->bank() |
377 |
&& pItem->instrument()->program() == pInstrument->program()) |
&& pItem->instrument()->prog() == pInstrument->prog()) |
378 |
return pItem; |
return pItem; |
379 |
} |
} |
380 |
++iter; |
++iter; |
429 |
if (pItem) |
if (pItem) |
430 |
delete pItem; |
delete pItem; |
431 |
|
|
432 |
pInstrument->map(); |
pInstrument->mapInstrument(); |
433 |
emit instrumentsChanged(); |
emit instrumentsChanged(); |
434 |
|
|
435 |
qsamplerInstrumentGroup *pParentGroup |
qsamplerInstrumentGroup *pParentGroup |
455 |
qsamplerInstrumentForm form(this); |
qsamplerInstrumentForm form(this); |
456 |
form.setup(pItem->instrument()); |
form.setup(pItem->instrument()); |
457 |
if (form.exec()) { |
if (form.exec()) { |
458 |
pItem->instrument()->map(); |
pItem->instrument()->mapInstrument(); |
459 |
emit instrumentsChanged(); |
emit instrumentsChanged(); |
460 |
pItem->update(); |
pItem->update(); |
461 |
} |
} |
481 |
void qsamplerInstrumentList::deleteSlot (void) |
void qsamplerInstrumentList::deleteSlot (void) |
482 |
{ |
{ |
483 |
QListViewItem *pListItem = QListView::selectedItem(); |
QListViewItem *pListItem = QListView::selectedItem(); |
484 |
if (pListItem) { |
if (pListItem == NULL) |
485 |
if (pListItem->rtti() == Item) { |
return; |
486 |
qsamplerInstrumentItem *pItem |
|
487 |
= static_cast<qsamplerInstrumentItem *> (pListItem); |
qsamplerMainForm *pMainForm = qsamplerMainForm::getInstance(); |
488 |
if (pItem && pItem->instrument()) { |
if (pMainForm == NULL) |
489 |
pItem->instrument()->unmap(); |
return; |
490 |
emit instrumentsChanged(); |
|
491 |
} |
// Prompt user if this is for real... |
492 |
|
qsamplerOptions *pOptions = pMainForm->options(); |
493 |
|
if (pOptions && pOptions->bConfirmRemove) { |
494 |
|
if (QMessageBox::warning(this, |
495 |
|
QSAMPLER_TITLE ": " + tr("Warning"), |
496 |
|
tr("Delete %1:\n\n" |
497 |
|
"%2\n\n" |
498 |
|
"Are you sure?") |
499 |
|
.arg(pListItem->rtti() == Item ? tr("instrument") : tr("group")) |
500 |
|
.arg(pListItem->text(0)), |
501 |
|
tr("OK"), tr("Cancel")) > 0) |
502 |
|
return; |
503 |
|
} |
504 |
|
|
505 |
|
// Unmap instrument entry... |
506 |
|
if (pListItem->rtti() == Item) { |
507 |
|
qsamplerInstrumentItem *pItem |
508 |
|
= static_cast<qsamplerInstrumentItem *> (pListItem); |
509 |
|
if (pItem && pItem->instrument()) { |
510 |
|
pItem->instrument()->unmapInstrument(); |
511 |
|
emit instrumentsChanged(); |
512 |
} |
} |
|
delete pListItem; |
|
513 |
} |
} |
514 |
|
|
515 |
|
// Do it for real... |
516 |
|
delete pListItem; |
517 |
|
|
518 |
selectionChangedSlot(); |
selectionChangedSlot(); |
519 |
} |
} |
520 |
|
|
550 |
= static_cast<qsamplerInstrumentItem *> (pListItem); |
= static_cast<qsamplerInstrumentItem *> (pListItem); |
551 |
if (pItem && pItem->instrument()) { |
if (pItem && pItem->instrument()) { |
552 |
pItem->instrument()->setName(pListItem->text(0)); |
pItem->instrument()->setName(pListItem->text(0)); |
553 |
pItem->instrument()->map(); |
pItem->instrument()->mapInstrument(); |
554 |
emit instrumentsChanged(); |
emit instrumentsChanged(); |
555 |
pItem->update(); |
pItem->update(); |
556 |
} |
} |
594 |
|
|
595 |
qsamplerInstrumentItem *pItem = NULL; |
qsamplerInstrumentItem *pItem = NULL; |
596 |
lscp_midi_instrument_t *pInstrs |
lscp_midi_instrument_t *pInstrs |
597 |
= ::lscp_list_midi_instruments(pMainForm->client()); |
= ::lscp_list_midi_instruments(pMainForm->client(), LSCP_MIDI_MAP_ALL); |
598 |
for (int iInstr = 0; pInstrs && pInstrs[iInstr].program >= 0; ++iInstr) { |
for (int iInstr = 0; pInstrs && pInstrs[iInstr].map >= 0; ++iInstr) { |
599 |
int iBank = (pInstrs[iInstr].bank_msb << 7) | pInstrs[iInstr].bank_lsb; |
int iMap = pInstrs[iInstr].map; |
600 |
int iProgram = pInstrs[iInstr].program; |
int iBank = pInstrs[iInstr].bank; |
601 |
|
int iProg = pInstrs[iInstr].prog; |
602 |
qsamplerInstrument *pInstrument |
qsamplerInstrument *pInstrument |
603 |
= new qsamplerInstrument(iBank, iProgram); |
= new qsamplerInstrument(iMap, iBank, iProg); |
604 |
if (pInstrument->get()) |
if (pInstrument->getInstrument()) |
605 |
pItem = new qsamplerInstrumentItem(this, pInstrument, pItem); |
pItem = new qsamplerInstrumentItem(this, pInstrument, pItem); |
606 |
} |
} |
607 |
|
|