35 |
#include <math.h> |
#include <math.h> |
36 |
|
|
37 |
#ifndef CONFIG_ROUND |
#ifndef CONFIG_ROUND |
38 |
static long lroundf ( float fval ) |
static inline long lroundf ( float x ) |
39 |
{ |
{ |
40 |
double fint = 0.0; |
if (x >= 0.0f) |
41 |
float frac = float(::modf(fval, &fint)); |
return long(x + 0.5f); |
42 |
long lint = long(fint); |
else |
43 |
if (frac >= +0.5f) |
return long(x - 0.5f); |
|
lint++; |
|
|
else |
|
|
if (frac <= -0.5f) |
|
|
lint--; |
|
|
return lint; |
|
44 |
} |
} |
45 |
#endif |
#endif |
46 |
|
|
187 |
const QString s = "-"; |
const QString s = "-"; |
188 |
if (m_pInstrument) { |
if (m_pInstrument) { |
189 |
setText(0, m_pInstrument->name()); |
setText(0, m_pInstrument->name()); |
190 |
setText(1, QString::number(m_pInstrument->bank())); |
setText(1, QString::number(m_pInstrument->map())); |
191 |
setText(2, QString::number(m_pInstrument->program() + 1)); |
setText(2, QString::number(m_pInstrument->bank())); |
192 |
setText(3, m_pInstrument->engineName()); |
setText(3, QString::number(m_pInstrument->prog() + 1)); |
193 |
setText(4, QFileInfo(m_pInstrument->instrumentFile()).fileName()); |
setText(4, m_pInstrument->engineName()); |
194 |
setText(5, QString::number(m_pInstrument->instrumentNr())); |
setText(5, QFileInfo(m_pInstrument->instrumentFile()).fileName()); |
195 |
setText(6, QString::number(::lroundf(100.0f * m_pInstrument->volume()))); |
setText(6, QString::number(m_pInstrument->instrumentNr())); |
196 |
|
setText(7, QString::number(::lroundf(100.0f * m_pInstrument->volume()))); |
197 |
QString sLoadMode = s; |
QString sLoadMode = s; |
198 |
switch (m_pInstrument->loadMode()) { |
switch (m_pInstrument->loadMode()) { |
199 |
case 3: |
case 3: |
206 |
sLoadMode = QObject::tr("On Demand"); |
sLoadMode = QObject::tr("On Demand"); |
207 |
break; |
break; |
208 |
} |
} |
209 |
setText(7, sLoadMode); |
setText(8, sLoadMode); |
210 |
} else { |
} else { |
211 |
for (int i = 0; i < listView()->columns(); i++) |
for (int i = 0; i < listView()->columns(); i++) |
212 |
setText(i, s); |
setText(i, s); |
233 |
QListView::setSortColumn(-1); |
QListView::setSortColumn(-1); |
234 |
|
|
235 |
QListView::addColumn(tr("Name")); |
QListView::addColumn(tr("Name")); |
236 |
|
QListView::addColumn(tr("Map")); |
237 |
QListView::addColumn(tr("Bank")); |
QListView::addColumn(tr("Bank")); |
238 |
QListView::addColumn(tr("Prog")); |
QListView::addColumn(tr("Prog")); |
239 |
QListView::addColumn(tr("Engine")); |
QListView::addColumn(tr("Engine")); |
242 |
QListView::addColumn(tr("Vol")); |
QListView::addColumn(tr("Vol")); |
243 |
QListView::addColumn(tr("Mode")); |
QListView::addColumn(tr("Mode")); |
244 |
|
|
245 |
QListView::setColumnAlignment(1, Qt::AlignHCenter); // Bank |
QListView::setColumnAlignment(1, Qt::AlignHCenter); // Map |
246 |
QListView::setColumnAlignment(2, Qt::AlignHCenter); // Prog |
QListView::setColumnAlignment(2, Qt::AlignHCenter); // Bank |
247 |
QListView::setColumnAlignment(5, Qt::AlignHCenter); // Nr |
QListView::setColumnAlignment(3, Qt::AlignHCenter); // Prog |
248 |
QListView::setColumnAlignment(6, Qt::AlignHCenter); // Vol |
QListView::setColumnAlignment(6, Qt::AlignHCenter); // Nr |
249 |
|
QListView::setColumnAlignment(7, Qt::AlignHCenter); // Vol |
250 |
|
|
251 |
QListView::setColumnWidth(0, 60); // Name |
QListView::setColumnWidth(0, 120); // Name |
252 |
QListView::setColumnWidth(0, 120); // File |
QListView::setColumnWidth(5, 240); // File |
253 |
|
|
254 |
m_pNewGroupAction = new QAction(tr("New &Group"), tr("Ctrl+G"), this); |
m_pNewGroupAction = new QAction(tr("New &Group"), tr("Ctrl+G"), this); |
255 |
m_pNewItemAction = new QAction(tr("New &Instrument..."), tr("Ctrl+I"), this); |
m_pNewItemAction = new QAction(tr("New &Instrument..."), tr("Ctrl+I"), this); |
370 |
qsamplerInstrumentItem *pItem |
qsamplerInstrumentItem *pItem |
371 |
= static_cast<qsamplerInstrumentItem *> (pListItem); |
= static_cast<qsamplerInstrumentItem *> (pListItem); |
372 |
if (pItem && pItem->instrument() |
if (pItem && pItem->instrument() |
373 |
|
&& pItem->instrument()->map() == pInstrument->map() |
374 |
&& pItem->instrument()->bank() == pInstrument->bank() |
&& pItem->instrument()->bank() == pInstrument->bank() |
375 |
&& pItem->instrument()->program() == pInstrument->program()) |
&& pItem->instrument()->prog() == pInstrument->prog()) |
376 |
return pItem; |
return pItem; |
377 |
} |
} |
378 |
++iter; |
++iter; |
427 |
if (pItem) |
if (pItem) |
428 |
delete pItem; |
delete pItem; |
429 |
|
|
430 |
pInstrument->map(); |
pInstrument->mapInstrument(); |
431 |
emit instrumentsChanged(); |
emit instrumentsChanged(); |
432 |
|
|
433 |
qsamplerInstrumentGroup *pParentGroup |
qsamplerInstrumentGroup *pParentGroup |
453 |
qsamplerInstrumentForm form(this); |
qsamplerInstrumentForm form(this); |
454 |
form.setup(pItem->instrument()); |
form.setup(pItem->instrument()); |
455 |
if (form.exec()) { |
if (form.exec()) { |
456 |
pItem->instrument()->map(); |
pItem->instrument()->mapInstrument(); |
457 |
emit instrumentsChanged(); |
emit instrumentsChanged(); |
458 |
pItem->update(); |
pItem->update(); |
459 |
} |
} |
484 |
qsamplerInstrumentItem *pItem |
qsamplerInstrumentItem *pItem |
485 |
= static_cast<qsamplerInstrumentItem *> (pListItem); |
= static_cast<qsamplerInstrumentItem *> (pListItem); |
486 |
if (pItem && pItem->instrument()) { |
if (pItem && pItem->instrument()) { |
487 |
pItem->instrument()->unmap(); |
pItem->instrument()->unmapInstrument(); |
488 |
emit instrumentsChanged(); |
emit instrumentsChanged(); |
489 |
} |
} |
490 |
} |
} |
526 |
= static_cast<qsamplerInstrumentItem *> (pListItem); |
= static_cast<qsamplerInstrumentItem *> (pListItem); |
527 |
if (pItem && pItem->instrument()) { |
if (pItem && pItem->instrument()) { |
528 |
pItem->instrument()->setName(pListItem->text(0)); |
pItem->instrument()->setName(pListItem->text(0)); |
529 |
pItem->instrument()->map(); |
pItem->instrument()->mapInstrument(); |
530 |
emit instrumentsChanged(); |
emit instrumentsChanged(); |
531 |
pItem->update(); |
pItem->update(); |
532 |
} |
} |
570 |
|
|
571 |
qsamplerInstrumentItem *pItem = NULL; |
qsamplerInstrumentItem *pItem = NULL; |
572 |
lscp_midi_instrument_t *pInstrs |
lscp_midi_instrument_t *pInstrs |
573 |
= ::lscp_list_midi_instruments(pMainForm->client()); |
= ::lscp_list_midi_instruments(pMainForm->client(), LSCP_MIDI_MAP_ALL); |
574 |
for (int iInstr = 0; pInstrs && pInstrs[iInstr].program >= 0; ++iInstr) { |
for (int iInstr = 0; pInstrs && pInstrs[iInstr].prog >= 0; ++iInstr) { |
575 |
int iBank = (pInstrs[iInstr].bank_msb << 7) | pInstrs[iInstr].bank_lsb; |
int iMap = pInstrs[iInstr].map; |
576 |
int iProgram = pInstrs[iInstr].program; |
int iBank = pInstrs[iInstr].bank; |
577 |
|
int iProg = pInstrs[iInstr].prog; |
578 |
qsamplerInstrument *pInstrument |
qsamplerInstrument *pInstrument |
579 |
= new qsamplerInstrument(iBank, iProgram); |
= new qsamplerInstrument(iMap, iBank, iProg); |
580 |
if (pInstrument->get()) |
if (pInstrument->getInstrument()) |
581 |
pItem = new qsamplerInstrumentItem(this, pInstrument, pItem); |
pItem = new qsamplerInstrumentItem(this, pInstrument, pItem); |
582 |
} |
} |
583 |
|
|