summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Jung <flo@windfisch.org>2011-05-08 14:08:06 +0000
committerFlorian Jung <flo@windfisch.org>2011-05-08 14:08:06 +0000
commit94583a696436a3bec385223efaea730768720975 (patch)
treecf216cbc526a27582e43b6e39a3c80788cbb7a13
parent777badc6ba80b5bc244e8e3141b2fd0257271a89 (diff)
made quantize, modify note len and modify velocity functions global
added quantize-dialog and improved the other dialogs
-rw-r--r--muse2/muse/CMakeLists.txt1
-rw-r--r--muse2/muse/app.cpp4
-rw-r--r--muse2/muse/functions.cpp237
-rw-r--r--muse2/muse/functions.h40
-rw-r--r--muse2/muse/main.cpp4
-rw-r--r--muse2/muse/midiedit/CMakeLists.txt2
-rw-r--r--muse2/muse/midiedit/dcanvas.cpp49
-rw-r--r--muse2/muse/midiedit/drumedit.cpp4
-rw-r--r--muse2/muse/midiedit/pianoroll.cpp62
-rw-r--r--muse2/muse/midiedit/pianoroll.h9
-rw-r--r--muse2/muse/midiedit/prcanvas.cpp159
-rw-r--r--muse2/muse/midiedit/prcanvas.h7
-rw-r--r--muse2/muse/midiedit/quantconfig.cpp79
-rw-r--r--muse2/muse/midiedit/quantconfig.h32
-rw-r--r--muse2/muse/midiedit/scoreedit.cpp43
-rw-r--r--muse2/muse/midiedit/scoreedit.h12
-rw-r--r--muse2/muse/widgets/CMakeLists.txt3
-rw-r--r--muse2/muse/widgets/gatetime.cpp26
-rw-r--r--muse2/muse/widgets/gatetime.h16
-rw-r--r--muse2/muse/widgets/gatetimebase.ui13
-rw-r--r--muse2/muse/widgets/quantbase.ui308
-rw-r--r--muse2/muse/widgets/quantize.cpp54
-rw-r--r--muse2/muse/widgets/quantize.h40
-rw-r--r--muse2/muse/widgets/velocity.cpp28
-rw-r--r--muse2/muse/widgets/velocity.h19
-rw-r--r--muse2/muse/widgets/velocitybase.ui14
26 files changed, 834 insertions, 431 deletions
diff --git a/muse2/muse/CMakeLists.txt b/muse2/muse/CMakeLists.txt
index 2d2a9fe3..3117cf2f 100644
--- a/muse2/muse/CMakeLists.txt
+++ b/muse2/muse/CMakeLists.txt
@@ -89,6 +89,7 @@ file (GLOB core_source_files
event.cpp
eventlist.cpp
exportmidi.cpp
+ functions.cpp
gconfig.cpp
globals.cpp
help.cpp
diff --git a/muse2/muse/app.cpp b/muse2/muse/app.cpp
index 052bb48b..7bf171e5 100644
--- a/muse2/muse/app.cpp
+++ b/muse2/muse/app.cpp
@@ -31,7 +31,6 @@
#include "didyouknow.h"
#include "drumedit.h"
#include "filedialog.h"
-#include "gatetime.h"
#include "gconfig.h"
#include "gui.h"
#include "icons.h"
@@ -4184,8 +4183,7 @@ void MusE::transpose()
void MusE::modifyGateTime()
{
- GateTime* w = new GateTime(this);
- w->show();
+ printf("not implemented\n");
}
//---------------------------------------------------------
diff --git a/muse2/muse/functions.cpp b/muse2/muse/functions.cpp
new file mode 100644
index 00000000..980a5103
--- /dev/null
+++ b/muse2/muse/functions.cpp
@@ -0,0 +1,237 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: functions.cpp,v 1.20.2.19 2011/05/05 20:10 flo93 Exp $
+// (C) Copyright 2011 Florian Jung (flo93@sourceforge.net)
+//=========================================================
+
+#include "functions.h"
+#include "song.h"
+
+#include "event.h"
+#include "audio.h"
+#include "gconfig.h"
+
+#include <iostream>
+
+using namespace std;
+
+GateTime* gatetime_dialog=NULL;
+Velocity* velocity_dialog=NULL;
+Quantize* quantize_dialog=NULL;
+
+void init_function_dialogs(QWidget* parent)
+{
+ gatetime_dialog = new GateTime(parent);
+ velocity_dialog = new Velocity(parent);
+ quantize_dialog = new Quantize(parent);
+}
+
+set<Part*> partlist_to_set(PartList* pl)
+{
+ set<Part*> result;
+
+ for (PartList::iterator it=pl->begin(); it!=pl->end(); it++)
+ result.insert(it->second);
+
+ return result;
+}
+
+bool is_relevant(const Event& event, const Part* part, int range)
+{
+ unsigned tick;
+
+ if (event.type()!=Note) return false;
+
+ switch (range)
+ {
+ case 0: return true;
+ case 1: return event.selected();
+ case 2: tick=event.tick()+part->tick(); return (tick >= song->lpos()) && (tick < song->rpos());
+ case 3: return is_relevant(event,part,1) && is_relevant(event,part,2);
+ default: cout << "ERROR: ILLEGAL FUNCTION CALL in is_relevant: range is illegal: "<<range<<endl;
+ return false;
+ }
+}
+
+bool modify_notelen(const set<Part*>& parts)
+{
+ if (!gatetime_dialog->exec())
+ return false;
+
+ modify_notelen(parts,gatetime_dialog->range,gatetime_dialog->rateVal,gatetime_dialog->offsetVal);
+
+ return true;
+}
+
+bool modify_velocity(const set<Part*>& parts)
+{
+ if (!velocity_dialog->exec())
+ return false;
+
+ modify_velocity(parts,velocity_dialog->range,velocity_dialog->rateVal,velocity_dialog->offsetVal);
+
+ return true;
+}
+
+bool quantize_notes(const set<Part*>& parts)
+{
+ if (!quantize_dialog->exec())
+ return false;
+
+ quantize_notes(parts, quantize_dialog->range, (config.division*4)/(1<<quantize_dialog->raster_power2),
+ quantize_dialog->strength, quantize_dialog->swing, quantize_dialog->threshold);
+
+ return true;
+}
+
+
+
+void modify_velocity(const set<Part*>& parts, int range, int rate, int offset)
+{
+ map<Event*, Part*> events;
+
+ for (set<Part*>::iterator part=parts.begin(); part!=parts.end(); part++)
+ for (iEvent event=(*part)->events()->begin(); event!=(*part)->events()->end(); event++)
+ if (is_relevant(event->second, *part, range))
+ events.insert(pair<Event*, Part*>(&event->second, *part));
+
+
+ song->startUndo();
+
+ for (map<Event*, Part*>::iterator it=events.begin(); it!=events.end(); it++)
+ {
+ Event& event=*(it->first);
+ Part* part=it->second;
+
+ int velo = event.velo();
+
+ velo = (velo * rate) / 100;
+ velo += offset;
+
+ if (velo <= 0)
+ velo = 1;
+ else if (velo > 127)
+ velo = 127;
+
+ if (event.velo() != velo)
+ {
+ Event newEvent = event.clone();
+ newEvent.setVelo(velo);
+ // Indicate no undo, and do not do port controller values and clone parts.
+ audio->msgChangeEvent(event, newEvent, part, false, false, false);
+ }
+ }
+
+ song->endUndo(SC_EVENT_MODIFIED);
+}
+
+void modify_notelen(const set<Part*>& parts, int range, int rate, int offset)
+{
+ map<Event*, Part*> events;
+
+ for (set<Part*>::iterator part=parts.begin(); part!=parts.end(); part++)
+ for (iEvent event=(*part)->events()->begin(); event!=(*part)->events()->end(); event++)
+ if (is_relevant(event->second, *part, range))
+ events.insert(pair<Event*, Part*>(&event->second, *part));
+
+
+ song->startUndo();
+
+ for (map<Event*, Part*>::iterator it=events.begin(); it!=events.end(); it++)
+ {
+ Event& event=*(it->first);
+ Part* part=it->second;
+
+ unsigned int len = event.lenTick(); //prevent compiler warning: comparison singed/unsigned
+
+ len = (len * rate) / 100;
+ len += offset;
+
+ if (len <= 0)
+ len = 1;
+
+ if (event.lenTick() != len)
+ {
+ Event newEvent = event.clone();
+ newEvent.setLenTick(len);
+ // Indicate no undo, and do not do port controller values and clone parts.
+ audio->msgChangeEvent(event, newEvent, part, false, false, false);
+ }
+ }
+
+ song->endUndo(SC_EVENT_MODIFIED);
+}
+
+unsigned quantize_tick(unsigned tick, unsigned raster, int swing)
+{
+ //find out the nearest tick and the distance to it:
+ //this is so complicated because this function supports
+ //swing: if swing is 50, the resulting rhythm is not
+ //"daa daa daa daa" but "daaaa da daaaa da"...
+ int tick_dest1 = AL::sigmap.raster1(tick, raster*2); //round down
+ int tick_dest2 = tick_dest1 + raster + raster*swing/100;
+ int tick_dest3 = tick_dest1 + raster*2;
+
+ int tick_diff1 = tick_dest1 - tick;
+ int tick_diff2 = tick_dest2 - tick;
+ int tick_diff3 = tick_dest3 - tick;
+
+ if ((abs(tick_diff1) <= abs(tick_diff2)) && (abs(tick_diff1) <= abs(tick_diff3))) //tick_dest1 is the nearest tick
+ return tick_dest1;
+ else if ((abs(tick_diff2) <= abs(tick_diff1)) && (abs(tick_diff2) <= abs(tick_diff3))) //tick_dest2 is the nearest tick
+ return tick_dest2;
+ else
+ return tick_dest3;
+}
+
+void quantize_notes(const set<Part*>& parts, int range, int raster, int strength, int swing, int threshold)
+{
+ map<Event*, Part*> events;
+
+ for (set<Part*>::iterator part=parts.begin(); part!=parts.end(); part++)
+ for (iEvent event=(*part)->events()->begin(); event!=(*part)->events()->end(); event++)
+ if (is_relevant(event->second, *part, range))
+ events.insert(pair<Event*, Part*>(&event->second, *part));
+
+
+ song->startUndo();
+
+ for (map<Event*, Part*>::iterator it=events.begin(); it!=events.end(); it++)
+ {
+ Event& event=*(it->first);
+ Part* part=it->second;
+
+ unsigned begin_tick = event.tick() + part->tick();
+ int begin_diff = quantize_tick(begin_tick, raster, swing) - begin_tick;
+
+ if (abs(begin_diff) > threshold)
+ begin_tick = begin_tick + begin_diff*strength/100;
+
+
+ unsigned len=event.lenTick();
+
+ unsigned end_tick = begin_tick + len;
+ int len_diff = quantize_tick(end_tick, raster, swing) - end_tick;
+
+ if (abs(len_diff) > threshold)
+ len = len + len_diff*strength/100;
+
+ if (len <= 0)
+ len = 1;
+
+
+ if ( (event.lenTick() != len) || (event.tick() + part->tick() != begin_tick) )
+ {
+ Event newEvent = event.clone();
+ newEvent.setTick(begin_tick - part->tick());
+ newEvent.setLenTick(len);
+ // Indicate no undo, and do not do port controller values and clone parts.
+ audio->msgChangeEvent(event, newEvent, part, false, false, false);
+ }
+ }
+
+ song->endUndo(SC_EVENT_MODIFIED);
+}
+
+
diff --git a/muse2/muse/functions.h b/muse2/muse/functions.h
new file mode 100644
index 00000000..a71230a4
--- /dev/null
+++ b/muse2/muse/functions.h
@@ -0,0 +1,40 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: functions.h,v 1.20.2.19 2011/05/05 20:10 flo93 Exp $
+// (C) Copyright 2011 Florian Jung (flo93@sourceforge.net)
+//=========================================================
+
+#ifndef __FUNCTIONS_H__
+#define __FUNCTIONS_H__
+
+#include "velocity.h"
+#include "quantize.h"
+#include "gatetime.h"
+
+#include <set>
+#include "part.h"
+
+
+extern GateTime* gatetime_dialog;
+extern Velocity* velocity_dialog;
+extern Quantize* quantize_dialog;
+
+void init_function_dialogs(QWidget* parent);
+
+
+std::set<Part*> partlist_to_set(PartList* pl);
+
+//these functions simply do their job, non-interactively
+void modify_velocity(const std::set<Part*>& parts, int range, int rate, int offset=0);
+void modify_notelen(const std::set<Part*>& parts, int range, int rate, int offset=0);
+void quantize_notes(const std::set<Part*>& parts, int range, int raster, int strength=100, int swing=0, int threshold=0);
+
+//the below functions automatically open the dialog
+//they return true if you click "ok" and false if "abort"
+bool modify_velocity(const std::set<Part*>& parts);
+bool modify_notelen(const std::set<Part*>& parts);
+bool quantize_notes(const std::set<Part*>& parts);
+
+
+#endif
diff --git a/muse2/muse/main.cpp b/muse2/muse/main.cpp
index 53f8961b..6481f4cb 100644
--- a/muse2/muse/main.cpp
+++ b/muse2/muse/main.cpp
@@ -27,6 +27,7 @@
#include "globals.h"
#include "icons.h"
#include "sync.h"
+#include "functions.h"
extern bool initDummyAudio();
extern void initIcons();
@@ -470,6 +471,9 @@ int main(int argc, char* argv[])
muse = new MusE(argc, &argv[optind]);
app.setMuse(muse);
muse->setWindowIcon(*museIcon);
+
+ init_function_dialogs(muse);
+
// Added by Tim. p3.3.22
if (!debugMode) {
diff --git a/muse2/muse/midiedit/CMakeLists.txt b/muse2/muse/midiedit/CMakeLists.txt
index 7e973aaa..a52d1844 100644
--- a/muse2/muse/midiedit/CMakeLists.txt
+++ b/muse2/muse/midiedit/CMakeLists.txt
@@ -35,7 +35,6 @@ QT4_WRAP_CPP ( midiedit_mocs
piano.h
pianoroll.h
prcanvas.h
- quantconfig.h
scoreedit.h
)
@@ -58,7 +57,6 @@ file (GLOB midiedit_source_files
piano.cpp
pianoroll.cpp
prcanvas.cpp
- quantconfig.cpp
scoreedit.cpp
)
diff --git a/muse2/muse/midiedit/dcanvas.cpp b/muse2/muse/midiedit/dcanvas.cpp
index 1303c189..9c50c8b2 100644
--- a/muse2/muse/midiedit/dcanvas.cpp
+++ b/muse2/muse/midiedit/dcanvas.cpp
@@ -31,7 +31,6 @@
#include "globals.h"
#include "midiport.h"
#include "audio.h"
-#include "velocity.h"
#include "shortcuts.h"
#include "icons.h"
@@ -608,7 +607,7 @@ void DrumCanvas::drawCanvas(QPainter& p, const QRect& rect)
//---------------------------------------------------------
// drawTopItem
//---------------------------------------------------------
-void DrumCanvas::drawTopItem(QPainter &p, const QRect &r)
+void DrumCanvas::drawTopItem(QPainter& p, const QRect&)
{
// draw cursor
if (_tool == CursorTool) {
@@ -819,52 +818,6 @@ void DrumCanvas::cmd(int cmd)
song->setPos(0, p, true, true, true); //CDW
}
break;
- case CMD_MODIFY_VELOCITY:
- {
- Velocity w;
- w.setRange(0); //TODO: Make this work! Probably put _to & _toInit in ecanvas instead
- 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) {
- DEvent* devent = (DEvent*)(k->second);
- Event event = devent->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);
- // Indicate no undo, and do not do port controller values and clone parts.
- //audio->msgChangeEvent(event, newEvent, devent->part(), false);
- audio->msgChangeEvent(event, newEvent, devent->part(), false, false, false);
- }
- }
- }
- song->endUndo(SC_EVENT_MODIFIED);
- }
- break;
}
updateSelection();
redraw();
diff --git a/muse2/muse/midiedit/drumedit.cpp b/muse2/muse/midiedit/drumedit.cpp
index ed3cd0e8..d9029969 100644
--- a/muse2/muse/midiedit/drumedit.cpp
+++ b/muse2/muse/midiedit/drumedit.cpp
@@ -43,6 +43,7 @@
#include "drummap.h"
#include "audio.h"
#include "gconfig.h"
+#include "functions.h"
/*
static const char* map_file_pattern[] = {
@@ -905,6 +906,9 @@ void DrumEdit::cmd(int cmd)
case DrumCanvas::CMD_RESET:
reset();
break;
+ case DrumCanvas::CMD_MODIFY_VELOCITY:
+ modify_velocity(partlist_to_set(parts()));
+ break;
default:
((DrumCanvas*)(canvas))->cmd(cmd);
break;
diff --git a/muse2/muse/midiedit/pianoroll.cpp b/muse2/muse/midiedit/pianoroll.cpp
index 2778d8b9..d008b35f 100644
--- a/muse2/muse/midiedit/pianoroll.cpp
+++ b/muse2/muse/midiedit/pianoroll.cpp
@@ -44,9 +44,10 @@
#include "gconfig.h"
#include "icons.h"
#include "audio.h"
+#include "functions.h"
+
#include "cmd.h"
-#include "quantconfig.h"
#include "shortcuts.h"
#include "mtrackinfo.h"
@@ -77,7 +78,6 @@ PianoRoll::PianoRoll(PartList* pl, QWidget* parent, const char* name, unsigned i
deltaMode = false;
resize(_widthInit, _heightInit);
selPart = 0;
- quantConfig = 0;
_playEvents = false;
_quantStrength = _quantStrengthInit;
_quantLimit = _quantLimitInit;
@@ -186,30 +186,11 @@ PianoRoll::PianoRoll(PartList* pl, QWidget* parent, const char* name, unsigned i
menuFunctions->setTearOffEnabled(true);
- funcOverQuantAction = menuFunctions->addAction(tr("Over Quantize"));
- mapper->setMapping(funcOverQuantAction, PianoCanvas::CMD_OVER_QUANTIZE);
- connect(funcOverQuantAction, SIGNAL(triggered()), mapper, SLOT(map()));
-
- funcNoteOnQuantAction = menuFunctions->addAction(tr("Note On Quantize"));
- mapper->setMapping(funcNoteOnQuantAction, PianoCanvas::CMD_ON_QUANTIZE);
- connect(funcNoteOnQuantAction, SIGNAL(triggered()), mapper, SLOT(map()));
-
- funcNoteOnOffQuantAction = menuFunctions->addAction(tr("Note On/Off Quantize"));
- mapper->setMapping(funcNoteOnOffQuantAction, PianoCanvas::CMD_ONOFF_QUANTIZE);
- connect(funcNoteOnOffQuantAction, SIGNAL(triggered()), mapper, SLOT(map()));
-
- funcIterQuantAction = menuFunctions->addAction(tr("Iterative Quantize"));
- mapper->setMapping(funcIterQuantAction, PianoCanvas::CMD_ITERATIVE_QUANTIZE);
- connect(funcIterQuantAction, SIGNAL(triggered()), mapper, SLOT(map()));
+ funcQuantizeAction = menuFunctions->addAction(tr("Quantize"));
+ mapper->setMapping(funcQuantizeAction, PianoCanvas::CMD_QUANTIZE);
+ connect(funcQuantizeAction, SIGNAL(triggered()), mapper, SLOT(map()));
- menuFunctions->addSeparator();
-
- funcConfigQuantAction = menuFunctions->addAction(tr("Config Quant..."));
- connect(funcConfigQuantAction, SIGNAL(triggered()), this, SLOT(configQuant()));
-
- menuFunctions->addSeparator();
-
- funcGateTimeAction = menuFunctions->addAction(tr("Modify Gate Time"));
+ funcGateTimeAction = menuFunctions->addAction(tr("Modify Note Length"));
mapper->setMapping(funcGateTimeAction, PianoCanvas::CMD_MODIFY_GATE_TIME);
connect(funcGateTimeAction, SIGNAL(triggered()), mapper, SLOT(map()));
@@ -655,7 +636,14 @@ PianoRoll::~PianoRoll()
void PianoRoll::cmd(int cmd)
{
- ((PianoCanvas*)canvas)->cmd(cmd, _quantStrength, _quantLimit, _quantLen, _to);
+ switch (cmd)
+ {
+ case PianoCanvas::CMD_MODIFY_GATE_TIME: modify_notelen(partlist_to_set(parts())); break;
+ case PianoCanvas::CMD_MODIFY_VELOCITY: modify_velocity(partlist_to_set(parts())); break;
+ case PianoCanvas::CMD_QUANTIZE: quantize_notes(partlist_to_set(parts())); break;
+
+ default: ((PianoCanvas*)canvas)->cmd(cmd);
+ }
}
//---------------------------------------------------------
@@ -1201,21 +1189,6 @@ void PianoRoll::keyPressEvent(QKeyEvent* event)
}
//---------------------------------------------------------
-// configQuant
-//---------------------------------------------------------
-
-void PianoRoll::configQuant()
- {
- if (!quantConfig) {
- quantConfig = new QuantConfig(_quantStrength, _quantLimit, _quantLen);
- connect(quantConfig, SIGNAL(setQuantStrength(int)), SLOT(setQuantStrength(int)));
- connect(quantConfig, SIGNAL(setQuantLimit(int)), SLOT(setQuantLimit(int)));
- connect(quantConfig, SIGNAL(setQuantLen(bool)), SLOT(setQuantLen(bool)));
- }
- quantConfig->show();
- }
-
-//---------------------------------------------------------
// setSteprec
//---------------------------------------------------------
@@ -1336,12 +1309,7 @@ void PianoRoll::initShortcuts()
//evColorPitchAction->setShortcut(shortcuts[ ].key);
//evColorVelAction->setShortcut(shortcuts[ ].key);
- funcOverQuantAction->setShortcut(shortcuts[SHRT_OVER_QUANTIZE].key);
- funcNoteOnQuantAction->setShortcut(shortcuts[SHRT_ON_QUANTIZE].key);
- funcNoteOnOffQuantAction->setShortcut(shortcuts[SHRT_ONOFF_QUANTIZE].key);
- funcIterQuantAction->setShortcut(shortcuts[SHRT_ITERATIVE_QUANTIZE].key);
-
- funcConfigQuantAction->setShortcut(shortcuts[SHRT_CONFIG_QUANT].key);
+ funcQuantizeAction->setShortcut(shortcuts[SHRT_OVER_QUANTIZE].key); //FINDMICH TODO FLO
funcGateTimeAction->setShortcut(shortcuts[SHRT_MODIFY_GATE_TIME].key);
funcModVelAction->setShortcut(shortcuts[SHRT_MODIFY_VELOCITY].key);
diff --git a/muse2/muse/midiedit/pianoroll.h b/muse2/muse/midiedit/pianoroll.h
index 2bfa9324..87bf52b6 100644
--- a/muse2/muse/midiedit/pianoroll.h
+++ b/muse2/muse/midiedit/pianoroll.h
@@ -35,7 +35,6 @@ class Splitter;
class PartList;
class Toolbar1;
class Xml;
-class QuantConfig;
class ScrollScale;
class Part;
class SNode;
@@ -81,11 +80,7 @@ class PianoRoll : public MidiEditor {
QAction* evColorPitchAction;
QAction* evColorVelAction;
- QAction* funcOverQuantAction;
- QAction* funcNoteOnQuantAction;
- QAction* funcNoteOnOffQuantAction;
- QAction* funcIterQuantAction;
- QAction* funcConfigQuantAction;
+ QAction* funcQuantizeAction;
QAction* funcGateTimeAction;
QAction* funcModVelAction;
QAction* funcCrescendoAction;
@@ -137,7 +132,6 @@ class PianoRoll : public MidiEditor {
int _quantLimit;
int _to;
bool _quantLen;
- QuantConfig* quantConfig;
bool _playEvents;
//QScrollBar* infoScroll;
@@ -160,7 +154,6 @@ class PianoRoll : public MidiEditor {
//void trackInfoScroll(int);
void setRaster(int);
void setQuant(int);
- void configQuant();
void setQuantStrength(int val) { _quantStrength = val; }
void setQuantLimit(int val) { _quantLimit = val; }
void setQuantLen(bool val) { _quantLen = val; }
diff --git a/muse2/muse/midiedit/prcanvas.cpp b/muse2/muse/midiedit/prcanvas.cpp
index a0ffdcaf..2966cf71 100644
--- a/muse2/muse/midiedit/prcanvas.cpp
+++ b/muse2/muse/midiedit/prcanvas.cpp
@@ -32,8 +32,6 @@
#include "mpevent.h"
#include "globals.h"
#include "cmd.h"
-#include "gatetime.h"
-#include "velocity.h"
#include "song.h"
#include "audio.h"
@@ -82,7 +80,6 @@ PianoCanvas::PianoCanvas(MidiEditor* pr, QWidget* parent, int sx, int sy)
: EventCanvas(pr, parent, sx, sy)
{
colorMode = 0;
- cmdRange = 0; // all Events
playedPitch = -1;
songChanged(SC_TRACK_INSERTED);
@@ -907,10 +904,8 @@ void PianoCanvas::drawCanvas(QPainter& p, const QRect& rect)
// pulldown menu commands
//---------------------------------------------------------
-void PianoCanvas::cmd(int cmd, int quantStrength,
- int quantLimit, bool quantLen, int range)
+void PianoCanvas::cmd(int cmd)
{
- cmdRange = range;
switch (cmd) {
case CMD_CUT:
copy();
@@ -946,18 +941,7 @@ void PianoCanvas::cmd(int cmd, int quantStrength,
song->endUndo(SC_EVENT_REMOVED);
}
return;
- case CMD_OVER_QUANTIZE: // over quantize
- quantize(100, 1, quantLen);
- break;
- case CMD_ON_QUANTIZE: // note on quantize
- quantize(50, 1, false);
- break;
- case CMD_ONOFF_QUANTIZE: // note on/off quantize
- quantize(50, 1, true);
- break;
- case CMD_ITERATIVE_QUANTIZE: // Iterative Quantize
- quantize(quantStrength, quantLimit, quantLen);
- break;
+
case CMD_SELECT_ALL: // select all
for (iCItem k = items.begin(); k != items.end(); ++k) {
if (!k->second->isSelected())
@@ -1032,96 +1016,6 @@ void PianoCanvas::cmd(int cmd, int quantStrength,
editor->setCurCanvasPart(newpt);
}
break;
- case CMD_MODIFY_GATE_TIME:
- {
- GateTime w(this);
- w.setRange(range);
- 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) {
- NEvent* nevent =(NEvent*)(k->second);
- Event event = nevent->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 int len = event.lenTick(); //prevent compiler warning: comparison singed/unsigned
-
- len = rate ? (len * 100) / rate : 1;
- len += offset;
- if (len < 1)
- len = 1;
-
- if (event.lenTick() != len) {
- Event newEvent = event.clone();
- newEvent.setLenTick(len);
- // Indicate no undo, and do not do port controller values and clone parts.
- //audio->msgChangeEvent(event, newEvent, nevent->part(), false);
- audio->msgChangeEvent(event, newEvent, nevent->part(), false, false, false);
- }
- }
- }
- song->endUndo(SC_EVENT_MODIFIED);
- }
- break;
-
- case CMD_MODIFY_VELOCITY:
- {
- Velocity w;
- w.setRange(range);
- 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) {
- NEvent* nevent = (NEvent*)(k->second);
- Event event = nevent->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);
- // Indicate no undo, and do not do port controller values and clone parts.
- //audio->msgChangeEvent(event, newEvent, nevent->part(), false);
- audio->msgChangeEvent(event, newEvent, nevent->part(), false, false, false);
- }
- }
- }
- song->endUndo(SC_EVENT_MODIFIED);
- }
- break;
case CMD_FIXED_LEN: //Set notes to the length specified in the drummap
if (!selectionSize())
@@ -1231,55 +1125,6 @@ void PianoCanvas::cmd(int cmd, int quantStrength,
}
//---------------------------------------------------------
-// quantize
-//---------------------------------------------------------
-
-void PianoCanvas::quantize(int strength, int limit, bool quantLen)
- {
- song->startUndo();
- for (iCItem k = items.begin(); k != items.end(); ++k) {
- NEvent* nevent = (NEvent*)(k->second);
- Event event = nevent->event();
- Part* part = nevent->part();
- if (event.type() != Note)
- continue;
-
- if ((cmdRange & CMD_RANGE_SELECTED) && !k->second->isSelected())
- continue;
-
- unsigned tick = event.tick() + part->tick();
-
- if ((cmdRange & CMD_RANGE_LOOP)
- && ((tick < song->lpos() || tick >= song->rpos())))
- continue;
-
- unsigned int len = event.lenTick(); //prevent compiler warning: comparison singed/unsigned
- int tick2 = tick + len;
-
- // quant start position
- int diff = AL::sigmap.raster(tick, editor->quant()) - tick;
- if (abs(diff) > limit)
- tick += ((diff * strength) / 100);
-
- // quant len
- diff = AL::sigmap.raster(tick2, editor->quant()) - tick2;
- if (quantLen && (abs(diff) > limit))
- len += ((diff * strength) / 100);
-
- // something changed?
- if (((event.tick() + part->tick()) != tick) || (event.lenTick() != len)) {
- Event newEvent = event.clone();
- newEvent.setTick(tick - part->tick());
- newEvent.setLenTick(len);
- // Indicate no undo, and do not do port controller values and clone parts.
- //audio->msgChangeEvent(event, newEvent, part, false);
- audio->msgChangeEvent(event, newEvent, part, false, false, false);
- }
- }
- song->endUndo(SC_EVENT_MODIFIED);
- }
-
-//---------------------------------------------------------
// midiNote
//---------------------------------------------------------
diff --git a/muse2/muse/midiedit/prcanvas.h b/muse2/muse/midiedit/prcanvas.h
index bda22fc3..39506a13 100644
--- a/muse2/muse/midiedit/prcanvas.h
+++ b/muse2/muse/midiedit/prcanvas.h
@@ -37,7 +37,6 @@ class QRect;
//---------------------------------------------------------
class PianoCanvas : public EventCanvas {
- int cmdRange;
int colorMode;
int playedPitch;
@@ -63,7 +62,6 @@ class PianoCanvas : public EventCanvas {
int y2pitch(int) const;
int pitch2y(int) const;
virtual void drawCanvas(QPainter&, const QRect&);
- void quantize(int, int, bool);
void copy();
void paste();
virtual void itemPressed(const CItem*);
@@ -88,8 +86,7 @@ class PianoCanvas : public EventCanvas {
public:
enum {
CMD_CUT, CMD_COPY, CMD_PASTE, CMD_DEL,
- CMD_OVER_QUANTIZE, CMD_ON_QUANTIZE, CMD_ONOFF_QUANTIZE,
- CMD_ITERATIVE_QUANTIZE,
+ CMD_QUANTIZE,
CMD_SELECT_ALL, CMD_SELECT_NONE, CMD_SELECT_INVERT,
CMD_SELECT_ILOOP, CMD_SELECT_OLOOP, CMD_SELECT_PREV_PART, CMD_SELECT_NEXT_PART,
CMD_MODIFY_GATE_TIME, CMD_MODIFY_VELOCITY,
@@ -100,7 +97,7 @@ class PianoCanvas : public EventCanvas {
};
PianoCanvas(MidiEditor*, QWidget*, int, int);
- void cmd(int, int, int, bool, int);
+ void cmd(int cmd);
void setColorMode(int mode) {
colorMode = mode;
redraw();
diff --git a/muse2/muse/midiedit/quantconfig.cpp b/muse2/muse/midiedit/quantconfig.cpp
deleted file mode 100644
index 2f413e6a..00000000
--- a/muse2/muse/midiedit/quantconfig.cpp
+++ /dev/null
@@ -1,79 +0,0 @@
-//=========================================================
-// MusE
-// Linux Music Editor
-// $Id: quantconfig.cpp,v 1.2 2004/04/24 14:58:52 wschweer Exp $
-//
-// (C) Copyright 1999/2003 Werner Schweer (ws@seh.de)
-//=========================================================
-
-#include <QCheckBox>
-#include <QGroupBox>
-#include <QLabel>
-#include <QSpinBox>
-#include <QVBoxLayout>
-
-#include "quantconfig.h"
-
-const char* wtStrengthTxt = QT_TRANSLATE_NOOP("@default", "sets amount of quantization:\n"
- "0 - no quantization\n"
- "100 - full quantization");
-const char* wtQLimitTxt = QT_TRANSLATE_NOOP("@default", "don't quantize notes above this tick limit");
-const char* wtQLenTxt = QT_TRANSLATE_NOOP("@default", "quantize also note len as default");
-
-//---------------------------------------------------------
-// QuantConfig
-//---------------------------------------------------------
-
-QuantConfig::QuantConfig(int s, int l, bool lenFlag)
- : QDialog()
- {
- setWindowTitle(tr("MusE: Config Quantize"));
- QVBoxLayout *mainlayout = new QVBoxLayout;
-
- QGridLayout* layout = new QGridLayout;
- QGroupBox* gb = new QGroupBox(tr("Config Quantize"));
-
- QLabel* l1 = new QLabel(tr("Strength"));
- layout->addWidget(l1, 0, 0);
- QSpinBox* sb1 = new QSpinBox;
- sb1->setMinimum(0);
- sb1->setMaximum(100);
- sb1->setSingleStep(1);
- sb1->setSuffix(QString("%"));
- sb1->setValue(s);
- layout->addWidget(sb1, 0, 1);
-
- QLabel* l2 = new QLabel(tr("Donīt Quantize"));
- layout->addWidget(l2, 1, 0);
- QSpinBox* sb2 = new QSpinBox;
- sb2->setMinimum(0);
- sb2->setMaximum(500);
- sb2->setSingleStep(1);
- sb2->setValue(l);
- layout->addWidget(sb2, 1, 1);
-
- QLabel* l3 = new QLabel(tr("Quant Len"));
- layout->addWidget(l3, 2, 0);
- QCheckBox* but = new QCheckBox;
- but->setChecked(lenFlag);
- layout->addWidget(but, 2, 1);
-
- connect(sb1, SIGNAL(valueChanged(int)), SIGNAL(setQuantStrength(int)));
- connect(sb2, SIGNAL(valueChanged(int)), SIGNAL(setQuantLimit(int)));
- connect(but, SIGNAL(toggled(bool)), SIGNAL(setQuantLen(bool)));
-
- gb->setLayout(layout);
- mainlayout->addWidget(gb);
- setLayout(mainlayout);
-
- l1->setWhatsThis(tr(wtStrengthTxt));
- l1->setToolTip(tr(wtStrengthTxt));
- sb1->setWhatsThis(tr(wtStrengthTxt));
- l2->setWhatsThis(tr(wtQLimitTxt));
- l2->setToolTip(tr(wtQLimitTxt));
- sb2->setWhatsThis(tr(wtQLimitTxt));
- l3->setWhatsThis(tr(wtQLenTxt));
- l3->setToolTip(tr(wtQLenTxt));
- but->setWhatsThis(tr(wtQLenTxt));
- }
-
diff --git a/muse2/muse/midiedit/quantconfig.h b/muse2/muse/midiedit/quantconfig.h
deleted file mode 100644
index 4466cdf0..00000000
--- a/muse2/muse/midiedit/quantconfig.h
+++ /dev/null
@@ -1,32 +0,0 @@
-//=========================================================
-// MusE
-// Linux Music Editor
-// $Id: quantconfig.h,v 1.1.1.1 2003/10/27 18:52:23 wschweer Exp $
-//
-// (C) Copyright 1999/2000 Werner Schweer (ws@seh.de)
-//=========================================================
-
-#ifndef __QCONFIG_H__
-#define __QCONFIG_H__
-
-#include <QDialog>
-
-//---------------------------------------------------------
-// QuantConfig
-//---------------------------------------------------------
-
-class QuantConfig : public QDialog {
- Q_OBJECT
-
- signals:
- void setQuantStrength(int);
- void setQuantLimit(int);
- void setQuantLen(bool);
-
- public:
- QuantConfig(int, int, bool);
- };
-
-
-#endif
-
diff --git a/muse2/muse/midiedit/scoreedit.cpp b/muse2/muse/midiedit/scoreedit.cpp
index 31f0f325..cb37c382 100644
--- a/muse2/muse/midiedit/scoreedit.cpp
+++ b/muse2/muse/midiedit/scoreedit.cpp
@@ -43,25 +43,20 @@ using namespace std;
#include "mtscale.h"
#include "prcanvas.h"
#include "scoreedit.h"
-#include "scrollscale.h"
-#include "piano.h"
-#include "../ctrl/ctrledit.h"
-#include "splitter.h"
#include "ttoolbar.h"
#include "tb1.h"
-#include "utils.h"
#include "globals.h"
#include "gconfig.h"
#include "icons.h"
#include "audio.h"
+#include "functions.h"
#include "cmd.h"
-#include "quantconfig.h"
-#include "shortcuts.h"
-
-#include "mtrackinfo.h"
-
#include "sig.h"
+#include "song.h"
+
+//#include "../ctrl/ctrledit.h"
+//#include "shortcuts.h"
string IntToStr(int i);
@@ -331,9 +326,15 @@ ScoreEdit::ScoreEdit(QWidget* parent, const char* name, unsigned initPos)
QAction* set_name_action = settings_menu->addAction(tr("Set Score &name"), menu_mapper, SLOT(map()));
menu_mapper->setMapping(set_name_action, CMD_SET_NAME);
-
-
+ QMenu* functions_menu = menuBar()->addMenu(tr("&Functions"));
+
+ QAction* func_quantize_action = functions_menu->addAction(tr("&Quantize"), menu_mapper, SLOT(map()));
+ QAction* func_notelen_action = functions_menu->addAction(tr("Change note &length"), menu_mapper, SLOT(map()));
+ QAction* func_velocity_action = functions_menu->addAction(tr("Change note &velocity"), menu_mapper, SLOT(map()));
+ menu_mapper->setMapping(func_quantize_action, CMD_QUANTIZE);
+ menu_mapper->setMapping(func_notelen_action, CMD_NOTELEN);
+ menu_mapper->setMapping(func_velocity_action, CMD_VELOCITY);
score_canvas->song_changed(SC_EVENT_INSERTED);
@@ -474,6 +475,10 @@ void ScoreEdit::menu_command(int cmd)
}
break;
+ case CMD_QUANTIZE: quantize_notes(score_canvas->get_all_parts()); break;
+ case CMD_VELOCITY: modify_velocity(score_canvas->get_all_parts()); break;
+ case CMD_NOTELEN: modify_notelen(score_canvas->get_all_parts()); break;
+
default:
score_canvas->menu_command(cmd);
}
@@ -1097,6 +1102,15 @@ void ScoreCanvas::move_staff_below(list<staff_t>::iterator dest, list<staff_t>::
move_staff_above(dest, src);
}
+set<Part*> ScoreCanvas::get_all_parts()
+{
+ set<Part*> result;
+
+ for (list<staff_t>::iterator it=staves.begin(); it!=staves.end(); it++)
+ result.insert(it->parts.begin(), it->parts.end());
+
+ return result;
+}
void ScoreCanvas::song_changed(int flags)
{
@@ -3913,16 +3927,19 @@ set<Part*> staff_t::parts_at_tick(unsigned tick)
/* BUGS and potential bugs
+ * o the proper quantize functions must be used! yes, really!
* o when the keymap is not used, this will probably lead to a bug
* same when mastertrack is disabled
* o tied notes don't work properly when there's a key-change in
* between, for example, when a cis is tied to a des
*
* CURRENT TODO
- * o offer functions like in the pianoroll: quantize etc.
* o support selections
* o let the user select the distance between staves, or do this
* automatically?
+ * o update translations
+ * o remove ambiguous translation: "offset"="zeitversatz"
+ * this is ambigous in mod. note len and WRONG in mod. velo dialogs
*
* IMPORTANT TODO
* o add a select-clef-toolbox for tracks
diff --git a/muse2/muse/midiedit/scoreedit.h b/muse2/muse/midiedit/scoreedit.h
index 111a4f47..ed242aae 100644
--- a/muse2/muse/midiedit/scoreedit.h
+++ b/muse2/muse/midiedit/scoreedit.h
@@ -20,12 +20,13 @@
#include <QSignalMapper>
#include <QAction>
#include <QActionGroup>
+#include <QGridLayout>
#include <values.h>
#include "noteinfo.h"
#include "cobject.h"
-#include "midieditor.h"
-#include "tools.h"
+//#include "midieditor.h"
+//#include "tools.h"
#include "event.h"
#include "view.h"
#include "gconfig.h"
@@ -55,9 +56,12 @@ using std::string;
enum {CMD_COLOR_BLACK, CMD_COLOR_VELO, CMD_COLOR_PART,
CMD_SET_NAME,
CMD_NOTELEN_1, CMD_NOTELEN_2, CMD_NOTELEN_4, CMD_NOTELEN_8,
- CMD_NOTELEN_16, CMD_NOTELEN_32, CMD_NOTELEN_LAST };
+ CMD_NOTELEN_16, CMD_NOTELEN_32, CMD_NOTELEN_LAST,
+
+ CMD_QUANTIZE, CMD_VELOCITY, CMD_NOTELEN };
class ScoreCanvas;
+class EditToolBar;
//---------------------------------------------------------
// ScoreEdit
@@ -725,6 +729,8 @@ class ScoreCanvas : public View
Part* get_selected_part() {return selected_part;}
void set_selected_part(Part* p) {selected_part=p;}
+ set<Part*> get_all_parts();
+
void write_staves(int level, Xml& xml) const;
};
diff --git a/muse2/muse/widgets/CMakeLists.txt b/muse2/muse/widgets/CMakeLists.txt
index 261c27a2..ee4af793 100644
--- a/muse2/muse/widgets/CMakeLists.txt
+++ b/muse2/muse/widgets/CMakeLists.txt
@@ -76,6 +76,7 @@ QT4_WRAP_CPP (widget_mocs
# ttoolbar.h
ttoolbutton.h
velocity.h
+ quantize.h
verticalmeter.h
view.h
vscale.h
@@ -111,6 +112,7 @@ file (GLOB widgets_ui_files
transformbase.ui
transposebase.ui
velocitybase.ui
+ quantbase.ui
)
QT4_WRAP_UI (widget_ui_headers ${widgets_ui_files})
@@ -177,6 +179,7 @@ file (GLOB widgets_source_files
ttoolbutton.cpp
utils.cpp
velocity.cpp
+ quantize.cpp
verticalmeter.cpp
view.cpp
vscale.cpp
diff --git a/muse2/muse/widgets/gatetime.cpp b/muse2/muse/widgets/gatetime.cpp
index f1804c35..c64411a0 100644
--- a/muse2/muse/widgets/gatetime.cpp
+++ b/muse2/muse/widgets/gatetime.cpp
@@ -26,6 +26,8 @@ GateTime::GateTime(QWidget* parent)
rangeGroup->addButton(loopButton, 2);
rangeGroup->addButton(sloopButton, 3);
rangeGroup->setExclusive(true);
+
+ pullValues();
}
//---------------------------------------------------------
@@ -34,18 +36,30 @@ GateTime::GateTime(QWidget* parent)
void GateTime::accept()
{
- _range = rangeGroup->checkedId();
- _rateVal = rate->value();
- _offsetVal = offset->value();
+ pullValues();
QDialog::accept();
}
//---------------------------------------------------------
-// setRange
+// pullValues
//---------------------------------------------------------
-void GateTime::setRange(int id)
+void GateTime::pullValues()
{
- rangeGroup->button(id)->setChecked(true);
+ range = rangeGroup->checkedId();
+ rateVal = rate->value();
+ offsetVal = offset->value();
}
+//---------------------------------------------------------
+// exec
+//---------------------------------------------------------
+
+int GateTime::exec()
+ {
+ rangeGroup->button(range)->setChecked(true);
+ rate->setValue(rateVal);
+ offset->setValue(offsetVal);
+
+ return QDialog::exec();
+ }
diff --git a/muse2/muse/widgets/gatetime.h b/muse2/muse/widgets/gatetime.h
index dcb1827c..5585d6ad 100644
--- a/muse2/muse/widgets/gatetime.h
+++ b/muse2/muse/widgets/gatetime.h
@@ -18,22 +18,24 @@ class QDialog;
//---------------------------------------------------------
class GateTime : public QDialog, public Ui::GateTimeBase {
+ private:
Q_OBJECT
- int _range;
- int _rateVal;
- int _offsetVal;
QButtonGroup *rangeGroup;
protected slots:
void accept();
+ void pullValues();
public:
GateTime(QWidget* parent=0);
- void setRange(int id);
- int range() const { return _range; }
- int rateVal() const { return _rateVal; }
- int offsetVal() const { return _offsetVal; }
+
+ int range;
+ int rateVal;
+ int offsetVal;
+
+ public slots:
+ int exec();
};
#endif
diff --git a/muse2/muse/widgets/gatetimebase.ui b/muse2/muse/widgets/gatetimebase.ui
index babf5f02..e804de17 100644
--- a/muse2/muse/widgets/gatetimebase.ui
+++ b/muse2/muse/widgets/gatetimebase.ui
@@ -11,7 +11,7 @@
</rect>
</property>
<property name="windowTitle">
- <string>MusE: Modify Gate Time</string>
+ <string>MusE: Modify Note Length</string>
</property>
<layout class="QVBoxLayout">
<property name="spacing">
@@ -59,7 +59,7 @@
<item>
<widget class="QRadioButton" name="sloopButton">
<property name="text">
- <string>Selected &amp; Looped</string>
+ <string>Selected Looped</string>
</property>
</widget>
</item>
@@ -104,7 +104,7 @@
<string>%</string>
</property>
<property name="maximum">
- <number>200</number>
+ <number>1000</number>
</property>
<property name="value">
<number>100</number>
@@ -124,6 +124,13 @@
</property>
</widget>
</item>
+ <item row="2" column="0" colspan="2">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>lenNew = (lenOld * rate) + offset</string>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
</item>
diff --git a/muse2/muse/widgets/quantbase.ui b/muse2/muse/widgets/quantbase.ui
new file mode 100644
index 00000000..6a88c86f
--- /dev/null
+++ b/muse2/muse/widgets/quantbase.ui
@@ -0,0 +1,308 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>QuantBase</class>
+ <widget class="QDialog" name="QuantBase">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>279</width>
+ <height>486</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>MusE: Quantize</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <item>
+ <widget class="QGroupBox" name="rangeBox">
+ <property name="title">
+ <string>Range</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <item>
+ <widget class="QRadioButton" name="all_events_button">
+ <property name="text">
+ <string>All Events</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="selected_events_button">
+ <property name="text">
+ <string>Selected Events</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="looped_events_button">
+ <property name="text">
+ <string>Looped Events</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="selected_looped_button">
+ <property name="text">
+ <string>Selected Looped</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="groupBox_2">
+ <property name="title">
+ <string>Values</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout">
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <item row="1" column="0">
+ <widget class="QLabel" name="TextLabel3">
+ <property name="text">
+ <string>Strength:</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QSpinBox" name="strength_spinbox">
+ <property name="suffix">
+ <string>%</string>
+ </property>
+ <property name="maximum">
+ <number>100</number>
+ </property>
+ <property name="value">
+ <number>80</number>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="TextLabel4">
+ <property name="text">
+ <string>Threshold (ticks):</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QSpinBox" name="threshold_spinbox">
+ <property name="minimum">
+ <number>0</number>
+ </property>
+ <property name="maximum">
+ <number>10000</number>
+ </property>
+ <property name="singleStep">
+ <number>1</number>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="0">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Quantize Len</string>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="1">
+ <widget class="QCheckBox" name="len_checkbox">
+ <property name="text">
+ <string/>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0">
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>Raster</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QComboBox" name="raster_combobox">
+ <property name="editable">
+ <bool>false</bool>
+ </property>
+ <property name="currentIndex">
+ <number>3</number>
+ </property>
+ <property name="frame">
+ <bool>true</bool>
+ </property>
+ <item>
+ <property name="text">
+ <string>Whole</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Half</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Quarter</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>8th</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>16th</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>32th</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item row="3" column="0">
+ <widget class="QLabel" name="label_3">
+ <property name="text">
+ <string>Swing:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1">
+ <widget class="QSpinBox" name="swing_spinbox">
+ <property name="minimum">
+ <number>-99</number>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="0" colspan="2">
+ <widget class="QLabel" name="label_4">
+ <property name="text">
+ <string>If the proposed change in tick or length is smaller than threshold, nothing is done.
+If swing=0, this is normal
+If swing is 33, you get a 2:1-rhythm.
+If swing is -33, you get a 1:2-rhythm.</string>
+ </property>
+ <property name="wordWrap">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <item>
+ <spacer name="Spacer1">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="ok_button">
+ <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="cancel_button">
+ <property name="text">
+ <string>Cancel</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <layoutdefault spacing="6" margin="11"/>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>ok_button</sender>
+ <signal>clicked()</signal>
+ <receiver>QuantBase</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>cancel_button</sender>
+ <signal>clicked()</signal>
+ <receiver>QuantBase</receiver>
+ <slot>reject()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
diff --git a/muse2/muse/widgets/quantize.cpp b/muse2/muse/widgets/quantize.cpp
new file mode 100644
index 00000000..734f3d5d
--- /dev/null
+++ b/muse2/muse/widgets/quantize.cpp
@@ -0,0 +1,54 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: quantize.cpp,v 1.1.1.1 2011/05/05 18:51:04 flo93 Exp $
+// (C) Copyright 2011 Florian Jung (flo93@sourceforge.net)
+//=========================================================
+
+#include <QButtonGroup>
+#include "quantize.h"
+
+
+Quantize::Quantize(QWidget* parent)
+ : QDialog(parent)
+{
+ setupUi(this);
+ range_group = new QButtonGroup;
+ range_group->addButton(all_events_button,0);
+ range_group->addButton(selected_events_button,1);
+ range_group->addButton(looped_events_button,2);
+ range_group->addButton(selected_looped_button,3);
+
+ pull_values();
+}
+
+void Quantize::pull_values()
+{
+ range = range_group->checkedId();
+ strength = strength_spinbox->value();
+ threshold = threshold_spinbox->value();
+ raster_power2 = raster_combobox->currentIndex();
+ quant_len = len_checkbox->isChecked();
+ swing = swing_spinbox->value();
+}
+
+void Quantize::accept()
+{
+ pull_values();
+ QDialog::accept();
+}
+
+int Quantize::exec()
+{
+ if ((range < 0) || (range > 3)) range=0;
+
+ range_group->button(range)->setChecked(true);
+ strength_spinbox->setValue(strength);
+ threshold_spinbox->setValue(threshold);
+ raster_combobox->setCurrentIndex(raster_power2);
+ len_checkbox->setChecked(quant_len);
+ swing_spinbox->setValue(swing);
+
+ return QDialog::exec();
+}
+
diff --git a/muse2/muse/widgets/quantize.h b/muse2/muse/widgets/quantize.h
new file mode 100644
index 00000000..3f54bc09
--- /dev/null
+++ b/muse2/muse/widgets/quantize.h
@@ -0,0 +1,40 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: quantize.h,v 1.1.1.1 2011/05/05 18:51:04 flo93 Exp $
+// (C) Copyright 2011 Florian Jung (flo93@sourceforge.net)
+//=========================================================
+
+#ifndef __QUANTIZE_H__
+#define __QUANTIZE_H__
+
+#include "ui_quantbase.h"
+
+class QButtonGroup;
+
+class Quantize : public QDialog, public Ui::QuantBase
+{
+ private:
+ Q_OBJECT
+ QButtonGroup* range_group;
+
+ protected slots:
+ void accept();
+ void pull_values();
+
+ public:
+ Quantize(QWidget* parent = 0);
+
+ int range;
+ int strength;
+ int threshold;
+ int raster_power2;
+ int swing;
+ bool quant_len;
+
+ public slots:
+ int exec();
+};
+
+#endif
+
diff --git a/muse2/muse/widgets/velocity.cpp b/muse2/muse/widgets/velocity.cpp
index 309beb4d..ad9bbfe4 100644
--- a/muse2/muse/widgets/velocity.cpp
+++ b/muse2/muse/widgets/velocity.cpp
@@ -12,7 +12,7 @@
// Velocity
//---------------------------------------------------------
-Velocity::Velocity(QDialog* parent)
+Velocity::Velocity(QWidget* parent)
: QDialog(parent)
{
setupUi(this);
@@ -21,6 +21,8 @@ Velocity::Velocity(QDialog* parent)
rangeGroup->addButton(selectedEvents,1);
rangeGroup->addButton(loopedEvents,2);
rangeGroup->addButton(selectedLooped,3);
+
+ pullValues();
}
//---------------------------------------------------------
@@ -29,18 +31,30 @@ Velocity::Velocity(QDialog* parent)
void Velocity::accept()
{
- _range = rangeGroup->checkedId();
- _rateVal = rate->value();
- _offsetVal = offset->value();
+ pullValues();
QDialog::accept();
}
//---------------------------------------------------------
-// setRange
+// pullValues
//---------------------------------------------------------
-void Velocity::setRange(int id)
+void Velocity::pullValues()
{
- rangeGroup->button(id)->setChecked(true);
+ range = rangeGroup->checkedId();
+ rateVal = rate->value();
+ offsetVal = offset->value();
}
+//---------------------------------------------------------
+// exec
+//---------------------------------------------------------
+
+int Velocity::exec()
+ {
+ rangeGroup->button(range)->setChecked(true);
+ rate->setValue(rateVal);
+ offset->setValue(offsetVal);
+
+ return QDialog::exec();
+ }
diff --git a/muse2/muse/widgets/velocity.h b/muse2/muse/widgets/velocity.h
index cf5b2779..448b3e5b 100644
--- a/muse2/muse/widgets/velocity.h
+++ b/muse2/muse/widgets/velocity.h
@@ -17,22 +17,23 @@ class QButtonGroup;
//---------------------------------------------------------
class Velocity : public QDialog, public Ui::VelocityBase {
- int _range;
- int _rateVal;
- int _offsetVal;
-
+ private:
Q_OBJECT
QButtonGroup* rangeGroup;
protected slots:
void accept();
+ void pullValues();
public:
- Velocity(QDialog* parent = 0);
- void setRange(int id);
- int range() const { return _range; }
- int rateVal() const { return _rateVal; }
- int offsetVal() const { return _offsetVal; }
+ Velocity(QWidget* parent = 0);
+
+ int range;
+ int rateVal;
+ int offsetVal;
+
+ public slots:
+ int exec();
};
#endif
diff --git a/muse2/muse/widgets/velocitybase.ui b/muse2/muse/widgets/velocitybase.ui
index 1e386e11..40fe625f 100644
--- a/muse2/muse/widgets/velocitybase.ui
+++ b/muse2/muse/widgets/velocitybase.ui
@@ -59,7 +59,7 @@
<item>
<widget class="QRadioButton" name="selectedLooped">
<property name="text">
- <string>Selected &amp; Looped</string>
+ <string>Selected Looped</string>
</property>
</widget>
</item>
@@ -114,7 +114,7 @@
<item row="1" column="1">
<widget class="QSpinBox" name="offset">
<property name="minimum">
- <number>1</number>
+ <number>-127</number>
</property>
<property name="maximum">
<number>127</number>
@@ -122,6 +122,16 @@
<property name="singleStep">
<number>1</number>
</property>
+ <property name="value">
+ <number>0</number>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0" colspan="2">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>veloNew = (veloOld * rate) + offset</string>
+ </property>
</widget>
</item>
</layout>