Skip to content

Commit 7308835

Browse files
committed
- MIDI Tool Resize / Legato: dropped percentage and added type (Normal, Trim and Extend) and length settings. (EXPERIMENTAL)
1 parent 6c4f5a3 commit 7308835

11 files changed

+635
-521
lines changed

src/qtractorMidiToolsForm.cpp

Lines changed: 25 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -188,14 +188,12 @@ qtractorMidiToolsForm::qtractorMidiToolsForm ( QWidget *pParent )
188188
while (snapIter.hasNext())
189189
m_ui.QuantizeSwingComboBox->addItem(snapIcon, snapIter.next());
190190
// m_ui.QuantizeSwingComboBox->insertItems(0, snapItems);
191-
m_ui.ResizeLegatoQuantizeComboBox->clear();
192-
m_ui.ResizeLegatoQuantizeComboBox->setIconSize(snapIconSize);
191+
m_ui.ResizeLegatoLengthComboBox->clear();
192+
m_ui.ResizeLegatoLengthComboBox->setIconSize(snapIconSize);
193193
snapIter.toFront();
194-
if (snapIter.hasNext())
195-
m_ui.ResizeLegatoQuantizeComboBox->addItem(
196-
QIcon(":/images/itemNone.png"), snapIter.next());
194+
snapIter.next();
197195
while (snapIter.hasNext())
198-
m_ui.ResizeLegatoQuantizeComboBox->addItem(snapIcon, snapIter.next());
196+
m_ui.ResizeLegatoLengthComboBox->addItem(snapIcon, snapIter.next());
199197
// m_ui.ResizeLegatoQuantizeComboBox->insertItems(0, snapItems);
200198
// Default quantization value...
201199
unsigned short iSnapPerBeat = m_pTimeScale->snapPerBeat();
@@ -206,7 +204,7 @@ qtractorMidiToolsForm::qtractorMidiToolsForm ( QWidget *pParent )
206204
m_ui.QuantizeDurationComboBox->setCurrentIndex(iSnapIndex);
207205
m_ui.QuantizeSwingComboBox->setCurrentIndex(0);
208206
m_ui.QuantizeSwingTypeComboBox->setCurrentIndex(0);
209-
m_ui.ResizeLegatoQuantizeComboBox->setCurrentIndex(0);
207+
m_ui.ResizeLegatoLengthComboBox->setCurrentIndex(iSnapIndex);
210208
// Initial tempo-ramp range...
211209
if (pSession->editHead() < pSession->editTail()) {
212210
qtractorTimeScale::Cursor cursor(m_pTimeScale);
@@ -393,7 +391,6 @@ qtractorMidiToolsForm::qtractorMidiToolsForm ( QWidget *pParent )
393391
QObject::connect(m_ui.ResizeDurationFormatComboBox,
394392
SIGNAL(activated(int)),
395393
SLOT(formatChanged(int)));
396-
397394
QObject::connect(m_ui.ResizeValueCheckBox,
398395
SIGNAL(toggled(bool)),
399396
SLOT(changed()));
@@ -409,10 +406,10 @@ qtractorMidiToolsForm::qtractorMidiToolsForm ( QWidget *pParent )
409406
QObject::connect(m_ui.ResizeLegatoCheckBox,
410407
SIGNAL(toggled(bool)),
411408
SLOT(changed()));
412-
QObject::connect(m_ui.ResizeLegatoSpinBox,
413-
SIGNAL(valueChanged(double)),
409+
QObject::connect(m_ui.ResizeLegatoTypeComboBox,
410+
SIGNAL(activated(int)),
414411
SLOT(changed()));
415-
QObject::connect(m_ui.ResizeLegatoQuantizeComboBox,
412+
QObject::connect(m_ui.ResizeLegatoLengthComboBox,
416413
SIGNAL(activated(int)),
417414
SLOT(changed()));
418415
QObject::connect(m_ui.ResizeLegatoModeComboBox,
@@ -627,8 +624,8 @@ void qtractorMidiToolsForm::loadPreset ( const QString& sPreset )
627624
// Resize legato mode tool...
628625
if (vlist.count() > 10) {
629626
m_ui.ResizeLegatoCheckBox->setChecked(vlist[7].toBool());
630-
m_ui.ResizeLegatoSpinBox->setValue(vlist[8].toDouble());
631-
m_ui.ResizeLegatoQuantizeComboBox->setCurrentIndex(vlist[9].toInt());
627+
m_ui.ResizeLegatoTypeComboBox->setCurrentIndex(vlist[8].toInt());
628+
m_ui.ResizeLegatoLengthComboBox->setCurrentIndex(vlist[9].toInt());
632629
m_ui.ResizeLegatoModeComboBox->setCurrentIndex(vlist[10].toInt());
633630
}
634631
// Rescale tool...
@@ -735,8 +732,8 @@ void qtractorMidiToolsForm::savePreset ( const QString& sPreset )
735732
vlist.append(m_ui.ResizeValue2ComboBox->currentIndex());
736733
vlist.append(m_ui.ResizeValue2SpinBox->value());
737734
vlist.append(m_ui.ResizeLegatoCheckBox->isChecked());
738-
vlist.append(m_ui.ResizeLegatoSpinBox->value());
739-
vlist.append(m_ui.ResizeLegatoQuantizeComboBox->currentIndex());
735+
vlist.append(m_ui.ResizeLegatoTypeComboBox->currentIndex());
736+
vlist.append(m_ui.ResizeLegatoLengthComboBox->currentIndex());
740737
vlist.append(m_ui.ResizeLegatoModeComboBox->currentIndex());
741738
settings.setValue("/Resize", vlist);
742739
// Rescale tool...
@@ -1192,23 +1189,20 @@ qtractorMidiEditCommand *qtractorMidiToolsForm::midiEditCommand (
11921189
if (m_ui.ResizeLegatoCheckBox->isChecked()
11931190
&& pEvent->type() == qtractorMidiEvent::NOTEON) {
11941191
if (pLastEvent) {
1195-
const float p2
1196-
= 0.01f * float(m_ui.ResizeLegatoSpinBox->value());
1197-
const long d2
1198-
= long(p2 * float(pLastEvent->time() - pEvent->time()));
1199-
const unsigned short p = qtractorTimeScale::snapFromIndex(
1200-
m_ui.ResizeLegatoQuantizeComboBox->currentIndex());
1201-
long iDuration2 = d2;
1202-
if (p > 0) {
1192+
long d2 = long(float(pLastEvent->time() - pEvent->time()));
1193+
const int i = m_ui.ResizeLegatoTypeComboBox->currentIndex();
1194+
if (i > 0) {
1195+
const unsigned short p = qtractorTimeScale::snapFromIndex(
1196+
m_ui.ResizeLegatoLengthComboBox->currentIndex());
12031197
const unsigned long q = pNode->ticksPerBeat / p;
1204-
iDuration2 = q * ((iDuration2 + q - 1) / q);
1198+
d2 += (i == 1 ? -long(q) : +long(q));
12051199
}
12061200
if (m_ui.ResizeLegatoModeComboBox->currentIndex() > 0) {
1207-
if (iDuration < iDuration2 && iDuration2 > 0)
1208-
iDuration = iDuration2;
1201+
if (iDuration < d2 && d2 > 0)
1202+
iDuration = d2;
12091203
}
1210-
else if (iDuration2 > 0)
1211-
iDuration = iDuration2;
1204+
else if (d2 > 0)
1205+
iDuration = d2;
12121206
}
12131207
pLastEvent = pEvent;
12141208
}
@@ -1522,9 +1516,9 @@ void qtractorMidiToolsForm::stabilizeForm (void)
15221516
bEnabled2 = bEnabled && m_ui.ResizeLegatoCheckBox->isChecked();
15231517
if (bEnabled2)
15241518
++iEnabled;
1525-
m_ui.ResizeLegatoSpinBox->setEnabled(bEnabled2);
1526-
m_ui.ResizeLegatoQuantizeComboBox->setEnabled(bEnabled2
1527-
&& qAbs(float(m_ui.ResizeLegatoSpinBox->value()) - 100.0f) > 0.05f);
1519+
m_ui.ResizeLegatoTypeComboBox->setEnabled(bEnabled2);
1520+
m_ui.ResizeLegatoLengthComboBox->setEnabled(bEnabled2
1521+
&& m_ui.ResizeLegatoTypeComboBox->currentIndex() > 0);
15281522
m_ui.ResizeLegatoModeComboBox->setEnabled(bEnabled2);
15291523

15301524
// Rescale tool...

src/qtractorMidiToolsForm.ui

Lines changed: 27 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -944,7 +944,7 @@
944944
</item>
945945
</widget>
946946
</item>
947-
<item row="1" column="6">
947+
<item row="1" column="6" colspan="2">
948948
<spacer>
949949
<property name="orientation">
950950
<enum>Qt::Horizontal</enum>
@@ -980,7 +980,7 @@
980980
</property>
981981
</widget>
982982
</item>
983-
<item row="2" column="3">
983+
<item row="2" column="3" colspan="2">
984984
<widget class="QComboBox" name="ResizeValue2ComboBox">
985985
<property name="toolTip">
986986
<string>Resize value mode</string>
@@ -997,7 +997,7 @@
997997
</item>
998998
</widget>
999999
</item>
1000-
<item row="2" column="4">
1000+
<item row="2" column="5" colspan="2">
10011001
<widget class="QSpinBox" name="ResizeValue2SpinBox">
10021002
<property name="minimumSize">
10031003
<size>
@@ -1013,7 +1013,7 @@
10131013
</property>
10141014
</widget>
10151015
</item>
1016-
<item row="2" column="5" colspan="2">
1016+
<item row="2" column="7">
10171017
<spacer>
10181018
<property name="orientation">
10191019
<enum>Qt::Horizontal</enum>
@@ -1034,47 +1034,41 @@
10341034
</widget>
10351035
</item>
10361036
<item row="3" column="2">
1037-
<widget class="QDoubleSpinBox" name="ResizeLegatoSpinBox">
1037+
<widget class="QComboBox" name="ResizeLegatoTypeComboBox">
10381038
<property name="minimumSize">
10391039
<size>
10401040
<width>60</width>
10411041
<height>0</height>
10421042
</size>
10431043
</property>
10441044
<property name="toolTip">
1045-
<string>Legato percent</string>
1046-
</property>
1047-
<property name="suffix">
1048-
<string> %</string>
1049-
</property>
1050-
<property name="accelerated">
1051-
<bool>true</bool>
1052-
</property>
1053-
<property name="decimals">
1054-
<number>1</number>
1055-
</property>
1056-
<property name="minimum">
1057-
<double>80.0</double>
1058-
</property>
1059-
<property name="maximum">
1060-
<double>120.0</double>
1061-
</property>
1062-
<property name="singleStep">
1063-
<double>0.1</double>
1064-
</property>
1065-
<property name="value">
1066-
<double>100.0</double>
1045+
<string>Legato trim/extend type</string>
10671046
</property>
1047+
<item>
1048+
<property name="text">
1049+
<string>Normal</string>
1050+
</property>
1051+
</item>
1052+
<item>
1053+
<property name="text">
1054+
<string>Trim</string>
1055+
</property>
1056+
</item>
1057+
<item>
1058+
<property name="text">
1059+
<string>Extend</string>
1060+
</property>
1061+
</item>
10681062
</widget>
10691063
</item>
1070-
<item row="3" column="3">
1071-
<widget class="QComboBox" name="ResizeLegatoQuantizeComboBox">
1064+
<item row="3" column="3" colspan="2">
1065+
<widget class="QComboBox" name="ResizeLegatoLengthComboBox">
10721066
<property name="toolTip">
1073-
<string>Legato quantize</string>
1067+
<string>Legato trim/extend length</string>
10741068
</property>
10751069
</widget>
10761070
</item>
1077-
<item row="3" column="4">
1071+
<item row="3" column="5" colspan="2">
10781072
<widget class="QComboBox" name="ResizeLegatoModeComboBox">
10791073
<property name="toolTip">
10801074
<string>Legato mode</string>
@@ -1091,7 +1085,7 @@
10911085
</item>
10921086
</widget>
10931087
</item>
1094-
<item row="3" column="3" colspan="2">
1088+
<item row="3" column="7">
10951089
<spacer>
10961090
<property name="orientation">
10971091
<enum>Qt::Horizontal</enum>
@@ -1104,7 +1098,7 @@
11041098
</property>
11051099
</spacer>
11061100
</item>
1107-
<item row="4" column="1" colspan="5">
1101+
<item row="4" column="1" colspan="6">
11081102
<spacer>
11091103
<property name="orientation">
11101104
<enum>Qt::Vertical</enum>

0 commit comments

Comments
 (0)