From 7b4cfb934cb59146a71dd0381aa8ad27531c62af Mon Sep 17 00:00:00 2001 From: Werner Schweer Date: Sat, 2 Dec 2006 15:19:37 +0000 Subject: controller updates --- muse/muse/ctrl/CMakeLists.txt | 4 + muse/muse/ctrl/configmidictrl.cpp | 14 ++ muse/muse/ctrl/configmidictrl.h | 1 + muse/muse/ctrl/configmidictrl.ui | 208 ++++++++++++--------------- muse/muse/ctrl/ctrldialog.cpp | 66 ++++++--- muse/muse/ctrl/ctrldialog.h | 5 + muse/muse/ctrl/ctrldialog.ui | 13 +- muse/muse/ctrl/ctrledit.cpp | 21 +-- muse/muse/ctrl/definemidictrl.ui | 294 ++++++++++++++++++++++++++++++++++++++ muse/muse/wave.cpp | 17 +-- muse/muse/waveedit/waveview.cpp | 1 - 11 files changed, 482 insertions(+), 162 deletions(-) create mode 100644 muse/muse/ctrl/definemidictrl.ui diff --git a/muse/muse/ctrl/CMakeLists.txt b/muse/muse/ctrl/CMakeLists.txt index 17f3f2b9..e9e10702 100644 --- a/muse/muse/ctrl/CMakeLists.txt +++ b/muse/muse/ctrl/CMakeLists.txt @@ -20,20 +20,24 @@ QT4_WRAP_CPP (ctrl_mocs configmidictrl.h + definemidictrl.h ctrldialog.h ctrledit.h ) QT4_WRAP_UI (ctrl_ui_headers configmidictrl.ui + definemidictrl.ui ctrldialog.ui ) add_library ( ctrl STATIC configmidictrl.cpp + definemidictrl.cpp ctrldialog.cpp ctrldialog.h ctrleditor.cpp configmidictrl.h + definemidictrl.h ctrleditor.h ctrledit.cpp ${ctrl_mocs} diff --git a/muse/muse/ctrl/configmidictrl.cpp b/muse/muse/ctrl/configmidictrl.cpp index 1bbc2241..f5d2247d 100644 --- a/muse/muse/ctrl/configmidictrl.cpp +++ b/muse/muse/ctrl/configmidictrl.cpp @@ -19,6 +19,7 @@ //============================================================================= #include "configmidictrl.h" +#include "definemidictrl.h" #include "miditrack.h" #include "midioutport.h" #include "midictrl.h" @@ -72,6 +73,7 @@ ConfigMidiCtrl::ConfigMidiCtrl(MidiTrack* t) connect(buttonRemove, SIGNAL(clicked()), SLOT(removeClicked())); connect(availableController, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), SLOT(availableSelected(QListWidgetItem*))); connect(managedController, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), SLOT(managedSelected(QListWidgetItem*))); + connect(defineButton, SIGNAL(clicked()), SLOT(defineClicked())); } //--------------------------------------------------------- @@ -182,3 +184,15 @@ void ConfigMidiCtrl::done(int code) QDialog::done(code); } +//--------------------------------------------------------- +// defineClicked +//--------------------------------------------------------- + +void ConfigMidiCtrl::defineClicked() + { + printf("define clicked\n"); + DefineMidiCtrl dc(track, this); + if (dc.exec()) + QDialog::done(0); + } + diff --git a/muse/muse/ctrl/configmidictrl.h b/muse/muse/ctrl/configmidictrl.h index 28560d79..0af11e36 100644 --- a/muse/muse/ctrl/configmidictrl.h +++ b/muse/muse/ctrl/configmidictrl.h @@ -40,6 +40,7 @@ class ConfigMidiCtrl : public QDialog, public Ui::ConfigMidiCtrlBase { void availableSelected(QListWidgetItem*); void managedSelected(QListWidgetItem*); virtual void done(int); + void defineClicked(); public: ConfigMidiCtrl(MidiTrack*); diff --git a/muse/muse/ctrl/configmidictrl.ui b/muse/muse/ctrl/configmidictrl.ui index d76fe457..1960c490 100644 --- a/muse/muse/ctrl/configmidictrl.ui +++ b/muse/muse/ctrl/configmidictrl.ui @@ -1,156 +1,126 @@ - - - ConfigMidiCtrlBase 0 0 - 463 - 448 + 506 + 355 MusE: Config Midi Controller - + - 8 + 9 6 - - + + 0 6 - - + + - <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:Arial; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Midi Port:</p></body></html> + Midi Instrument: - - - - - 7 - 5 - 0 - 0 - - - - QFrame::Panel - - - QFrame::Sunken + + + + true - - 2 + + + + + + true + + + + - TextLabel + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:Arial; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Midi Port:</p></body></html> - - - - 0 + + + + + 5 + 0 + 0 + 0 + - - 6 + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:Arial; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Automated Controller:</p></body></html> - - - - 0 - - - 6 - - - - - <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:Arial; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Available Controller:</p></body></html> - - - - - - - - - - - - 0 - - - 6 - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - Add - - - - - - - Remove - - - - - - - - - 0 - - - 6 - - - - - <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:Arial; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Automated Controller:</p></body></html> - - - - - - - - - + - + + + + + + + Qt::Vertical + + + + 75 + 81 + + + + + + + + + 5 + 0 + 0 + 0 + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:Arial; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Available Controller:</p></body></html> + + + + + + + + + + Remove + + + + + + + Add + + + + 0 @@ -158,6 +128,13 @@ 6 + + + + Define new Controller + + + @@ -189,7 +166,6 @@ - diff --git a/muse/muse/ctrl/ctrldialog.cpp b/muse/muse/ctrl/ctrldialog.cpp index f1117469..6982ddaa 100644 --- a/muse/muse/ctrl/ctrldialog.cpp +++ b/muse/muse/ctrl/ctrldialog.cpp @@ -25,26 +25,43 @@ #include "audiotrack.h" #include "plugin.h" #include "pipeline.h" +#include "ctrl/configmidictrl.h" //--------------------------------------------------------- // CtrlDialog //--------------------------------------------------------- -CtrlDialog::CtrlDialog(Track* track, int currentId, QWidget* parent) +CtrlDialog::CtrlDialog(Track* track, int ci, QWidget* parent) : QDialog(parent) { + t = track; + currentId = ci; setupUi(this); QTreeWidgetItem* header = tw->headerItem(); header->setTextAlignment(0, Qt::AlignLeft); header->setTextAlignment(1, Qt::AlignHCenter); - /* COMMENT: setSizeHint does not work in qt4.1, Scheduled for 4.2.0 */ - header->setSizeHint(1, QSize(30, 20)); + tw->header()->setResizeMode(0, QHeaderView::Stretch); header->setToolTip(0, tr("controller name")); header->setToolTip(1, tr("flag if controller contains data")); + updateController(); + otherButton->setEnabled(track->type() == Track::MIDI); + connect(tw, + SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)), + SLOT(itemDoubleClicked(QTreeWidgetItem*, int))); + connect(otherButton, SIGNAL(clicked()), SLOT(otherClicked())); + } + +//--------------------------------------------------------- +// updateController +//--------------------------------------------------------- + +void CtrlDialog::updateController() + { + tw->clear(); QTreeWidgetItem* ci; - if (track->type() == Track::MIDI) { + if (t->type() == Track::MIDI) { // // add special controll for midi tracks // @@ -54,7 +71,7 @@ CtrlDialog::CtrlDialog(Track* track, int currentId, QWidget* parent) tw->setCurrentItem(ci); tw->setItemSelected(ci, true); } - if (((MidiTrack*)(track))->drumMap()) { + if (((MidiTrack*)(t))->drumMap()) { ci = new QTreeWidgetItem(tw, CTRL_SVELOCITY); ci->setText(0, "Single Velocity"); @@ -64,7 +81,7 @@ CtrlDialog::CtrlDialog(Track* track, int currentId, QWidget* parent) } } } - else if (!track->isMidiTrack()) { + else if (!t->isMidiTrack()) { // // aux send streams // @@ -72,7 +89,7 @@ CtrlDialog::CtrlDialog(Track* track, int currentId, QWidget* parent) // // present plugin parameter // - Pipeline* pl = ((AudioTrack*)track)->prePipe(); + Pipeline* pl = ((AudioTrack*)t)->prePipe(); int idx = 0; foreach (PluginI* plugin, *pl) { ci = new QTreeWidgetItem(tw, CTRL_NO_CTRL); @@ -83,7 +100,7 @@ CtrlDialog::CtrlDialog(Track* track, int currentId, QWidget* parent) int id = (idx + 1) * 0x1000 + i; QTreeWidgetItem* cci = new QTreeWidgetItem(ci, id); cci->setText(0, name); - Ctrl* ctrl = track->getController(id); + Ctrl* ctrl = t->getController(id); if (!ctrl->empty()) cci->setText(1, "*"); if (id == currentId) { @@ -92,7 +109,7 @@ CtrlDialog::CtrlDialog(Track* track, int currentId, QWidget* parent) } } } - pl = ((AudioTrack*)track)->postPipe(); + pl = ((AudioTrack*)t)->postPipe(); idx = 0; foreach (PluginI* plugin, *pl) { ci = new QTreeWidgetItem(tw, CTRL_NO_CTRL); @@ -103,7 +120,7 @@ CtrlDialog::CtrlDialog(Track* track, int currentId, QWidget* parent) int id = (idx + 1) * 0x1000 + i; QTreeWidgetItem* cci = new QTreeWidgetItem(ci, id); cci->setText(0, name); - Ctrl* ctrl = track->getController(id); + Ctrl* ctrl = t->getController(id); if (!ctrl->empty()) cci->setText(1, "*"); if (id == currentId) { @@ -114,11 +131,11 @@ CtrlDialog::CtrlDialog(Track* track, int currentId, QWidget* parent) } } - ControllerNameList* cn = track->controllerNames(); + ControllerNameList* cn = t->controllerNames(); for (iControllerName i = cn->begin(); i != cn->end(); ++i) { ci = new QTreeWidgetItem(tw, i->id); ci->setText(0, i->name); - Ctrl* ctrl = track->getController(i->id); + Ctrl* ctrl = t->getController(i->id); if (!ctrl->empty()) ci->setText(1, "*"); @@ -127,12 +144,6 @@ CtrlDialog::CtrlDialog(Track* track, int currentId, QWidget* parent) tw->setItemSelected(ci, true); } } - - ci = new QTreeWidgetItem(tw, CTRL_OTHER); - ci->setText(0, tr("other")); - connect(tw, - SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)), - SLOT(itemDoubleClicked(QTreeWidgetItem*, int))); } //--------------------------------------------------------- @@ -157,4 +168,23 @@ int CtrlDialog::curId() const return item->type(); } +//--------------------------------------------------------- +// otherClicked +// Add another controller to the list of "managed" +// controllers. +//--------------------------------------------------------- + +void CtrlDialog::otherClicked() + { + QTreeWidgetItem* item = tw->currentItem(); + if (item) + currentId = item->type(); + // + // present the list of available controller for + // the selected midi instrument + // + ConfigMidiCtrl mce((MidiTrack*)t); + mce.exec(); + updateController(); + } diff --git a/muse/muse/ctrl/ctrldialog.h b/muse/muse/ctrl/ctrldialog.h index d3889580..3cb51ef2 100644 --- a/muse/muse/ctrl/ctrldialog.h +++ b/muse/muse/ctrl/ctrldialog.h @@ -32,8 +32,13 @@ class Track; class CtrlDialog : public QDialog, public Ui_CtrlDialogBase { Q_OBJECT + Track* t; + int currentId; + void updateController(); + private slots: void itemDoubleClicked(QTreeWidgetItem*, int); + void otherClicked(); public: CtrlDialog(Track*, int, QWidget* parent = 0); diff --git a/muse/muse/ctrl/ctrldialog.ui b/muse/muse/ctrl/ctrldialog.ui index cdb3c5b8..a3d36304 100644 --- a/muse/muse/ctrl/ctrldialog.ui +++ b/muse/muse/ctrl/ctrldialog.ui @@ -1,14 +1,11 @@ - - - CtrlDialogBase 0 0 - 400 + 390 300 @@ -53,6 +50,13 @@ 6 + + + + Other + + + @@ -84,7 +88,6 @@ - diff --git a/muse/muse/ctrl/ctrledit.cpp b/muse/muse/ctrl/ctrledit.cpp index 06b28472..cbd0275c 100644 --- a/muse/muse/ctrl/ctrledit.cpp +++ b/muse/muse/ctrl/ctrledit.cpp @@ -109,20 +109,13 @@ void CtrlEdit::showControllerList() id = c->id(); else id = CTRL_NO_CTRL; - for (;;) { - CtrlDialog cd(_track, id); - int rv = cd.exec(); - if (rv != 1) - return; - id = cd.curId(); - if (id == CTRL_NO_CTRL) - return; - if (id != CTRL_OTHER) - break; - ConfigMidiCtrl* mce = new ConfigMidiCtrl((MidiTrack*)_track); - mce->exec(); - delete mce; - } + CtrlDialog cd(_track, id); + int rv = cd.exec(); + if (rv != 1) + return; + id = cd.curId(); + if (id == CTRL_NO_CTRL) + return; changeController(id); } diff --git a/muse/muse/ctrl/definemidictrl.ui b/muse/muse/ctrl/definemidictrl.ui new file mode 100644 index 00000000..20269956 --- /dev/null +++ b/muse/muse/ctrl/definemidictrl.ui @@ -0,0 +1,294 @@ + + DefineMidiCtrlBase + + + + 0 + 0 + 463 + 301 + + + + Dialog + + + + 9 + + + 6 + + + + + 0 + + + 6 + + + + + + + + + 7-Bit + + + + + 14-Bit + + + + + 7-Bit RPN + + + + + 14-Bit RPN + + + + + 7-Bit NRPN + + + + + 14-Bit NRPN + + + + + + + + Controller Name: + + + + + + + Controller Type: + + + + + + + + 24 + 75 + true + + + + QFrame::Raised + + + 5 + + + <html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Arial'; font-size:24pt; font-weight:600; font-style:normal; text-decoration:none;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:400;"> </span><span style=" font-weight:400;">CTRL </span></p></body></html> + + + + + + + + + Qt::Vertical + + + + 20 + 16 + + + + + + + + 0 + + + 6 + + + + + 0 + + + 6 + + + + + 0x00 + + + + + + + + + + Id LSB + + + + + + + 0x00 + + + + + + + + + + Id MSB + + + + + + + + + 0 + + + 6 + + + + + + + + 0x00 + + + + + + + 0x00 + + + + + + + Init Value + + + + + + + + + + Min.Value + + + + + + + + + + Max.Value + + + + + + + 0x00 + + + + + + + + + + + Qt::Vertical + + + + 20 + 16 + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + DefineMidiCtrlBase + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + DefineMidiCtrlBase + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/muse/muse/wave.cpp b/muse/muse/wave.cpp index f0e360c7..41682d88 100644 --- a/muse/muse/wave.cpp +++ b/muse/muse/wave.cpp @@ -289,8 +289,10 @@ bool SndFile::openRead() sfUI = sf_open(p.toAscii().data(), SFM_READ, &sfinfo); sfinfo.format = 0; sfRT = sf_open(p.toAscii().data(), SFM_READ, &sfinfo); - if (sfUI == 0 || sfRT == 0) + if (sfUI == 0 || sfRT == 0) { + printf("SndFile::openRead(): failed\n"); return true; + } writeFlag = false; openFlag = true; QString cacheName = _finfo.absolutePath() + QString("/") + _finfo.baseName() + QString(".wca"); @@ -442,10 +444,9 @@ void SndFile::read(SampleV* s, int mag, unsigned pos) { int srcChannels = channels(); int dstChannels = sfinfo.channels; - size_t n = mag; float** dst = fp; - float buffer[n * dstChannels]; - size_t rn = sf_readf_float(sfUI, buffer, n); + float buffer[mag * dstChannels]; + size_t rn = sf_readf_float(sfUI, buffer, mag); float* src = buffer; if (srcChannels == dstChannels) { @@ -705,15 +706,15 @@ QString SndFile::strerror() const } //--------------------------------------------------------- -// getSnd +// getWave //--------------------------------------------------------- SndFile* SndFile::getWave(const QString& inName, bool writeFlag) { QString name = song->absoluteProjectPath() + "/" + inName; -// printf("=====%s %s\n", inName.toLatin1().data(), name.toLatin1().data()); SndFile* f = sndFiles.value(name); +// printf("SndFile::getWave: %p writeFlag %d %s %s\n", f, writeFlag, inName.toLatin1().data(), name.toLatin1().data()); if (f == 0) { if (!QFile::exists(name)) { fprintf(stderr, "wave file <%s> not found\n", @@ -723,9 +724,9 @@ SndFile* SndFile::getWave(const QString& inName, bool writeFlag) f = new SndFile(name); bool error; if (writeFlag) - error = f->openRead(); - else error = f->openWrite(); + else + error = f->openRead(); if (error) { fprintf(stderr, "open wave file(%s) for %s failed: %s\n", name.toLatin1().data(), diff --git a/muse/muse/waveedit/waveview.cpp b/muse/muse/waveedit/waveview.cpp index 6659274d..14550c3d 100644 --- a/muse/muse/waveedit/waveview.cpp +++ b/muse/muse/waveedit/waveview.cpp @@ -132,7 +132,6 @@ void WaveView::drawWavePart(QPainter& p, Part* wp, int y0, int th, int from, int f.read(sa, xScale, frame); frame += xScale; for (unsigned k = 0; k < channels; ++k) { - // peak = (sa[k].peak * h) / 256; int peak = (sa[k].peak * (h - 1)) >> 8; int rms = (sa[k].rms * (h - 1)) >> 8; p.setPen(QColor(Qt::darkGray)); -- cgit v1.2.3