summaryrefslogtreecommitdiff
path: root/muse2
diff options
context:
space:
mode:
Diffstat (limited to 'muse2')
-rw-r--r--muse2/muse/arranger/arrangerview.cpp37
-rw-r--r--muse2/muse/arranger/arrangerview.h15
-rw-r--r--muse2/muse/functions.cpp207
-rw-r--r--muse2/muse/functions.h17
4 files changed, 275 insertions, 1 deletions
diff --git a/muse2/muse/arranger/arrangerview.cpp b/muse2/muse/arranger/arrangerview.cpp
index c19280bd..fd8165cf 100644
--- a/muse2/muse/arranger/arrangerview.cpp
+++ b/muse2/muse/arranger/arrangerview.cpp
@@ -486,7 +486,33 @@ ArrangerView::ArrangerView(QWidget* parent)
menuStructure->addAction(strCopyRangeAction);
menuStructure->addSeparator();
menuStructure->addAction(strCutEventsAction);
+
+
+
+ QMenu* functions_menu = menuBar()->addMenu(tr("Functions"));
+ QAction* func_quantize_action = functions_menu->addAction(tr("&Quantize Notes"), editSignalMapper, SLOT(map()));
+ QAction* func_notelen_action = functions_menu->addAction(tr("Change note &length"), editSignalMapper, SLOT(map()));
+ QAction* func_velocity_action = functions_menu->addAction(tr("Change note &velocity"), editSignalMapper, SLOT(map()));
+ QAction* func_cresc_action = functions_menu->addAction(tr("Crescendo/Decrescendo"), editSignalMapper, SLOT(map()));
+ QAction* func_transpose_action = functions_menu->addAction(tr("Transpose"), editSignalMapper, SLOT(map()));
+ QAction* func_erase_action = functions_menu->addAction(tr("Erase Events (Not Parts)"), editSignalMapper, SLOT(map()));
+ QAction* func_move_action = functions_menu->addAction(tr("Move Events (Not Parts)"), editSignalMapper, SLOT(map()));
+ QAction* func_fixed_len_action = functions_menu->addAction(tr("Set Fixed Note Length"), editSignalMapper, SLOT(map()));
+ QAction* func_del_overlaps_action = functions_menu->addAction(tr("Delete Overlapping Notes"), editSignalMapper, SLOT(map()));
+ QAction* func_legato_action = functions_menu->addAction(tr("Legato"), editSignalMapper, SLOT(map()));
+ editSignalMapper->setMapping(func_quantize_action, CMD_QUANTIZE);
+ editSignalMapper->setMapping(func_notelen_action, CMD_NOTELEN);
+ editSignalMapper->setMapping(func_velocity_action, CMD_VELOCITY);
+ editSignalMapper->setMapping(func_cresc_action, CMD_CRESCENDO);
+ editSignalMapper->setMapping(func_transpose_action, CMD_TRANSPOSE);
+ editSignalMapper->setMapping(func_erase_action, CMD_ERASE);
+ editSignalMapper->setMapping(func_move_action, CMD_MOVE);
+ editSignalMapper->setMapping(func_fixed_len_action, CMD_FIXED_LEN);
+ editSignalMapper->setMapping(func_del_overlaps_action, CMD_DELETE_OVERLAPS);
+ editSignalMapper->setMapping(func_legato_action, CMD_LEGATO);
+
+
QMenu* menuSettings = menuBar()->addMenu(tr("Window &Config"));
menuSettings->addAction(subwinAction);
menuSettings->addAction(shareAction);
@@ -771,6 +797,17 @@ void ArrangerView::cmd(int cmd)
case CMD_EXPAND_PART: expand_parts(); break;
case CMD_CLEAN_PART: clean_parts(); break;
+ case CMD_QUANTIZE: quantize_notes(); break;
+ case CMD_VELOCITY: modify_velocity(); break;
+ case CMD_CRESCENDO: crescendo(); break;
+ case CMD_NOTELEN: modify_notelen(); break;
+ case CMD_TRANSPOSE: transpose_notes(); break;
+ case CMD_ERASE: erase_notes(); break;
+ case CMD_MOVE: move_notes(); break;
+ case CMD_FIXED_LEN: set_notelen(); break;
+ case CMD_DELETE_OVERLAPS: delete_overlaps(); break;
+ case CMD_LEGATO: legato(); break;
+
}
}
diff --git a/muse2/muse/arranger/arrangerview.h b/muse2/muse/arranger/arrangerview.h
index 47edf6d3..752c2728 100644
--- a/muse2/muse/arranger/arrangerview.h
+++ b/muse2/muse/arranger/arrangerview.h
@@ -52,7 +52,9 @@ class ArrangerView : public TopWin
CMD_PASTE_TO_TRACK, CMD_PASTE_CLONE_TO_TRACK, CMD_DELETE,
CMD_SELECT_ALL, CMD_SELECT_NONE, CMD_SELECT_INVERT,
CMD_SELECT_ILOOP, CMD_SELECT_OLOOP, CMD_SELECT_PARTS,
- CMD_DELETE_TRACK, CMD_EXPAND_PART, CMD_SHRINK_PART, CMD_CLEAN_PART };
+ CMD_DELETE_TRACK, CMD_EXPAND_PART, CMD_SHRINK_PART, CMD_CLEAN_PART,
+ CMD_QUANTIZE, CMD_VELOCITY, CMD_CRESCENDO, CMD_NOTELEN, CMD_TRANSPOSE,
+ CMD_ERASE, CMD_MOVE, CMD_FIXED_LEN, CMD_DELETE_OVERLAPS, CMD_LEGATO };
virtual void closeEvent(QCloseEvent*);
@@ -81,6 +83,17 @@ class ArrangerView : public TopWin
QAction *midiTransformerAction;
QAction *editCleanPartsAction, *editShrinkPartsAction, *editExpandPartsAction;
+ QAction* func_quantize_action;
+ QAction* func_notelen_action;
+ QAction* func_velocity_action;
+ QAction* func_cresc_action;
+ QAction* func_transpose_action;
+ QAction* func_erase_action;
+ QAction* func_move_action;
+ QAction* func_fixed_len_action;
+ QAction* func_del_overlaps_action;
+ QAction* func_legato_action;
+
QSignalMapper *editSignalMapper;
QSignalMapper *scoreOneStaffPerTrackMapper;
QSignalMapper *scoreAllInOneMapper;
diff --git a/muse2/muse/functions.cpp b/muse2/muse/functions.cpp
index 5861ca9e..025f6c63 100644
--- a/muse2/muse/functions.cpp
+++ b/muse2/muse/functions.cpp
@@ -84,6 +84,37 @@ set<Part*> part_to_set(Part* p)
return result;
}
+set<Part*> get_all_parts()
+{
+ set<Part*> result;
+
+ TrackList* tracks=song->tracks();
+ for (TrackList::const_iterator t_it=tracks->begin(); t_it!=tracks->end(); t_it++)
+ {
+ const PartList* parts=(*t_it)->cparts();
+ for (ciPart p_it=parts->begin(); p_it!=parts->end(); p_it++)
+ result.insert(p_it->second);
+ }
+
+ return result;
+}
+
+set<Part*> get_all_selected_parts()
+{
+ set<Part*> result;
+
+ TrackList* tracks=song->tracks();
+ for (TrackList::const_iterator t_it=tracks->begin(); t_it!=tracks->end(); t_it++)
+ {
+ const PartList* parts=(*t_it)->cparts();
+ for (ciPart p_it=parts->begin(); p_it!=parts->end(); p_it++)
+ if (p_it->second->selected())
+ result.insert(p_it->second);
+ }
+
+ return result;
+}
+
bool is_relevant(const Event& event, const Part* part, int range)
{
unsigned tick;
@@ -115,6 +146,8 @@ map<Event*, Part*> get_events(const set<Part*>& parts, int range)
}
+
+
bool modify_notelen(const set<Part*>& parts)
{
if (!gatetime_dialog->exec())
@@ -226,6 +259,180 @@ bool legato(const set<Part*>& parts)
+bool modify_notelen()
+{
+ if (!gatetime_dialog->exec())
+ return false;
+
+ set<Part*> parts;
+ if (gatetime_dialog->range & FUNCTION_RANGE_ONLY_SELECTED)
+ parts=get_all_selected_parts();
+ else
+ parts=get_all_parts();
+
+ modify_notelen(parts,gatetime_dialog->range & FUNCTION_RANGE_ONLY_BETWEEN_MARKERS, gatetime_dialog->rateVal,gatetime_dialog->offsetVal);
+
+ return true;
+}
+
+bool modify_velocity()
+{
+ if (!velocity_dialog->exec())
+ return false;
+
+ set<Part*> parts;
+ if (velocity_dialog->range & FUNCTION_RANGE_ONLY_SELECTED)
+ parts=get_all_selected_parts();
+ else
+ parts=get_all_parts();
+
+ modify_velocity(parts,velocity_dialog->range & FUNCTION_RANGE_ONLY_BETWEEN_MARKERS,velocity_dialog->rateVal,velocity_dialog->offsetVal);
+
+ return true;
+}
+
+bool quantize_notes()
+{
+ if (!quantize_dialog->exec())
+ return false;
+
+ set<Part*> parts;
+ if (quantize_dialog->range & FUNCTION_RANGE_ONLY_SELECTED)
+ parts=get_all_selected_parts();
+ else
+ parts=get_all_parts();
+
+ quantize_notes(parts, quantize_dialog->range & FUNCTION_RANGE_ONLY_BETWEEN_MARKERS, (config.division*4)/(1<<quantize_dialog->raster_power2),
+ quantize_dialog->quant_len, quantize_dialog->strength, quantize_dialog->swing,
+ quantize_dialog->threshold);
+
+ return true;
+}
+
+bool erase_notes()
+{
+ if (!erase_dialog->exec())
+ return false;
+
+ set<Part*> parts;
+ if (erase_dialog->range & FUNCTION_RANGE_ONLY_SELECTED)
+ parts=get_all_selected_parts();
+ else
+ parts=get_all_parts();
+
+ erase_notes(parts,erase_dialog->range & FUNCTION_RANGE_ONLY_BETWEEN_MARKERS, erase_dialog->velo_threshold, erase_dialog->velo_thres_used,
+ erase_dialog->len_threshold, erase_dialog->len_thres_used );
+
+ return true;
+}
+
+bool delete_overlaps()
+{
+ if (!del_overlaps_dialog->exec())
+ return false;
+
+ set<Part*> parts;
+ if (del_overlaps_dialog->range & FUNCTION_RANGE_ONLY_SELECTED)
+ parts=get_all_selected_parts();
+ else
+ parts=get_all_parts();
+
+ delete_overlaps(parts,erase_dialog->range & FUNCTION_RANGE_ONLY_BETWEEN_MARKERS);
+
+ return true;
+}
+
+bool set_notelen()
+{
+ if (!set_notelen_dialog->exec())
+ return false;
+
+ set<Part*> parts;
+ if (set_notelen_dialog->range & FUNCTION_RANGE_ONLY_SELECTED)
+ parts=get_all_selected_parts();
+ else
+ parts=get_all_parts();
+
+ set_notelen(parts,set_notelen_dialog->range & FUNCTION_RANGE_ONLY_BETWEEN_MARKERS, set_notelen_dialog->len);
+
+ return true;
+}
+
+bool move_notes()
+{
+ if (!move_notes_dialog->exec())
+ return false;
+
+ set<Part*> parts;
+ if (move_notes_dialog->range & FUNCTION_RANGE_ONLY_SELECTED)
+ parts=get_all_selected_parts();
+ else
+ parts=get_all_parts();
+
+ move_notes(parts,move_notes_dialog->range & FUNCTION_RANGE_ONLY_BETWEEN_MARKERS, move_notes_dialog->amount);
+
+ return true;
+}
+
+bool transpose_notes()
+{
+ if (!transpose_dialog->exec())
+ return false;
+
+ set<Part*> parts;
+ if (transpose_dialog->range & FUNCTION_RANGE_ONLY_SELECTED)
+ parts=get_all_selected_parts();
+ else
+ parts=get_all_parts();
+
+ transpose_notes(parts,transpose_dialog->range & FUNCTION_RANGE_ONLY_BETWEEN_MARKERS, transpose_dialog->amount);
+
+ return true;
+}
+
+bool crescendo()
+{
+ if (song->rpos() <= song->lpos())
+ {
+ QMessageBox::warning(NULL, QObject::tr("Error"), QObject::tr("Please first select the range for crescendo with the loop markers."));
+ return false;
+ }
+
+ if (!crescendo_dialog->exec())
+ return false;
+
+ set<Part*> parts;
+ if (crescendo_dialog->range & FUNCTION_RANGE_ONLY_SELECTED)
+ parts=get_all_selected_parts();
+ else
+ parts=get_all_parts();
+
+ crescendo(parts,crescendo_dialog->range & FUNCTION_RANGE_ONLY_BETWEEN_MARKERS, crescendo_dialog->start_val,crescendo_dialog->end_val,crescendo_dialog->absolute);
+
+ return true;
+}
+
+bool legato()
+{
+ if (!legato_dialog->exec())
+ return false;
+
+ set<Part*> parts;
+ if (legato_dialog->range & FUNCTION_RANGE_ONLY_SELECTED)
+ parts=get_all_selected_parts();
+ else
+ parts=get_all_parts();
+
+ legato(parts,legato_dialog->range & FUNCTION_RANGE_ONLY_BETWEEN_MARKERS, legato_dialog->min_len, !legato_dialog->allow_shortening);
+
+ return true;
+}
+
+
+
+
+
+
bool modify_velocity(const set<Part*>& parts, int range, int rate, int offset)
{
map<Event*, Part*> events = get_events(parts, range);
diff --git a/muse2/muse/functions.h b/muse2/muse/functions.h
index 3b8a23f3..4e2e7151 100644
--- a/muse2/muse/functions.h
+++ b/muse2/muse/functions.h
@@ -41,6 +41,11 @@ extern Legato* legato_dialog;
void init_function_dialogs(QWidget* parent);
+#define FUNCTION_RANGE_ONLY_SELECTED 1
+#define FUNCTION_RANGE_ONLY_BETWEEN_MARKERS 2
+
+
+
std::set<Part*> partlist_to_set(PartList* pl);
std::set<Part*> part_to_set(Part* p);
std::map<Event*, Part*> get_events(const std::set<Part*>& parts, int range);
@@ -72,6 +77,18 @@ bool erase_notes(const std::set<Part*>& parts);
bool delete_overlaps(const std::set<Part*>& parts);
bool legato(const std::set<Part*>& parts);
+//the below functions operate on selected parts
+bool modify_velocity();
+bool modify_notelen();
+bool quantize_notes();
+bool set_notelen();
+bool move_notes();
+bool transpose_notes();
+bool crescendo();
+bool erase_notes();
+bool delete_overlaps();
+bool legato();
+
//functions for copy'n'paste
void copy_notes(const std::set<Part*>& parts, int range);