diff options
author | Robert Jonsson <spamatica@gmail.com> | 2011-01-04 19:16:13 +0000 |
---|---|---|
committer | Robert Jonsson <spamatica@gmail.com> | 2011-01-04 19:16:13 +0000 |
commit | 217b37620cb47a9a6d9ae6c4027638d763e9df1b (patch) | |
tree | cac9681fa81489f57cbb29f9ae62da4fcbaa1665 /muse2/muse/arranger | |
parent | 212f604407e4a712563ca71eb281161ffcc91d85 (diff) |
automation viewable in arranger and rec changes
Diffstat (limited to 'muse2/muse/arranger')
-rw-r--r-- | muse2/muse/arranger/arranger.cpp | 6 | ||||
-rw-r--r-- | muse2/muse/arranger/pcanvas.cpp | 52 | ||||
-rw-r--r-- | muse2/muse/arranger/tlist.cpp | 125 | ||||
-rw-r--r-- | muse2/muse/arranger/tlist.h | 3 |
4 files changed, 131 insertions, 55 deletions
diff --git a/muse2/muse/arranger/arranger.cpp b/muse2/muse/arranger/arranger.cpp index d9cf5d5b..834b9613 100644 --- a/muse2/muse/arranger/arranger.cpp +++ b/muse2/muse/arranger/arranger.cpp @@ -67,7 +67,7 @@ void Arranger::setHeaderToolTips() header->setToolTip(COL_OCHANNEL, tr("Midi output channel number or audio channels")); header->setToolTip(COL_OPORT, tr("Midi output port or synth midi port")); header->setToolTip(COL_TIMELOCK, tr("Time Lock")); - //header->setToolTip(COL_AUTOMATION, tr("Automation parameter selection")); + header->setToolTip(COL_AUTOMATION, tr("Automation parameter selection")); } @@ -287,7 +287,7 @@ Arranger::Arranger(QMainWindow* parent, const char* name) header->setColumnLabel(tr("Port"), COL_OPORT, 60); header->setColumnLabel(tr("Ch"), COL_OCHANNEL, 30); header->setColumnLabel(tr("T"), COL_TIMELOCK, fm1.width('T')+fw); - //header->setColumnLabel(tr("Automation"), COL_AUTOMATION, 30); + header->setColumnLabel(tr("Automation"), COL_AUTOMATION, 75); header->setResizeMode(COL_RECORD, QHeaderView::Fixed); header->setResizeMode(COL_MUTE, QHeaderView::Fixed); header->setResizeMode(COL_SOLO, QHeaderView::Fixed); @@ -296,7 +296,7 @@ Arranger::Arranger(QMainWindow* parent, const char* name) header->setResizeMode(COL_OPORT, QHeaderView::Interactive); header->setResizeMode(COL_OCHANNEL, QHeaderView::Fixed); header->setResizeMode(COL_TIMELOCK, QHeaderView::Fixed); - //header->setResizeMode(COL_AUTOMATION, QHeaderView::Interactive); + header->setResizeMode(COL_AUTOMATION, QHeaderView::Interactive); setHeaderToolTips(); setHeaderWhatsThis(); diff --git a/muse2/muse/arranger/pcanvas.cpp b/muse2/muse/arranger/pcanvas.cpp index b57f524f..3e6919a7 100644 --- a/muse2/muse/arranger/pcanvas.cpp +++ b/muse2/muse/arranger/pcanvas.cpp @@ -2887,33 +2887,40 @@ void PartCanvas::drawAutomation(QPainter& p, const QRect& r, AudioTrack *t) // printf("drawAudioTrack %d x %d y %d w %d h %d\n",t, r.x(), r.y(), r.width(), r.height()); //int v2=r.x()+r.width(); //printf("v2=%d mapx=%d rmapx=%d mapxdev=%d rmapxdev=%d\n",v2, mapx(v2),rmapx(v2),mapxDev(v2),rmapxDev(v2)); - return; + //return; - p.setPen(QPen(Qt::black, 2, Qt::SolidLine)); +// p.setPen(QPen(Qt::black, 2, Qt::SolidLine)); int height=r.bottom()-r.top()-4; // limit height CtrlListList* cll = t->controller(); - QColor cols[10]; - cols[0]=Qt::white; - cols[1]=Qt::red; - cols[2]=Qt::yellow; - cols[3]=Qt::black; - cols[4]=Qt::blue; - int colIndex=0; +// QColor cols[10]; +// cols[0]=Qt::white; +// cols[1]=Qt::red; +// cols[2]=Qt::yellow; +// cols[3]=Qt::black; +// cols[4]=Qt::blue; + //int colIndex=0; bool firstRun=true; for(CtrlListList::iterator icll =cll->begin();icll!=cll->end();++icll) { //iCtrlList *icl = icll->second; CtrlList *cl = icll->second; + if (cl->dontShow()) + continue; double prevVal; iCtrl ic=cl->begin(); - p.setPen(QPen(cols[colIndex++],1,Qt::SolidLine)); + if (!cl->isVisible()) + continue; // skip this iteration if this controller isn't in the visible list + p.setPen(QPen(cl->color(),1,Qt::SolidLine)); - if (ic!=cl->end()) { // if there are no automation values we don't draw at all + // First check that there ARE automation, ic == cl->end means no automation + if (ic != cl->end()) { CtrlVal cvFirst = ic->second; ic++; int prevPos=cvFirst.frame; prevVal = cvFirst.val; + + // prepare prevVal if (cl->id() == AC_VOLUME ) { // use db scale for volume prevVal = (20.0*log10(cvFirst.val)+60) / 70.0; // represent volume between 0 and 1 if (prevVal < 0) prevVal = 0.0; @@ -2924,6 +2931,7 @@ void PartCanvas::drawAutomation(QPainter& p, const QRect& r, AudioTrack *t) cl->range(&min,&max); prevVal = (prevVal- min)/(max-min); } + for (; ic !=cl->end(); ++ic) { CtrlVal cv = ic->second; @@ -2938,29 +2946,27 @@ void PartCanvas::drawAutomation(QPainter& p, const QRect& r, AudioTrack *t) cl->range(&min,&max); nextVal = (nextVal- min)/(max-min); } - //printf("volume automation event %d %f %f %d\n",cv.frame,cv.val, tempomap.frame2tick(cv.frame)); - //p.drawLine(r.x(),(r.bottom()-2)-lastVal*height,r.x()+r.width(),(r.bottom()-2)-curVal*height); // debuggingtest int leftX=tempomap.frame2tick(prevPos); if (firstRun && leftX>r.x()) { - printf("first run\n"); leftX=r.x(); } - printf("inner draw\n"); - p.drawLine(leftX,(r.bottom()-2)-prevVal*height,tempomap.frame2tick(cv.frame),(r.bottom()-2)-prevVal*height); + p.drawLine( leftX, + (r.bottom()-2)-prevVal*height, + tempomap.frame2tick(cv.frame), + (r.bottom()-2)-nextVal*height); firstRun=false; //printf("draw line: %d %f %d %f\n",tempomap.frame2tick(lastPos),r.bottom()-lastVal*height,tempomap.frame2tick(cv.frame),r.bottom()-curVal*height); prevPos=cv.frame; prevVal=nextVal; } - printf("outer draw %f\n", cvFirst.val); - p.drawLine(tempomap.frame2tick(prevPos),(r.bottom()-2)-prevVal*height,tempomap.frame2tick(prevPos)+r.width(),(r.bottom()-2)-prevVal*height); - //printf("draw last line: %d %f %d %f\n",tempomap.frame2tick(lastPos),r.bottom()-lastVal*height,150000,r.bottom()-lastVal*height); + //printf("outer draw %f\n", cvFirst.val ); + p.drawLine(tempomap.frame2tick(prevPos), + (r.bottom()-2)-prevVal*height, + r.x()+r.width(), + (r.bottom()-2)-prevVal*height); + //printf("draw last line: %d %f %d %f\n",tempomap.frame2tick(prevPos),(r.bottom()-2)-prevVal*height,tempomap.frame2tick(prevPos)+r.width(),(r.bottom()-2)-prevVal*height); } -// if (height >100) { -// p.drawText(tempomap.frame2tick(0)+1000,40,"FOOO"); -// printf("drawText %s\n", cl->name().toLatin1().constData()); -// } } } diff --git a/muse2/muse/arranger/tlist.cpp b/muse2/muse/arranger/tlist.cpp index 4c104e0b..02f742f7 100644 --- a/muse2/muse/arranger/tlist.cpp +++ b/muse2/muse/arranger/tlist.cpp @@ -21,6 +21,7 @@ #include <QScrollBar> #include <QWheelEvent> +#include "popupmenu.h" #include "globals.h" #include "icons.h" #include "scrollscale.h" @@ -329,19 +330,19 @@ void TList::paint(const QRect& r) p.drawText(r, Qt::AlignVCenter|Qt::AlignLeft, s); } break; -// case COL_AUTOMATION: -// { -// QString s="-"; -// -// if (!track->isMidiTrack()) { -// int count = ((AudioTrack*)track)->controller()->size(); -// s.sprintf("%d", count); -// } -// -// -// p.drawText(r, Qt::AlignVCenter|Qt::AlignLeft, s); -// } -// break; + case COL_AUTOMATION: + { + QString s="-"; + + if (!track->isMidiTrack()) { + int count = ((AudioTrack*)track)->controller()->size(); + s.sprintf("%d viewed", count); + } + + + p.drawText(r, Qt::AlignVCenter|Qt::AlignLeft, s); + } + break; default: break; } @@ -774,6 +775,25 @@ TrackList TList::getRecEnabledTracks() // mousePressEvent //--------------------------------------------------------- +void TList::changeAutomation(QAction* act) +{ + printf("changeAutomation!\n"); + if (editTrack->type() == Track::MIDI) { + printf("this is wrong, we can't edit automation for midi tracks from arranger yet!\n"); + return; + } + + CtrlListList* cll = ((AudioTrack*)editTrack)->controller(); + int index=0; + for(CtrlListList::iterator icll =cll->begin();icll!=cll->end();++icll) { + if (act->data() == index++) { // got it, change state + CtrlList *cl = icll->second; + cl->setVisible(!cl->isVisible()); + } + } + song->update(SC_TRACK_MODIFIED); +} + void TList::mousePressEvent(QMouseEvent* ev) { int x = ev->x(); @@ -919,24 +939,73 @@ void TList::mousePressEvent(QMouseEvent* ev) mode = START_DRAG; switch (col) { + case COL_AUTOMATION: + { + if (t->type() != Track::MIDI) { + editTrack = t; + PopupMenu* p = new PopupMenu(); + p->disconnect(); + p->clear(); + p->setTitle(tr("Viewable automation")); + CtrlListList* cll = ((AudioTrack*)t)->controller(); + QAction* act = 0; + int index=0; + for(CtrlListList::iterator icll =cll->begin();icll!=cll->end();++icll) { + CtrlList *cl = icll->second; + if (cl->dontShow()) + continue; + act = p->addAction(cl->name()); + act->setCheckable(true); + act->setChecked(cl->isVisible()); + act->setData(index++); + } + connect(p, SIGNAL(triggered(QAction*)), SLOT(changeAutomation(QAction*))); + //connect(p, SIGNAL(aboutToHide()), muse, SLOT(routingPopupMenuAboutToHide())); + //p->popup(QCursor::pos()); + p->exec(QCursor::pos()); + + delete p; + } + break; + } + case COL_RECORD: { - bool val = !(t->recordFlag()); - if (!t->isMidiTrack()) { - if (t->type() == Track::AUDIO_OUTPUT) { - if (val && t->recordFlag() == false) { - muse->bounceToFile((AudioOutput*)t); + bool val = !(t->recordFlag()); + if (button == Qt::LeftButton) { + if (!t->isMidiTrack()) { + if (t->type() == Track::AUDIO_OUTPUT) { + if (val && t->recordFlag() == false) { + muse->bounceToFile((AudioOutput*)t); + } + audio->msgSetRecord((AudioOutput*)t, val); + if (!((AudioOutput*)t)->recFile()) + val = false; + else + return; } - audio->msgSetRecord((AudioOutput*)t, val); - if (!((AudioOutput*)t)->recFile()) - val = false; - else + song->setRecordFlag(t, val); + } + else + song->setRecordFlag(t, val); + } else if (button == Qt::RightButton) { + // enable or disable ALL tracks of this type + if (!t->isMidiTrack()) { + if (t->type() == Track::AUDIO_OUTPUT) { return; + } + WaveTrackList* wtl = song->waves(); + foreach (WaveTrack *wt, *wtl) { + song->setRecordFlag(wt, val); + } } - song->setRecordFlag(t, val); + else { + MidiTrackList* mtl = song->midis(); + foreach (MidiTrack *mt, *mtl) { + song->setRecordFlag(mt, val); + } } - else - song->setRecordFlag(t, val); + } } break; case COL_NONE: @@ -1001,7 +1070,7 @@ void TList::mousePressEvent(QMouseEvent* ev) mode = NORMAL; QMenu* p = new QMenu; //p->clear(); - p->addAction(QIcon(*automation_clear_dataIcon), tr("Delete Track"))->setData(0); // ddskrjo + p->addAction(QIcon(*automation_clear_dataIcon), tr("Delete Track"))->setData(0); p->addAction(QIcon(*track_commentIcon), tr("Track Comment"))->setData(1); QAction* act = p->exec(ev->globalPos(), 0); if (act) { @@ -1238,7 +1307,7 @@ void TList::mouseReleaseEvent(QMouseEvent* ev) setCursor(QCursor(Qt::ArrowCursor)); redraw(); } - if (editTrack) + if (editTrack && editor && editor->isVisible()) editor->setFocus(); adjustScrollbar(); } @@ -1265,7 +1334,7 @@ void TList::wheelEvent(QWheelEvent* ev) case COL_NONE: case COL_CLASS: case COL_NAME: - //case COL_AUTOMATION: + case COL_AUTOMATION: break; case COL_MUTE: // p3.3.29 diff --git a/muse2/muse/arranger/tlist.h b/muse2/muse/arranger/tlist.h index 3431a7a1..188685bc 100644 --- a/muse2/muse/arranger/tlist.h +++ b/muse2/muse/arranger/tlist.h @@ -34,9 +34,9 @@ enum TrackColumn { COL_OPORT, COL_OCHANNEL, COL_TIMELOCK, + COL_AUTOMATION, COL_NONE = -1 }; -// COL_AUTOMATION, -- not enabled //--------------------------------------------------------- // TList @@ -87,6 +87,7 @@ class TList : public QWidget { private slots: void returnPressed(); void songChanged(int flags); + void changeAutomation(QAction*); signals: ///void selectionChanged(); |