summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWerner Schweer <ws.seh.de>2006-09-04 12:52:43 +0000
committerWerner Schweer <ws.seh.de>2006-09-04 12:52:43 +0000
commitb266c2b2ba06a208fde6596a9eaef94e5e8eb19d (patch)
treeeb38132ce8615d7d9b3666b4ae5284f9f5f3901f
parentf238c5895b93a580ab781e96045ec2a8f52ec71d (diff)
midi cmd update
-rw-r--r--muse/muse/midiedit/CMakeLists.txt10
-rw-r--r--muse/muse/midiedit/gatetime.cpp76
-rw-r--r--muse/muse/midiedit/gatetime.h23
-rw-r--r--muse/muse/midiedit/gatetime.ui133
-rw-r--r--muse/muse/midiedit/midicmd.cpp181
-rw-r--r--muse/muse/midiedit/midicmd.h15
-rw-r--r--muse/muse/midiedit/prcanvas.cpp91
-rw-r--r--muse/muse/midiedit/prcanvas.h4
-rw-r--r--muse/muse/midiedit/velocity.cpp79
-rw-r--r--muse/muse/midiedit/velocity.h21
-rw-r--r--muse/muse/midiedit/velocity.ui129
11 files changed, 229 insertions, 533 deletions
diff --git a/muse/muse/midiedit/CMakeLists.txt b/muse/muse/midiedit/CMakeLists.txt
index c46a3dd0..384eed3f 100644
--- a/muse/muse/midiedit/CMakeLists.txt
+++ b/muse/muse/midiedit/CMakeLists.txt
@@ -19,6 +19,7 @@
#=============================================================================
QT4_WRAP_CPP ( midiedit_mocs
+ midicmd.h
gatetime.h
velocity.h
quantconfig.h
@@ -33,12 +34,18 @@ QT4_WRAP_CPP ( midiedit_mocs
)
QT4_WRAP_UI ( midiedit_ui_headers
+ midicmd.ui
gatetime.ui
velocity.ui
quantconfig.ui
)
add_library ( midiedit STATIC
+ midicmd.h
+ gatetime.h
+ ${midiedit_ui_headers}
+ ${midiedit_mocs}
+ midicmd.cpp
gatetime.cpp
velocity.cpp
quantconfig.cpp
@@ -52,13 +59,10 @@ add_library ( midiedit STATIC
drumedit.cpp
drummap.cpp
ecanvas.cpp
- midicmd.cpp
midieditor.cpp
pianoroll.cpp
prcanvas.cpp
miditracker.cpp
- ${midiedit_mocs}
- ${midiedit_ui_headers}
)
set_target_properties( midiedit
diff --git a/muse/muse/midiedit/gatetime.cpp b/muse/muse/midiedit/gatetime.cpp
index e75710c8..862d4aaf 100644
--- a/muse/muse/midiedit/gatetime.cpp
+++ b/muse/muse/midiedit/gatetime.cpp
@@ -29,14 +29,15 @@
GateTime::GateTime(QWidget*)
: MidiCmdDialog()
{
- setupUi(this);
- rangeGroup = new QButtonGroup(this);
- rangeGroup->setExclusive(true);
- rangeGroup->addButton(allEventsButton, RANGE_ALL);
- rangeGroup->addButton(selectedEventsButton, RANGE_SELECTED);
- rangeGroup->addButton(loopedEventsButton, RANGE_LOOPED);
- rangeGroup->addButton(selectedLoopedButton, RANGE_SELECTED | RANGE_LOOPED);
- allEventsButton->setChecked(true);
+ setWindowTitle(tr("MusE: Modify Gate Time"));
+ QWidget* gateTime = new QWidget;
+ gt.setupUi(gateTime);
+ layout->addWidget(gateTime);
+ layout->addStretch(10);
+ _rateVal = 0;
+ _offsetVal = 0;
+ gt.rate->setValue(_rateVal);
+ gt.offset->setValue(_offsetVal);
}
//---------------------------------------------------------
@@ -45,21 +46,60 @@ GateTime::GateTime(QWidget*)
void GateTime::accept()
{
- _range = rangeGroup->checkedId();
- _rateVal = rate->value();
- _offsetVal = offset->value();
- QDialog::accept();
+ _rateVal = gt.rate->value();
+ _offsetVal = gt.offset->value();
+ MidiCmdDialog::accept();
}
//---------------------------------------------------------
-// setRange
+// MidifyGateTime
//---------------------------------------------------------
-void GateTime::setRange(int id)
+ModifyGateTimeCmd::ModifyGateTimeCmd(MidiEditor* e)
+ : MidiCmd(e)
{
- if (rangeGroup->button(id))
- rangeGroup->button(id)->setChecked(true);
- else
- printf("setRange: not button %d!\n", id);
+ dialog = 0;
+ }
+
+//---------------------------------------------------------
+// guiDialog
+//---------------------------------------------------------
+
+MidiCmdDialog* ModifyGateTimeCmd::guiDialog()
+ {
+ if (dialog == 0)
+ dialog = new GateTime(0);
+ return dialog;
+ }
+
+//---------------------------------------------------------
+// process
+//---------------------------------------------------------
+
+void ModifyGateTimeCmd::process(CItemList* items)
+ {
+ int rate = dialog->rateVal();
+ int offset = dialog->offsetVal();
+
+ for (iCItem k = items->begin(); k != items->end(); ++k) {
+ CItem* item = k->second;
+ Event event = item->event;
+ if (event.type() != Note)
+ continue;
+
+ if (itemInRange(item)) {
+ unsigned len = event.lenTick();
+ len = rate ? (len * 100) / rate : 1;
+ len += offset;
+ if (len <= 1)
+ len = 1;
+
+ if (event.lenTick() != len) {
+ Event newEvent = event.clone();
+ newEvent.setLenTick(len);
+ changeEvent(event, newEvent, item->part);
+ }
+ }
+ }
}
diff --git a/muse/muse/midiedit/gatetime.h b/muse/muse/midiedit/gatetime.h
index f438fc1d..699b7c61 100644
--- a/muse/muse/midiedit/gatetime.h
+++ b/muse/muse/midiedit/gatetime.h
@@ -28,11 +28,10 @@
// GateTime
//---------------------------------------------------------
-class GateTime : public MidiCmdDialog, public Ui::GateTimeBase {
+class GateTime : public MidiCmdDialog {
Q_OBJECT
-
- QButtonGroup* rangeGroup;
- int _range;
+
+ Ui::GateTimeBase gt;
int _rateVal;
int _offsetVal;
@@ -41,11 +40,23 @@ class GateTime : public MidiCmdDialog, public Ui::GateTimeBase {
public:
GateTime(QWidget* parent = 0);
- void setRange(int id);
- int range() const { return _range; }
int rateVal() const { return _rateVal; }
int offsetVal() const { return _offsetVal; }
};
+//---------------------------------------------------------
+// ModifyGateTimeCmd
+//---------------------------------------------------------
+
+class ModifyGateTimeCmd : public MidiCmd
+ {
+ GateTime* dialog;
+ virtual MidiCmdDialog* guiDialog();
+ virtual void process(CItemList* items);
+
+ public:
+ ModifyGateTimeCmd(MidiEditor* e);
+ };
+
#endif
diff --git a/muse/muse/midiedit/gatetime.ui b/muse/muse/midiedit/gatetime.ui
index 76d45ddc..e1b92e7e 100644
--- a/muse/muse/midiedit/gatetime.ui
+++ b/muse/muse/midiedit/gatetime.ui
@@ -3,13 +3,13 @@
<comment></comment>
<exportmacro></exportmacro>
<class>GateTimeBase</class>
- <widget class="QDialog" name="GateTimeBase" >
+ <widget class="QWidget" name="GateTimeBase" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
- <width>387</width>
- <height>392</height>
+ <width>262</width>
+ <height>149</height>
</rect>
</property>
<property name="windowTitle" >
@@ -23,52 +23,6 @@
<number>6</number>
</property>
<item>
- <widget class="QGroupBox" name="rangeGroup" >
- <property name="title" >
- <string>Apply To</string>
- </property>
- <layout class="QVBoxLayout" >
- <property name="margin" >
- <number>6</number>
- </property>
- <property name="spacing" >
- <number>3</number>
- </property>
- <item>
- <widget class="QRadioButton" name="allEventsButton" >
- <property name="text" >
- <string>All Events</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QRadioButton" name="selectedEventsButton" >
- <property name="text" >
- <string>Selected Events</string>
- </property>
- <property name="checked" >
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QRadioButton" name="loopedEventsButton" >
- <property name="text" >
- <string>Looped Events</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QRadioButton" name="selectedLoopedButton" >
- <property name="text" >
- <string>Selected AND Looped</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- <item>
<widget class="QGroupBox" name="GroupBox3" >
<property name="title" >
<string>Values</string>
@@ -123,88 +77,9 @@
</layout>
</widget>
</item>
- <item>
- <layout class="QHBoxLayout" >
- <property name="margin" >
- <number>0</number>
- </property>
- <property name="spacing" >
- <number>6</number>
- </property>
- <item>
- <spacer>
- <property name="orientation" >
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeType" >
- <enum>QSizePolicy::Expanding</enum>
- </property>
- <property name="sizeHint" >
- <size>
- <width>20</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QPushButton" name="okButton" >
- <property name="text" >
- <string>OK</string>
- </property>
- <property name="autoDefault" >
- <bool>false</bool>
- </property>
- <property name="default" >
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="cancelButton" >
- <property name="text" >
- <string>Cancel</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
</layout>
</widget>
<pixmapfunction>qPixmapFromMimeSource</pixmapfunction>
<resources/>
- <connections>
- <connection>
- <sender>okButton</sender>
- <signal>clicked()</signal>
- <receiver>GateTimeBase</receiver>
- <slot>accept()</slot>
- <hints>
- <hint type="sourcelabel" >
- <x>211</x>
- <y>360</y>
- </hint>
- <hint type="destinationlabel" >
- <x>36</x>
- <y>356</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>cancelButton</sender>
- <signal>clicked()</signal>
- <receiver>GateTimeBase</receiver>
- <slot>reject()</slot>
- <hints>
- <hint type="sourcelabel" >
- <x>316</x>
- <y>372</y>
- </hint>
- <hint type="destinationlabel" >
- <x>124</x>
- <y>378</y>
- </hint>
- </hints>
- </connection>
- </connections>
+ <connections/>
</ui>
diff --git a/muse/muse/midiedit/midicmd.cpp b/muse/muse/midiedit/midicmd.cpp
index 231a442f..bb6b1972 100644
--- a/muse/muse/midiedit/midicmd.cpp
+++ b/muse/muse/midiedit/midicmd.cpp
@@ -24,6 +24,7 @@
#include "velocity.h"
#include "audio.h"
#include "midieditor.h"
+#include "widgets/tb1.h"
//==========================================================
// class MidiCmd is an attempt to formalize the
@@ -37,8 +38,42 @@
//---------------------------------------------------------
MidiCmdDialog::MidiCmdDialog()
- : QDialog(0)
+ : QDialog()
{
+ QWidget* rangeWidget = new QWidget;
+ mc.setupUi(rangeWidget);
+ layout = new QVBoxLayout;
+ setLayout(layout);
+ layout->addWidget(rangeWidget);
+ rangeGroup = new QButtonGroup(this);
+ rangeGroup->setExclusive(true);
+ rangeGroup->addButton(mc.allEventsButton, RANGE_ALL);
+ rangeGroup->addButton(mc.selectedEventsButton, RANGE_SELECTED);
+ rangeGroup->addButton(mc.loopedEventsButton, RANGE_LOOPED);
+ rangeGroup->addButton(mc.selectedLoopedButton, RANGE_SELECTED | RANGE_LOOPED);
+ mc.allEventsButton->setChecked(true);
+ }
+
+//---------------------------------------------------------
+// setRange
+//---------------------------------------------------------
+
+void MidiCmdDialog::setRange(int id)
+ {
+ if (rangeGroup->button(id))
+ rangeGroup->button(id)->setChecked(true);
+ else
+ printf("setRange: not button %d!\n", id);
+ }
+
+//---------------------------------------------------------
+// accept
+//---------------------------------------------------------
+
+void MidiCmdDialog::accept()
+ {
+ _range = rangeGroup->checkedId();
+ QDialog::accept();
}
//---------------------------------------------------------
@@ -57,16 +92,13 @@ MidiCmd::MidiCmd(MidiEditor* e)
void MidiCmd::processEvents(CItemList* items)
{
MidiCmdDialog* dialog = guiDialog();
- editor->applyTo();
+ range = editor->applyTo();
dialog->setRange(range);
bool rv = dialog->exec();
- if (!rv) {
- delete dialog;
+ if (!rv)
return;
- }
range = dialog->range(); // all, selected, looped, sel+loop
editor->setApplyTo(range);
- delete dialog;
modified = 0;
song->startUndo();
@@ -101,140 +133,3 @@ void MidiCmd::changeEvent(Event oldEvent, Event newEvent, Part* part)
modified = SC_EVENT_MODIFIED;
}
-//==================================================================
-// process midi event lists
-//==================================================================
-
-//---------------------------------------------------------
-// ModifyGateTimeCmd
-//---------------------------------------------------------
-
-class ModifyGateTimeCmd : public MidiCmd
- {
- GateTime* dialog;
- virtual MidiCmdDialog* guiDialog();
- virtual void process(CItemList* items);
-
- public:
- ModifyGateTimeCmd(MidiEditor* e);
- };
-
-//---------------------------------------------------------
-// MidifyGateTime
-//---------------------------------------------------------
-
-ModifyGateTimeCmd::ModifyGateTimeCmd(MidiEditor* e)
- : MidiCmd(e)
- {
- dialog = 0;
- }
-
-//---------------------------------------------------------
-// guiDialog
-//---------------------------------------------------------
-
-MidiCmdDialog* ModifyGateTimeCmd::guiDialog()
- {
- if (dialog == 0)
- dialog = new GateTime(0);
- return dialog;
- }
-
-//---------------------------------------------------------
-// process
-//---------------------------------------------------------
-
-void ModifyGateTimeCmd::process(CItemList* items)
- {
- int rate = dialog->rateVal();
- int offset = dialog->offsetVal();
-
- for (iCItem k = items->begin(); k != items->end(); ++k) {
- CItem* item = k->second;
- Event event = item->event;
- if (event.type() != Note)
- continue;
-
- if (itemInRange(item)) {
- unsigned len = event.lenTick();
- len = rate ? (len * 100) / rate : 1;
- len += offset;
- if (len <= 1)
- len = 1;
-
- if (event.lenTick() != len) {
- Event newEvent = event.clone();
- newEvent.setLenTick(len);
- changeEvent(event, newEvent, item->part);
- }
- }
- }
- }
-
-//---------------------------------------------------------
-// ModifyVelocityCmd
-//---------------------------------------------------------
-
-class ModifyVelocityCmd : public MidiCmd
- {
- Velocity* dialog;
- virtual MidiCmdDialog* guiDialog();
- virtual void process(CItemList* items);
-
- public:
- ModifyVelocityCmd(MidiEditor* e);
- };
-
-//---------------------------------------------------------
-// ModifyVelocityCmd
-//---------------------------------------------------------
-
-ModifyVelocityCmd::ModifyVelocityCmd(MidiEditor* e)
- : MidiCmd(e)
- {
- dialog = 0;
- }
-
-//---------------------------------------------------------
-// guiDialog
-//---------------------------------------------------------
-
-MidiCmdDialog* ModifyVelocityCmd::guiDialog()
- {
- if (dialog == 0)
- dialog = new Velocity(0);
- return dialog;
- }
-
-//---------------------------------------------------------
-// process
-//---------------------------------------------------------
-
-void ModifyVelocityCmd::process(CItemList* items)
- {
- int rate = dialog->rateVal();
- int offset = dialog->offsetVal();
-
- for (iCItem k = items->begin(); k != items->end(); ++k) {
- CItem* item = k->second;
- Event event = item->event;
- if (event.type() != Note)
- continue;
- if (itemInRange(item)) {
- int velo = event.velo();
- velo = (velo * rate) / 100;
- velo += offset;
-
- if (velo <= 0)
- velo = 1;
- if (velo > 127)
- velo = 127;
- if (event.velo() != velo) {
- Event newEvent = event.clone();
- newEvent.setVelo(velo);
- audio->msgChangeEvent(event, newEvent, item->part, false);
- }
- }
- }
- }
-
diff --git a/muse/muse/midiedit/midicmd.h b/muse/muse/midiedit/midicmd.h
index 0e4a9b43..f78f9cb9 100644
--- a/muse/muse/midiedit/midicmd.h
+++ b/muse/muse/midiedit/midicmd.h
@@ -22,21 +22,32 @@
#define __MIDICMD_H__
#include "citem.h"
+#include "ui_midicmd.h"
class MidiEditor;
class MidiCmdDialog;
//---------------------------------------------------------
// MidiCmdDialog
+// GUI base class for midiCmd
//---------------------------------------------------------
class MidiCmdDialog : public QDialog
{
+ Q_OBJECT
+
+ QButtonGroup* rangeGroup;
+ int _range;
+ Ui::MidiCmd mc;
+
+ protected:
+ void accept();
+ QVBoxLayout* layout;
public:
MidiCmdDialog();
- int range() const { return 0; }
- void setRange(int /*val*/) { }
+ int range() const { return _range; }
+ void setRange(int);
};
//---------------------------------------------------------
diff --git a/muse/muse/midiedit/prcanvas.cpp b/muse/muse/midiedit/prcanvas.cpp
index df674e0e..9356abad 100644
--- a/muse/muse/midiedit/prcanvas.cpp
+++ b/muse/muse/midiedit/prcanvas.cpp
@@ -27,6 +27,9 @@
#include "audio.h"
#include "part.h"
+#include "velocity.h"
+#include "gatetime.h"
+
//---------------------------------------------------------
// PianoCanvas
//---------------------------------------------------------
@@ -39,6 +42,10 @@ PianoCanvas::PianoCanvas(MidiEditor* pr)
colorMode = 0;
canvasTools = PointerTool | PencilTool | RubberTool | DrawTool;
+ // register midi commands
+ cmdModifyGateTime = new ModifyGateTimeCmd(pr);
+ cmdModifyVelocity = new ModifyVelocityCmd(pr);
+
songChanged(SC_TRACK_INSERTED);
}
@@ -442,91 +449,11 @@ void PianoCanvas::cmd(int cmd, int quantStrength, int quantLimit, bool quantLen)
}
break;
case CMD_MODIFY_GATE_TIME:
- {
- GateTime w(this);
- w.setRange(editor->applyTo());
- if (!w.exec())
- break;
- int range = w.range(); // all, selected, looped, sel+loop
- int rate = w.rateVal();
- int offset = w.offsetVal();
- editor->setApplyTo(range);
-
- song->startUndo();
- for (iCItem k = items.begin(); k != items.end(); ++k) {
- CItem* item = k->second;
- Event event = item->event;
- if (event.type() != Note)
- continue;
- unsigned tick = event.tick();
- bool selected = k->second->isSelected();
- bool inLoop = (tick >= song->lpos()) && (tick < song->rpos());
-
- if ((range == 0)
- || (range == 1 && selected)
- || (range == 2 && inLoop)
- || (range == 3 && selected && inLoop)) {
- unsigned len = event.lenTick();
-
- len = rate ? (len * 100) / rate : 1;
- len += offset;
- if (len <= 1)
- len = 1;
-
- if (event.lenTick() != len) {
- Event newEvent = event.clone();
- newEvent.setLenTick(len);
- audio->msgChangeEvent(event, newEvent, item->part, false);
- }
- }
- }
- song->endUndo(SC_EVENT_MODIFIED);
- }
+ cmdModifyGateTime->processEvents(&items);
break;
case CMD_MODIFY_VELOCITY:
- {
- Velocity w(this);
- w.setRange(editor->applyTo());
- if (!w.exec())
- break;
- int range = w.range(); // all, selected, looped, sel+loop
- int rate = w.rateVal();
- int offset = w.offsetVal();
-
- song->startUndo();
- for (iCItem k = items.begin(); k != items.end(); ++k) {
- CItem* item = k->second;
- Event event = item->event;
- if (event.type() != Note)
- continue;
- unsigned tick = event.tick();
- bool selected = k->second->isSelected();
- bool inLoop = (tick >= song->lpos()) && (tick < song->rpos());
-
- if ((range == 0)
- || (range == 1 && selected)
- || (range == 2 && inLoop)
- || (range == 3 && selected && inLoop)) {
- int velo = event.velo();
-
- //velo = rate ? (velo * 100) / rate : 64;
- velo = (velo * rate) / 100;
- velo += offset;
-
- if (velo <= 0)
- velo = 1;
- if (velo > 127)
- velo = 127;
- if (event.velo() != velo) {
- Event newEvent = event.clone();
- newEvent.setVelo(velo);
- audio->msgChangeEvent(event, newEvent, item->part, false);
- }
- }
- }
- song->endUndo(SC_EVENT_MODIFIED);
- }
+ cmdModifyVelocity->processEvents(&items);
break;
case CMD_CRESCENDO:
diff --git a/muse/muse/midiedit/prcanvas.h b/muse/muse/midiedit/prcanvas.h
index 63cb689c..95e4cecc 100644
--- a/muse/muse/midiedit/prcanvas.h
+++ b/muse/muse/midiedit/prcanvas.h
@@ -24,6 +24,7 @@
#include "ecanvas.h"
class CItem;
+class MidiCmd;
//---------------------------------------------------------
// PianoCanvas
@@ -35,6 +36,9 @@ class PianoCanvas : public EventCanvas {
int colorMode;
int playedPitch;
+ MidiCmd* cmdModifyGateTime;
+ MidiCmd* cmdModifyVelocity;
+
virtual void paint(QPainter&, QRect);
virtual CItem* searchItem(const QPoint& p) const;
virtual void addItem(Part* part, const Event& event);
diff --git a/muse/muse/midiedit/velocity.cpp b/muse/muse/midiedit/velocity.cpp
index a011317d..f0abd845 100644
--- a/muse/muse/midiedit/velocity.cpp
+++ b/muse/muse/midiedit/velocity.cpp
@@ -21,6 +21,7 @@
#include "velocity.h"
#include "song.h"
#include "tb1.h"
+#include "audio.h"
//---------------------------------------------------------
// Velocity
@@ -29,14 +30,15 @@
Velocity::Velocity(QWidget*)
: MidiCmdDialog()
{
- setupUi(this);
- rangeGroup = new QButtonGroup(this);
- rangeGroup->setExclusive(true);
- rangeGroup->addButton(allEventsButton, RANGE_ALL);
- rangeGroup->addButton(selectedEventsButton, RANGE_SELECTED);
- rangeGroup->addButton(loopedEventsButton, RANGE_LOOPED);
- rangeGroup->addButton(selectedLoopedButton, RANGE_SELECTED | RANGE_LOOPED);
- allEventsButton->setChecked(true);
+ setWindowTitle(tr("MusE: Modify Velocity"));
+ QWidget* velocityWidget = new QWidget;
+ velo.setupUi(velocityWidget);
+ layout->addWidget(velocityWidget);
+ layout->addStretch(10);
+ _rateVal = 0;
+ _offsetVal = 0;
+ velo.rate->setValue(_rateVal);
+ velo.offset->setValue(_offsetVal);
}
//---------------------------------------------------------
@@ -45,21 +47,62 @@ Velocity::Velocity(QWidget*)
void Velocity::accept()
{
- _range = rangeGroup->checkedId();
- _rateVal = rate->value();
- _offsetVal = offset->value();
- QDialog::accept();
+ _rateVal = velo.rate->value();
+ _offsetVal = velo.offset->value();
+ MidiCmdDialog::accept();
}
//---------------------------------------------------------
-// setRange
+// ModifyVelocityCmd
//---------------------------------------------------------
-void Velocity::setRange(int id)
+ModifyVelocityCmd::ModifyVelocityCmd(MidiEditor* e)
+ : MidiCmd(e)
{
- if (rangeGroup->button(id))
- rangeGroup->button(id)->setChecked(true);
- else
- printf("setRange: not button %d!\n", id);
+ dialog = 0;
}
+//---------------------------------------------------------
+// guiDialog
+//---------------------------------------------------------
+
+MidiCmdDialog* ModifyVelocityCmd::guiDialog()
+ {
+ if (dialog == 0)
+ dialog = new Velocity(0);
+ return dialog;
+ }
+
+//---------------------------------------------------------
+// process
+//---------------------------------------------------------
+
+void ModifyVelocityCmd::process(CItemList* items)
+ {
+ int rate = dialog->rateVal();
+ int offset = dialog->offsetVal();
+
+ for (iCItem k = items->begin(); k != items->end(); ++k) {
+ CItem* item = k->second;
+ Event event = item->event;
+ if (event.type() != Note)
+ continue;
+ if (itemInRange(item)) {
+ int velo = event.velo();
+ velo = (velo * rate) / 100;
+ velo += offset;
+
+ if (velo <= 0)
+ velo = 1;
+ if (velo > 127)
+ velo = 127;
+ if (event.velo() != velo) {
+ Event newEvent = event.clone();
+ newEvent.setVelo(velo);
+ audio->msgChangeEvent(event, newEvent, item->part, false);
+ }
+ }
+ }
+ }
+
+
diff --git a/muse/muse/midiedit/velocity.h b/muse/muse/midiedit/velocity.h
index 8cbf1e26..2ac4e700 100644
--- a/muse/muse/midiedit/velocity.h
+++ b/muse/muse/midiedit/velocity.h
@@ -28,11 +28,10 @@
// Velocity
//---------------------------------------------------------
-class Velocity : public MidiCmdDialog, public Ui::VelocityBase {
+class Velocity : public MidiCmdDialog {
Q_OBJECT
- QButtonGroup* rangeGroup;
- int _range;
+ Ui::VelocityBase velo;
int _rateVal;
int _offsetVal;
@@ -41,11 +40,23 @@ class Velocity : public MidiCmdDialog, public Ui::VelocityBase {
public:
Velocity(QWidget* parent = 0);
- void setRange(int id);
- int range() const { return _range; }
int rateVal() const { return _rateVal; }
int offsetVal() const { return _offsetVal; }
};
+//---------------------------------------------------------
+// ModifyVelocityCmd
+//---------------------------------------------------------
+
+class ModifyVelocityCmd : public MidiCmd
+ {
+ Velocity* dialog;
+ virtual MidiCmdDialog* guiDialog();
+ virtual void process(CItemList* items);
+
+ public:
+ ModifyVelocityCmd(MidiEditor* e);
+ };
+
#endif
diff --git a/muse/muse/midiedit/velocity.ui b/muse/muse/midiedit/velocity.ui
index e0122520..342611c0 100644
--- a/muse/muse/midiedit/velocity.ui
+++ b/muse/muse/midiedit/velocity.ui
@@ -3,7 +3,7 @@
<comment></comment>
<exportmacro></exportmacro>
<class>VelocityBase</class>
- <widget class="QDialog" name="VelocityBase" >
+ <widget class="QWidget" name="VelocityBase" >
<property name="geometry" >
<rect>
<x>0</x>
@@ -23,52 +23,6 @@
<number>6</number>
</property>
<item>
- <widget class="QGroupBox" name="rangeGroup" >
- <property name="title" >
- <string>Apply To</string>
- </property>
- <layout class="QVBoxLayout" >
- <property name="margin" >
- <number>6</number>
- </property>
- <property name="spacing" >
- <number>3</number>
- </property>
- <item>
- <widget class="QRadioButton" name="allEventsButton" >
- <property name="text" >
- <string>All Events</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QRadioButton" name="selectedEventsButton" >
- <property name="text" >
- <string>Selected Events</string>
- </property>
- <property name="checked" >
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QRadioButton" name="loopedEventsButton" >
- <property name="text" >
- <string>Looped Events</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QRadioButton" name="selectedLoopedButton" >
- <property name="text" >
- <string>Selected AND Looped</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- </item>
- <item>
<widget class="QGroupBox" name="GroupBox3" >
<property name="title" >
<string>Values</string>
@@ -123,89 +77,10 @@
</layout>
</widget>
</item>
- <item>
- <layout class="QHBoxLayout" >
- <property name="margin" >
- <number>0</number>
- </property>
- <property name="spacing" >
- <number>6</number>
- </property>
- <item>
- <spacer>
- <property name="orientation" >
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeType" >
- <enum>QSizePolicy::Expanding</enum>
- </property>
- <property name="sizeHint" >
- <size>
- <width>20</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QPushButton" name="okButton" >
- <property name="text" >
- <string>OK</string>
- </property>
- <property name="autoDefault" >
- <bool>false</bool>
- </property>
- <property name="default" >
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="cancelButton" >
- <property name="text" >
- <string>Cancel</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11" />
<pixmapfunction>qPixmapFromMimeSource</pixmapfunction>
<resources/>
- <connections>
- <connection>
- <sender>okButton</sender>
- <signal>clicked()</signal>
- <receiver>VelocityBase</receiver>
- <slot>accept()</slot>
- <hints>
- <hint type="sourcelabel" >
- <x>204</x>
- <y>362</y>
- </hint>
- <hint type="destinationlabel" >
- <x>59</x>
- <y>357</y>
- </hint>
- </hints>
- </connection>
- <connection>
- <sender>cancelButton</sender>
- <signal>clicked()</signal>
- <receiver>VelocityBase</receiver>
- <slot>reject()</slot>
- <hints>
- <hint type="sourcelabel" >
- <x>322</x>
- <y>377</y>
- </hint>
- <hint type="destinationlabel" >
- <x>127</x>
- <y>377</y>
- </hint>
- </hints>
- </connection>
- </connections>
+ <connections/>
</ui>