diff options
author | Florian Jung <flo@windfisch.org> | 2011-12-14 15:08:02 +0000 |
---|---|---|
committer | Florian Jung <flo@windfisch.org> | 2011-12-14 15:08:02 +0000 |
commit | c36a5508aa42e596b005425208054af9a60734b4 (patch) | |
tree | fde0504e0c25b8f39ed6f5f7f7332943e4a95c7f /muse2/muse/arranger | |
parent | 42126f3b398802eb24c8d9acd2591ef4dbe7257d (diff) |
pulled fixes from release into trunk
Diffstat (limited to 'muse2/muse/arranger')
-rw-r--r-- | muse2/muse/arranger/alayout.cpp | 2 | ||||
-rw-r--r-- | muse2/muse/arranger/arranger.cpp | 59 | ||||
-rw-r--r-- | muse2/muse/arranger/arrangerview.cpp | 29 | ||||
-rw-r--r-- | muse2/muse/arranger/arrangerview.h | 10 | ||||
-rw-r--r-- | muse2/muse/arranger/pcanvas.cpp | 144 | ||||
-rw-r--r-- | muse2/muse/arranger/pcanvas.h | 6 | ||||
-rw-r--r-- | muse2/muse/arranger/tlist.cpp | 169 |
7 files changed, 331 insertions, 88 deletions
diff --git a/muse2/muse/arranger/alayout.cpp b/muse2/muse/arranger/alayout.cpp index a892356c..119da498 100644 --- a/muse2/muse/arranger/alayout.cpp +++ b/muse2/muse/arranger/alayout.cpp @@ -117,7 +117,7 @@ void TLLayout::setGeometry(const QRect &rect) QSize s1 = li[1]->sizeHint(); QSize s2 = li[2]->sizeHint(); - QSize s3 = li[3]->sizeHint(); + //QSize s3 = li[3]->sizeHint(); QSize s4 = li[4]->sizeHint(); QSize s5 = li[5]->sizeHint(); diff --git a/muse2/muse/arranger/arranger.cpp b/muse2/muse/arranger/arranger.cpp index ae753378..cb024070 100644 --- a/muse2/muse/arranger/arranger.cpp +++ b/muse2/muse/arranger/arranger.cpp @@ -569,27 +569,40 @@ void Arranger::songChanged(int type) // Is it simply a midi controller value adjustment? Forget it. if(type != SC_MIDI_CONTROLLER) { - unsigned endTick = MusEGlobal::song->len(); - int offset = AL::sigmap.ticksMeasure(endTick); - hscroll->setRange(-offset, endTick + offset); //DEBUG - canvas->setOrigin(-offset, 0); - time->setOrigin(-offset, 0); - - int bar, beat; - unsigned tick; - AL::sigmap.tickValues(endTick, &bar, &beat, &tick); - if (tick || beat) - ++bar; - lenEntry->blockSignals(true); - lenEntry->setValue(bar); - lenEntry->blockSignals(false); - - if(type & SC_SONG_TYPE) // p4.0.7 Tim. + // TEST p4.0.36 Try these, may need more/less. + if(type & ( SC_TRACK_INSERTED | SC_TRACK_REMOVED | SC_TRACK_MODIFIED | + SC_PART_INSERTED | SC_PART_REMOVED | SC_PART_MODIFIED)) + { + unsigned endTick = MusEGlobal::song->len(); + int offset = AL::sigmap.ticksMeasure(endTick); + hscroll->setRange(-offset, endTick + offset); //DEBUG + canvas->setOrigin(-offset, 0); + time->setOrigin(-offset, 0); + + int bar, beat; + unsigned tick; + AL::sigmap.tickValues(endTick, &bar, &beat, &tick); + if (tick || beat) + ++bar; + lenEntry->blockSignals(true); + lenEntry->setValue(bar); + lenEntry->blockSignals(false); + } + + if(type & SC_SONG_TYPE) setMode(MusEGlobal::song->mtype()); - trackSelectionChanged(); - canvas->partsChanged(); - typeBox->setCurrentIndex(int(MusEGlobal::song->mtype())); + if(type & SC_SELECTION) // TEST p4.0.36 Try this alone, may need more. + trackSelectionChanged(); + + // Keep this light, partsChanged is a heavy move! TEST p4.0.36 Try these, may need more. + if(type & (SC_TRACK_INSERTED | SC_TRACK_REMOVED | SC_TRACK_MODIFIED | + SC_PART_INSERTED | SC_PART_REMOVED | SC_PART_MODIFIED | + SC_SIG | SC_TEMPO)) // Maybe sig. Requires tempo. + canvas->partsChanged(); + + //typeBox->setCurrentIndex(int(MusEGlobal::song->mtype())); // REMOVE Tim. Redundant. + if (type & SC_SIG) time->redraw(); if (type & SC_TEMPO) @@ -616,6 +629,14 @@ void Arranger::songChanged(int type) } } } + + // TEST p4.0.36 Try this + if(type & ( //SC_TRACK_INSERTED | SC_TRACK_REMOVED | SC_TRACK_MODIFIED | + SC_PART_INSERTED | SC_PART_REMOVED | SC_PART_MODIFIED | + SC_EVENT_INSERTED | SC_EVENT_REMOVED | SC_EVENT_MODIFIED)) //| + //SC_SIG | SC_TEMPO)) // Maybe sig. and tempo. No, moved above. + canvas->redraw(); + } updateTrackInfo(type); diff --git a/muse2/muse/arranger/arrangerview.cpp b/muse2/muse/arranger/arrangerview.cpp index 3b726845..52be5194 100644 --- a/muse2/muse/arranger/arrangerview.cpp +++ b/muse2/muse/arranger/arrangerview.cpp @@ -37,7 +37,7 @@ #include <QMessageBox> #include <QMimeData> #include <QPushButton> -#include <QResizeEvent> +//#include <QResizeEvent> #include <QScrollArea> #include <QScrollBar> #include <QSettings> @@ -129,6 +129,7 @@ ArrangerView::ArrangerView(QWidget* parent) connect(muse, SIGNAL(configChanged()), arranger, SLOT(configChanged())); connect(arranger, SIGNAL(setUsedTool(int)), editTools, SLOT(set(int))); connect(arranger, SIGNAL(selectionChanged()), SLOT(selectionChanged())); + connect(MusEGlobal::song, SIGNAL(songChanged(int)), visTracks, SLOT(updateVisibleTracksButtons())); @@ -167,8 +168,8 @@ ArrangerView::ArrangerView(QWidget* parent) scoreSubmenu = new QMenu(tr("Score"), this); scoreSubmenu->setIcon(QIcon(*scoreIconSet)); - scoreAllInOneSubsubmenu = new QMenu(tr("all parts in one staff"), this); - scoreOneStaffPerTrackSubsubmenu = new QMenu(tr("one staff per part"), this); + scoreAllInOneSubsubmenu = new QMenu(tr("all tracks in one staff"), this); + scoreOneStaffPerTrackSubsubmenu = new QMenu(tr("one staff per track"), this); scoreSubmenu->addMenu(scoreAllInOneSubsubmenu); scoreSubmenu->addMenu(scoreOneStaffPerTrackSubsubmenu); @@ -193,6 +194,10 @@ ArrangerView::ArrangerView(QWidget* parent) strGlobalInsertAction = new QAction(tr("Global Insert"), this); strGlobalSplitAction = new QAction(tr("Global Split"), this); + strGlobalCutSelAction = new QAction(tr("Global Cut - selected tracks"), this); + strGlobalInsertSelAction = new QAction(tr("Global Insert - selected tracks"), this); + strGlobalSplitSelAction = new QAction(tr("Global Split - selected tracks"), this); + //------------------------------------------------------------- @@ -246,7 +251,11 @@ ArrangerView::ArrangerView(QWidget* parent) menuStructure->addAction(strGlobalCutAction); menuStructure->addAction(strGlobalInsertAction); menuStructure->addAction(strGlobalSplitAction); - + menuStructure->addSeparator(); + menuStructure->addAction(strGlobalCutSelAction); + menuStructure->addAction(strGlobalInsertSelAction); + menuStructure->addAction(strGlobalSplitSelAction); + QMenu* functions_menu = menuBar()->addMenu(tr("Functions")); @@ -341,6 +350,9 @@ ArrangerView::ArrangerView(QWidget* parent) connect(strGlobalCutAction, SIGNAL(activated()), SLOT(globalCut())); connect(strGlobalInsertAction, SIGNAL(activated()), SLOT(globalInsert())); connect(strGlobalSplitAction, SIGNAL(activated()), SLOT(globalSplit())); + connect(strGlobalCutSelAction, SIGNAL(activated()), SLOT(globalCutSel())); + connect(strGlobalInsertSelAction, SIGNAL(activated()), SLOT(globalInsertSel())); + connect(strGlobalSplitSelAction, SIGNAL(activated()), SLOT(globalSplitSel())); @@ -351,7 +363,7 @@ ArrangerView::ArrangerView(QWidget* parent) connect(cb, SIGNAL(dataChanged()), SLOT(clipboardChanged())); connect(cb, SIGNAL(selectionChanged()), SLOT(clipboardChanged())); - + MusEGlobal::muse->topwinMenuInited(this); // work around for probable QT/WM interaction bug. // for certain window managers, e.g xfce, this window is @@ -368,7 +380,7 @@ ArrangerView::~ArrangerView() void ArrangerView::closeEvent(QCloseEvent* e) { - emit deleted(static_cast<TopWin*>(this)); + emit isDeleting(static_cast<TopWin*>(this)); emit closed(); e->accept(); } @@ -729,4 +741,9 @@ void ArrangerView::globalCut() { MusECore::globalCut(); } void ArrangerView::globalInsert() { MusECore::globalInsert(); } void ArrangerView::globalSplit() { MusECore::globalSplit(); } +// variants only applicable for selected tracks +void ArrangerView::globalCutSel() { MusECore::globalCut(true); } +void ArrangerView::globalInsertSel() { MusECore::globalInsert(true); } +void ArrangerView::globalSplitSel() { MusECore::globalSplit(true); } + } // namespace MusEGui diff --git a/muse2/muse/arranger/arrangerview.h b/muse2/muse/arranger/arrangerview.h index de610bd6..c56767a6 100644 --- a/muse2/muse/arranger/arrangerview.h +++ b/muse2/muse/arranger/arrangerview.h @@ -89,7 +89,8 @@ class ArrangerView : public TopWin QMenu* master; QAction *strGlobalCutAction, *strGlobalInsertAction, *strGlobalSplitAction; - QAction *trackMidiAction, *trackDrumAction, *trackWaveAction, *trackAOutputAction, *trackAGroupAction; + QAction *strGlobalCutSelAction, *strGlobalInsertSelAction, *strGlobalSplitSelAction; + QAction *trackMidiAction, *trackDrumAction, *trackWaveAction, *trackAOutputAction, *trackAGroupAction; QAction *trackAInputAction, *trackAAuxAction; QAction *editCutAction, *editCopyAction, *editCopyRangeAction; QAction *editPasteAction, *editPasteCloneAction, *editPasteDialogAction, *editPasteCloneDialogAction; @@ -119,11 +120,14 @@ class ArrangerView : public TopWin void globalCut(); void globalInsert(); void globalSplit(); - void cmd(int); + void globalCutSel(); + void globalInsertSel(); + void globalSplitSel(); + void cmd(int); void addNewTrack(QAction* action); signals: - void deleted(MusEGui::TopWin*); + void isDeleting(MusEGui::TopWin*); void closed(); public slots: diff --git a/muse2/muse/arranger/pcanvas.cpp b/muse2/muse/arranger/pcanvas.cpp index d19fa082..f190de3b 100644 --- a/muse2/muse/arranger/pcanvas.cpp +++ b/muse2/muse/arranger/pcanvas.cpp @@ -3,7 +3,7 @@ // Linux Music Editor // $Id: pcanvas.cpp,v 1.48.2.26 2009/11/22 11:08:33 spamatica Exp $ // (C) Copyright 1999 Werner Schweer (ws@seh.de) -// (C) Copyright 2011 Tim E. Real (terminator356 on users DOT sourceforge DOT net) +// (C) Copyright 2011 Tim E. Real (terminator356 on sourceforge) // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -302,12 +302,9 @@ void PartCanvas::moveCanvasItems(CItemList& items, int dp, int dx, DragType dtyp QPoint newpos = raster(QPoint(nx, ny)); selectItem(ci, true); - MusECore::UndoOp operation=moveItem(ci, newpos, dtype); - if (operation.type != MusECore::UndoOp::DoNothing) - { + bool result=moveItem(operations, ci, newpos, dtype); + if (result) ci->move(newpos); - operations.push_back(operation); - } if(moving.size() == 1) { itemReleased(curItem, newpos); @@ -326,37 +323,41 @@ void PartCanvas::moveCanvasItems(CItemList& items, int dp, int dx, DragType dtyp //--------------------------------------------------------- // Changed by T356. -MusECore::UndoOp PartCanvas::moveItem(CItem* item, const QPoint& newpos, DragType t) +bool PartCanvas::moveItem(MusECore::Undo& operations, CItem* item, const QPoint& newpos, DragType t) { - MusECore::UndoOp result; NPart* npart = (NPart*) item; MusECore::Part* spart = npart->part(); MusECore::Track* track = npart->track(); + MusECore::Track* dtrack=NULL; unsigned dtick = newpos.x(); unsigned ntrack = y2pitch(item->mp().y()); MusECore::Track::TrackType type = track->type(); if (tracks->index(track) == ntrack && (dtick == spart->tick())) { - return MusECore::UndoOp(MusECore::UndoOp::DoNothing); + return false; } if (ntrack >= tracks->size()) { ntrack = tracks->size(); if (MusEGlobal::debugMsg) printf("PartCanvas::moveItem - add new track\n"); - MusECore::Track* newTrack = MusEGlobal::song->addTrack(type); // Add at end of list. + dtrack = MusEGlobal::song->addTrack(operations, type); // Add at end of list. + if (type == MusECore::Track::WAVE) { MusECore::WaveTrack* st = (MusECore::WaveTrack*) track; - MusECore::WaveTrack* dt = (MusECore::WaveTrack*) newTrack; + MusECore::WaveTrack* dt = (MusECore::WaveTrack*) dtrack; dt->setChannels(st->channels()); } emit tracklistChanged(); } - MusECore::Track* dtrack = tracks->index(ntrack); - if (dtrack->type() != type) { - QMessageBox::critical(this, QString("MusE"), - tr("Cannot copy/move/clone to different Track-Type")); - return MusECore::UndoOp(MusECore::UndoOp::DoNothing); + else + { + dtrack = tracks->index(ntrack); + if (dtrack->type() != type) { + QMessageBox::critical(this, QString("MusE"), + tr("Cannot copy/move/clone to different Track-Type")); + return false; + } } - + MusECore::Part* dpart; bool clone = (t == MOVE_CLONE || (t == MOVE_COPY && spart->events()->arefCount() > 1)); @@ -397,22 +398,24 @@ MusECore::UndoOp PartCanvas::moveItem(CItem* item, const QPoint& newpos, DragTyp if (t == MOVE_COPY || t == MOVE_CLONE) { // These will not increment ref count, and will not chain clones... // TODO FINDMICH: is this still correct (by flo93)? i doubt it! - result=MusECore::UndoOp(MusECore::UndoOp::AddPart,dpart); + operations.push_back(MusECore::UndoOp(MusECore::UndoOp::AddPart,dpart)); } else if (t == MOVE_MOVE) { dpart->setSelected(spart->selected()); // These will increment ref count if not a clone, and will chain clones... // TODO FINDMICH: is this still correct (by flo93)? i doubt it! - result=MusECore::UndoOp(MusECore::UndoOp::ModifyPart,spart, dpart, true, false); + operations.push_back(MusECore::UndoOp(MusECore::UndoOp::ModifyPart,spart, dpart, true, false)); spart->setSelected(false); } - // else // will never happen -> result will always be defined + // else // will never happen -> operations will never be empty if (MusEGlobal::song->len() < (dpart->lenTick() + dpart->tick())) - MusEGlobal::song->setLen(dpart->lenTick() + dpart->tick()); - - return result; + operations.push_back( MusECore::UndoOp(MusECore::UndoOp::ModifySongLen, + dpart->lenTick() + dpart->tick(), + MusEGlobal::song->len() ) ); + + return true; } //--------------------------------------------------------- @@ -883,8 +886,8 @@ void PartCanvas::mousePress(QMouseEvent* event) default: if (item) emit trackChanged(item->part()->track()); - else - emit trackChanged(NULL); + //else -- don't see the point of removing track selection, commenting out (rj) + // emit trackChanged(NULL); break; case CutTool: if (item) splitItem(item, pt); @@ -1193,7 +1196,7 @@ void PartCanvas::keyPress(QKeyEvent* event) //If we're at topmost, leave if (!track) { - printf("no track above!\n"); + //printf("no track above!\n"); return; } int middle = curItem->x() + curItem->part()->lenTick()/2; @@ -1327,17 +1330,25 @@ void PartCanvas::keyPress(QKeyEvent* event) curItem = newItem; selectItem(newItem, true); - //Check if we've hit the upper or lower boundaries of the window. If so, set a new position + //Check if we've hit the left, right, upper or lower boundaries of the window. If so, scroll to new position. if (newItem->x() < mapxDev(0)) { - int curpos = pos[0]; - setPos(0,newItem->x(),true); - setPos(0,curpos,false); //Dummy to put the current position back once we've scrolled + emit horizontalScroll(rmapx(newItem->x() - xorg) - 10); // Leave some room. + } + else if (newItem->x() + newItem->width() > mapxDev(width())) { + int mx = rmapx(newItem->x()); + int newx = mx + rmapx(newItem->width()) - width(); + emit horizontalScroll( (newx > mx ? mx - 10 : newx + 10) - rmapx(xorg) ); + } + + if (newItem->y() < mapyDev(0)) { + int my = rmapy(newItem->y()); + int newy = my + rmapy(newItem->height()) - height(); + emit verticalScroll( (newy < my ? my - 10 : newy + 10) - rmapy(yorg) ); } - else if (newItem->x() > mapxDev(width())) { - int curpos = pos[0]; - setPos(0,newItem->x(),true); - setPos(0,curpos,false); //Dummy to put the current position back once we've scrolled + else if (newItem->y() + newItem->height() > mapyDev(height())) { + emit verticalScroll( rmapy(newItem->y() + newItem->height() - yorg) - height() + 10); } + redraw(); } } @@ -2299,9 +2310,9 @@ void PartCanvas::drawMidiPart(QPainter& p, const QRect&, MusECore::EventList* ev //else // color_brightness=64; // otherwise use dark color if (brightness >= 12000 && !pt->selected()) - color_brightness=64; // 96; // too bright: use dark color + color_brightness=54; // 96; // too bright: use dark color else - color_brightness=190; //160; // too dark: use lighter color + color_brightness=200; //160; // too dark: use lighter color } else color_brightness=80; @@ -3207,9 +3218,13 @@ void PartCanvas::viewDropEvent(QDropEvent* event) if (!track) { // we need to create a track for this drop if (text.endsWith(".mpt", Qt::CaseInsensitive)) { - track = MusEGlobal::song->addTrack(MusECore::Track::MIDI); // Add at end of list. + MusECore::Undo operations; + track = MusEGlobal::song->addTrack(operations, MusECore::Track::MIDI); // Add at end of list. + MusEGlobal::song->applyOperationGroup(operations); } else { - track = MusEGlobal::song->addTrack(MusECore::Track::WAVE); // Add at end of list. + MusECore::Undo operations; + track = MusEGlobal::song->addTrack(operations, MusECore::Track::WAVE); // Add at end of list. + MusEGlobal::song->applyOperationGroup(operations); } } if (track->type() == MusECore::Track::WAVE && @@ -3634,7 +3649,8 @@ void PartCanvas::drawAutomation(QPainter& p, const QRect& rr, MusECore::AudioTra { double y; if (cl->valueType() == MusECore::VAL_LOG ) { // use db scale for volume - y = dbToVal(cl->curVal()); // represent volume between 0 and 1 + //printf("log conversion val=%f min=%f max=%f\n", cl->curVal(), min, max); + y = logToVal(cl->curVal(), min, max); // represent volume between 0 and 1 if (y < 0) y = 0.0; } else @@ -3647,7 +3663,8 @@ void PartCanvas::drawAutomation(QPainter& p, const QRect& rr, MusECore::AudioTra { double y = ic->second.val; if (cl->valueType() == MusECore::VAL_LOG ) { // use db scale for volume - y = dbToVal(y); // represent volume between 0 and 1 + //printf("log conversion val=%f min=%f max=%f\n", cl->curVal(), min, max); + y = logToVal(y, min, max); // represent volume between 0 and 1 if (y < 0) y = 0.0; } else @@ -3746,7 +3763,7 @@ void PartCanvas::checkAutomation(MusECore::Track * t, const QPoint &pointer, boo { double y; if (cl->valueType() == MusECore::VAL_LOG ) { // use db scale for volume - y = dbToVal(cl->curVal()); // represent volume between 0 and 1 + y = logToVal(cl->curVal(), min, max); // represent volume between 0 and 1 if (y < 0) y = 0.0; } else @@ -3759,7 +3776,7 @@ void PartCanvas::checkAutomation(MusECore::Track * t, const QPoint &pointer, boo { double y = ic->second.val; if (cl->valueType() == MusECore::VAL_LOG ) { // use db scale for volume - y = dbToVal(y); // represent volume between 0 and 1 + y = logToVal(y, min, max); // represent volume between 0 and 1 if (y < 0) y = 0; } else @@ -3951,7 +3968,8 @@ void PartCanvas::processAutomationMovements(QPoint pos, bool addPoint) automation.currentCtrlList->range(&min,&max); double cvval; if (automation.currentCtrlList->valueType() == MusECore::VAL_LOG ) { // use db scale for volume - cvval = valToDb(yfraction); + printf("log conversion val=%f min=%f max=%f\n", yfraction, min, max); + cvval = valToLog(yfraction, min, max); //printf("calc yfraction = %f v=%f ",yfraction,cvval); if (cvval< min) cvval=min; if (cvval>max) cvval=max; @@ -3984,13 +4002,45 @@ void PartCanvas::processAutomationMovements(QPoint pos, bool addPoint) } -double PartCanvas::dbToVal(double inDb) +//--------------------------------------------------------- +// +// logToVal +// - represent logarithmic value on linear scale from 0 to 1 +// +//--------------------------------------------------------- +double PartCanvas::logToVal(double inLog, double min, double max) { - return (20.0*MusECore::fast_log10(inDb)+60.0) / 70.0; + //printf("logToVal inLog %f :", inLog); + if (inLog < min) inLog = min; + if (inLog > max) inLog = max; + double linMin = 20.0*MusECore::fast_log10(min); + double linMax = 20.0*MusECore::fast_log10(max); + double linVal = 20.0*MusECore::fast_log10(inLog); + + double outVal = (linVal-linMin) / (linMax - linMin); + // printf("inLog %f outVal %f linVal %f min %f max %f dbMin %f dbMax %f\n", inLog, outVal, linVal, min, max, linMin, linMax); + + return outVal; } -double PartCanvas::valToDb(double inV) + +//--------------------------------------------------------- +// +// valToLog +// - represent value from 0 to 1 as logarithmic value between min and max +// +//--------------------------------------------------------- +double PartCanvas::valToLog(double inV, double min, double max) { - return exp10((inV*70.0-60.0)/20.0); + double linMin = 20.0*MusECore::fast_log10(min); + double linMax = 20.0*MusECore::fast_log10(max); + + double linVal = (inV * (linMax - linMin)) + linMin; + double outVal = exp10((linVal)/20.0); + + //printf("::valToLog inV %f outVal %f linVal %f min %f max %f\n", inV, outVal, linVal, min, max); + if (outVal > max) outVal = max; + if (outVal < min) outVal = min; + return outVal; } //--------------------------------------------------------- diff --git a/muse2/muse/arranger/pcanvas.h b/muse2/muse/arranger/pcanvas.h index 78b88a5c..34395688 100644 --- a/muse2/muse/arranger/pcanvas.h +++ b/muse2/muse/arranger/pcanvas.h @@ -119,7 +119,7 @@ class PartCanvas : public Canvas { virtual void newItem(CItem*,bool); virtual bool deleteItem(CItem*); virtual void moveCanvasItems(CItemList&, int, int, DragType); - virtual MusECore::UndoOp moveItem(CItem*, const QPoint&, DragType); + virtual bool moveItem(MusECore::Undo& operations, CItem*, const QPoint&, DragType); virtual void updateSong(DragType, int); virtual void startDrag(CItem*, DragType); @@ -148,8 +148,8 @@ class PartCanvas : public Canvas { void checkAutomation(MusECore::Track * t, const QPoint& pointer, bool addNewCtrl); void processAutomationMovements(QPoint pos, bool addPoint); - double dbToVal(double inDb); - double valToDb(double inV); + double logToVal(double inLog, double min, double max); + double valToLog(double inV, double min, double max); protected: virtual void drawCanvas(QPainter&, const QRect&); diff --git a/muse2/muse/arranger/tlist.cpp b/muse2/muse/arranger/tlist.cpp index 1e3ad419..620a24b7 100644 --- a/muse2/muse/arranger/tlist.cpp +++ b/muse2/muse/arranger/tlist.cpp @@ -62,6 +62,7 @@ #include "synth.h" #include "config.h" #include "popupmenu.h" +#include "menutitleitem.h" #ifdef DSSI_SUPPORT #include "dssihost.h" @@ -392,7 +393,7 @@ void TList::paint(const QRect& r) countVisible++; } //int count = ((MusECore::AudioTrack*)track)->controller()->size(); //commented out by flo: gives a "unused variable" warning - s.sprintf(" %d(%d) visible",countVisible, countAll); + s.sprintf(" %d(%d) %s",countVisible, countAll, tr("visible").toAscii().data()); } @@ -584,12 +585,17 @@ void TList::portsPopupMenu(MusECore::Track* t, int x, int y) switch(t->type()) { case MusECore::Track::MIDI: case MusECore::Track::DRUM: + // FINDMICHJETZT: this is a notice for flo's experimental + // branch! don't forget NEW_DRUM here! + // please don't remove this. i'll do it when + // the time is there. case MusECore::Track::AUDIO_SOFTSYNTH: { MusECore::MidiTrack* track = (MusECore::MidiTrack*)t; //QPopupMenu* p = MusECore::midiPortsPopup(0); MusECore::MidiDevice* md = 0; + int potential_new_port_no=-1; int port = -1; if(t->type() == MusECore::Track::AUDIO_SOFTSYNTH) { @@ -602,25 +608,158 @@ void TList::portsPopupMenu(MusECore::Track* t, int x, int y) port = track->outPort(); QMenu* p = MusECore::midiPortsPopup(this, port); // 0, port); + + if (t->type()==MusECore::Track::MIDI || t->type()==MusECore::Track::DRUM) //FINDMICHJETZT + { + // extend that menu a bit + + + // find first free port number + // do not permit numbers already used in other tracks! + // except if it's only used in this track. + int no; + for (no=0;no<MIDI_PORTS;no++) + if (MusEGlobal::midiPorts[no].device()==NULL) + { + MusECore::ciTrack it; + for (it=MusEGlobal::song->tracks()->begin(); it!=MusEGlobal::song->tracks()->end(); it++) + { + MusECore::MidiTrack* mt=dynamic_cast<MusECore::MidiTrack*>(*it); + if (mt && mt!=t && mt->outPort()==no) + break; + } + if (it == MusEGlobal::song->tracks()->end()) + break; + } + + if (no==MIDI_PORTS) + { + delete p; + printf("THIS IS VERY UNLIKELY TO HAPPEN: no free midi ports! you have used all %i!\n",MIDI_PORTS); + break; + } + + + potential_new_port_no=no; + typedef std::map<std::string, int > asmap; + typedef std::map<std::string, int >::iterator imap; + + asmap mapALSA; + asmap mapJACK; + + int aix = 0x10000000; + int jix = 0x20000000; + for(MusECore::iMidiDevice i = MusEGlobal::midiDevices.begin(); i != MusEGlobal::midiDevices.end(); ++i) + { + if((*i)->deviceType() == MusECore::MidiDevice::ALSA_MIDI) + { + // don't add devices which are used somewhere + int j; + for (j=0;j<MIDI_PORTS;j++) + if (MusEGlobal::midiPorts[j].device() == *i) + break; + + if (j==MIDI_PORTS) mapALSA.insert( std::pair<std::string, int> (std::string((*i)->name().toLatin1().constData()), aix) ); + + ++aix; + } + else if((*i)->deviceType() == MusECore::MidiDevice::JACK_MIDI) + { + // don't add devices which are used somewhere + int j; + for (j=0;j<MIDI_PORTS;j++) + if (MusEGlobal::midiPorts[j].device() == *i) + break; + + if (j==MIDI_PORTS) mapJACK.insert( std::pair<std::string, int> (std::string((*i)->name().toLatin1().constData()), jix) ); + ++jix; + } + } + + if (!mapALSA.empty() || !mapJACK.empty()) + { + QMenu* pup = p->addMenu(tr("Unused Devices")); + QAction* act; + + + if (!mapALSA.empty()) + { + pup->addAction(new MusEGui::MenuTitleItem("ALSA:", pup)); + + for(imap i = mapALSA.begin(); i != mapALSA.end(); ++i) + { + int idx = i->second; + QString s(i->first.c_str()); + MusECore::MidiDevice* md = MusEGlobal::midiDevices.find(s, MusECore::MidiDevice::ALSA_MIDI); + if(md) + { + if(md->deviceType() != MusECore::MidiDevice::ALSA_MIDI) + continue; + + act = pup->addAction(md->name()); + act->setData(idx); + } + } + } + + if (!mapALSA.empty() && !mapJACK.empty()) + pup->addSeparator(); + + if (!mapJACK.empty()) + { + pup->addAction(new MusEGui::MenuTitleItem("JACK:", pup)); + + for(imap i = mapJACK.begin(); i != mapJACK.end(); ++i) + { + int idx = i->second; + QString s(i->first.c_str()); + MusECore::MidiDevice* md = MusEGlobal::midiDevices.find(s, MusECore::MidiDevice::JACK_MIDI); + if(md) + { + if(md->deviceType() != MusECore::MidiDevice::JACK_MIDI) + continue; + + act = pup->addAction(md->name()); + act->setData(idx); + } + } + } + } + } + + QAction* act = p->exec(mapToGlobal(QPoint(x, y)), 0); if(!act) { delete p; break; } - + + QString acttext=act->text(); int n = act->data().toInt(); delete p; if(n < 0) // Invalid item. break; - if(n >= MIDI_PORTS) // Show port config dialog. + if(n == MIDI_PORTS) // Show port config dialog. { MusEGlobal::muse->configMidiPorts(); break; } + else if (n & 0x30000000) + { + int typ; + if (n & 0x10000000) + typ = MusECore::MidiDevice::ALSA_MIDI; + else + typ = MusECore::MidiDevice::JACK_MIDI; + MusECore::MidiDevice* sdev = MusEGlobal::midiDevices.find(acttext, typ); + + MusEGlobal::midiSeq->msgSetMidiDevice(&MusEGlobal::midiPorts[potential_new_port_no], sdev); + n=potential_new_port_no; + } // Changed by T356. //track->setOutPort(n); //MusEGlobal::audio->msgSetTrackOutPort(track, n); @@ -1049,7 +1188,7 @@ void TList::mousePressEvent(QMouseEvent* ev) if(act) { t = MusEGlobal::song->addNewTrack(act); // Add at end of list. - if(t) + if(t && t->isVisible()) { MusEGlobal::song->deselectTracks(); t->setSelected(true); @@ -1064,13 +1203,13 @@ void TList::mousePressEvent(QMouseEvent* ev) //delete synp; delete p; } - else if (button == Qt::LeftButton) { + /*else if (button == Qt::LeftButton) { if (!ctrl) { MusEGlobal::song->deselectTracks(); emit selectionChanged(0); } - } + }*/ return; } @@ -1108,7 +1247,8 @@ void TList::mousePressEvent(QMouseEvent* ev) return; } - mode = START_DRAG; + + mode = NORMAL; switch (col) { case COL_CLEF: @@ -1137,8 +1277,8 @@ void TList::mousePressEvent(QMouseEvent* ev) } delete p; } - break; + case COL_AUTOMATION: { if (!t->isMidiTrack()) { @@ -1174,6 +1314,8 @@ void TList::mousePressEvent(QMouseEvent* ev) case COL_RECORD: { + mode = START_DRAG; + bool val = !(t->recordFlag()); if (button == Qt::LeftButton) { if (!t->isMidiTrack()) { @@ -1212,6 +1354,7 @@ void TList::mousePressEvent(QMouseEvent* ev) } break; case COL_NONE: + mode = START_DRAG; break; case COL_CLASS: if (t->isMidiTrack()) @@ -1232,9 +1375,10 @@ void TList::mousePressEvent(QMouseEvent* ev) //MusEGlobal::audio->msgUpdateSoloStates(); // p4.0.14 //MusEGlobal::song->update(SC_ROUTE); // - break; + case COL_MUTE: + mode = START_DRAG; // p3.3.29 if ((button == Qt::RightButton) || (((QInputEvent*)ev)->modifiers() & Qt::ShiftModifier)) t->setOff(!t->off()); @@ -1248,11 +1392,13 @@ void TList::mousePressEvent(QMouseEvent* ev) MusEGlobal::song->update(SC_MUTE); break; case COL_SOLO: + mode = START_DRAG; MusEGlobal::audio->msgSetSolo(t, !t->solo()); MusEGlobal::song->update(SC_SOLO); break; case COL_NAME: + mode = START_DRAG; if (button == Qt::LeftButton) { if (!ctrl) { MusEGlobal::song->deselectTracks(); @@ -1327,11 +1473,13 @@ void TList::mousePressEvent(QMouseEvent* ev) break; case COL_TIMELOCK: + mode = START_DRAG; t->setLocked(!t->locked()); break; case COL_OCHANNEL: { + mode = START_DRAG; // or not? (flo) int delta = 0; if (button == Qt::RightButton) delta = 1; @@ -1397,6 +1545,9 @@ void TList::mousePressEvent(QMouseEvent* ev) } } break; + + default: + mode = START_DRAG; } redraw(); } |