From cebe18a6c4211f23bc7cad82b4d9a9611a46234f Mon Sep 17 00:00:00 2001 From: Florian Jung Date: Mon, 23 May 2011 12:27:43 +0000 Subject: the "remove" function now supports velo- and length-thresholds --- muse2/muse/functions.cpp | 11 +- muse2/muse/functions.h | 2 +- muse2/muse/midiedit/scoreedit.cpp | 8 +- muse2/muse/widgets/function_dialogs/remove.cpp | 20 ++++ muse2/muse/widgets/function_dialogs/remove.h | 4 + muse2/muse/widgets/function_dialogs/removebase.ui | 129 +++++++++++++++++++++- 6 files changed, 162 insertions(+), 12 deletions(-) diff --git a/muse2/muse/functions.cpp b/muse2/muse/functions.cpp index ba5f33c4..1ad81693 100644 --- a/muse2/muse/functions.cpp +++ b/muse2/muse/functions.cpp @@ -119,7 +119,8 @@ bool erase_notes(const set& parts) if (!erase_dialog->exec()) return false; - erase_notes(parts,erase_dialog->range); + erase_notes(parts,erase_dialog->range, erase_dialog->velo_threshold, erase_dialog->velo_thres_used, + erase_dialog->len_threshold, erase_dialog->len_thres_used ); return true; } @@ -366,7 +367,7 @@ void quantize_notes(const set& parts, int range, int raster, bool quant_l } } -void erase_notes(const set& parts, int range) +void erase_notes(const set& parts, int range, int velo_threshold, bool velo_thres_used, int len_threshold, bool len_thres_used) { map events = get_events(parts, range); @@ -378,8 +379,10 @@ void erase_notes(const set& parts, int range) { Event& event=*(it->first); Part* part=it->second; - - audio->msgDeleteEvent(event, part, false, false, false); + if ( (!velo_thres_used && !len_thres_used) || + (velo_thres_used && event.velo() < velo_threshold) || + (len_thres_used && int(event.lenTick()) < len_threshold) ) + audio->msgDeleteEvent(event, part, false, false, false); } song->endUndo(SC_EVENT_REMOVED); diff --git a/muse2/muse/functions.h b/muse2/muse/functions.h index 4d7be6e2..18f6e3ec 100644 --- a/muse2/muse/functions.h +++ b/muse2/muse/functions.h @@ -43,7 +43,7 @@ void modify_velocity(const std::set& parts, int range, int rate, int offs void modify_off_velocity(const std::set& parts, int range, int rate, int offset=0); void modify_notelen(const std::set& parts, int range, int rate, int offset=0); void quantize_notes(const std::set& parts, int range, int raster, bool len=false, int strength=100, int swing=0, int threshold=0); -void erase_notes(const std::set& parts, int range); +void erase_notes(const std::set& parts, int range, int velo_threshold=0, bool velo_thres_used=false, int len_threshold=0, bool len_thres_used=false); void delete_overlaps(const std::set& parts, int range); void set_notelen(const std::set& parts, int range, int len); void move_notes(const std::set& parts, int range, signed int ticks); diff --git a/muse2/muse/midiedit/scoreedit.cpp b/muse2/muse/midiedit/scoreedit.cpp index b0e0eaf6..2636d4f2 100644 --- a/muse2/muse/midiedit/scoreedit.cpp +++ b/muse2/muse/midiedit/scoreedit.cpp @@ -4255,27 +4255,23 @@ void staff_t::apply_lasso(QRect rect, set& already_processed) /* BUGS and potential bugs - * o quantize always quantizes length. make this selectable! * 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 drum list: scroll while dragging + * o legato: extend length to next note * * IMPORTANT TODO * o do partial recalculating; recalculating can take pretty long * (0,5 sec) when displaying a whole song in scores * o transpose etc. must also transpose key-pressure events * o transpose: support in-key-transpose - * o legato: extend length to next note - * o delete: add velo and len threshold * o thin out: remove unneeded ctrl messages - * o in drum roll: changing the list causes undo to be triggered, WTF? - * o changing list is dead slow * * less important stuff + * o drum list: scroll while dragging * o controller view in score editor * o quantize-templates (everything is forced into a specified * rhythm) diff --git a/muse2/muse/widgets/function_dialogs/remove.cpp b/muse2/muse/widgets/function_dialogs/remove.cpp index 5ad272ab..4a875135 100644 --- a/muse2/muse/widgets/function_dialogs/remove.cpp +++ b/muse2/muse/widgets/function_dialogs/remove.cpp @@ -25,6 +25,10 @@ Remove::Remove(QWidget* parent) void Remove::pull_values() { range = range_group->checkedId(); + len_thres_used=len_checkbox->isChecked(); + len_threshold=len_spinbox->value(); + velo_thres_used=velo_checkbox->isChecked(); + velo_threshold=velo_spinbox->value(); } void Remove::accept() @@ -38,6 +42,10 @@ int Remove::exec() if ((range < 0) || (range > 3)) range=0; range_group->button(range)->setChecked(true); + len_checkbox->setChecked(len_thres_used); + len_spinbox->setValue(len_threshold); + velo_checkbox->setChecked(velo_thres_used); + velo_spinbox->setValue(velo_threshold); return QDialog::exec(); } @@ -56,6 +64,14 @@ void Remove::read_configuration(Xml& xml) case Xml::TagStart: if (tag == "range") range=xml.parseInt(); + else if (tag == "velo_threshold") + velo_threshold=xml.parseInt(); + else if (tag == "velo_thres_used") + velo_thres_used=xml.parseInt(); + else if (tag == "len_threshold") + len_threshold=xml.parseInt(); + else if (tag == "len_thres_used") + len_thres_used=xml.parseInt(); else xml.unknown("Erase"); break; @@ -74,5 +90,9 @@ void Remove::write_configuration(int level, Xml& xml) { xml.tag(level++, "erase"); xml.intTag(level, "range", range); + xml.intTag(level, "velo_threshold", velo_threshold); + xml.intTag(level, "velo_thres_used", velo_thres_used); + xml.intTag(level, "len_threshold", len_threshold); + xml.intTag(level, "len_thres_used", len_thres_used); xml.tag(level, "/erase"); } diff --git a/muse2/muse/widgets/function_dialogs/remove.h b/muse2/muse/widgets/function_dialogs/remove.h index 5615ed42..4c1a91e9 100644 --- a/muse2/muse/widgets/function_dialogs/remove.h +++ b/muse2/muse/widgets/function_dialogs/remove.h @@ -27,6 +27,10 @@ class Remove : public QDialog, public Ui::RemoveBase Remove(QWidget* parent = 0); int range; + int velo_threshold; + bool velo_thres_used; + int len_threshold; + bool len_thres_used; void read_configuration(Xml& xml); void write_configuration(int level, Xml& xml); diff --git a/muse2/muse/widgets/function_dialogs/removebase.ui b/muse2/muse/widgets/function_dialogs/removebase.ui index 3381795c..79d541cc 100644 --- a/muse2/muse/widgets/function_dialogs/removebase.ui +++ b/muse2/muse/widgets/function_dialogs/removebase.ui @@ -10,7 +10,7 @@ 0 0 275 - 195 + 443 @@ -69,6 +69,101 @@ + + + + Thresholds + + + false + + + false + + + + 11 + + + 6 + + + + + false + + + true + + + + + + 0 + + + 127 + + + 1 + + + 16 + + + + + + + false + + + ticks + + + 10000 + + + 12 + + + + + + + Velocity + + + + + + + Length + + + + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Sans'; font-size:9pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:7px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">If nothing is checked, everything is removed.</p> +<p style=" margin-top:0px; margin-bottom:7px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">If velocity is checked, only notes with velo &lt; threshold are removed.</p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">If both are checked, notes with velo &lt; threshold OR with length &lt; threshold are removed.</p></body></html> + + + Qt::AutoText + + + true + + + + + + @@ -149,5 +244,37 @@ + + velo_checkbox + toggled(bool) + velo_spinbox + setEnabled(bool) + + + 83 + 192 + + + 198 + 193 + + + + + len_checkbox + toggled(bool) + len_spinbox + setEnabled(bool) + + + 83 + 221 + + + 198 + 222 + + + -- cgit v1.2.3