Skip to content

Commit 6c4f5a3

Browse files
committed
- MIDI Tool Resize / Legato: added new gap quantize parameter setting; also limit gap percentage to 80%..120% range. (EXPERIMENTAL)
1 parent c5937b3 commit 6c4f5a3

17 files changed

+738
-659
lines changed

src/qtractorMidiToolsForm.cpp

Lines changed: 49 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -165,26 +165,38 @@ qtractorMidiToolsForm::qtractorMidiToolsForm ( QWidget *pParent )
165165
// Fill-up snap-per-beat items...
166166
const QIcon snapIcon(":/images/itemBeat.png");
167167
const QSize snapIconSize(8, 16);
168-
const QStringList& snapItems = qtractorTimeScale::snapItems(1);
168+
const QStringList& snapItems = qtractorTimeScale::snapItems();
169169
QStringListIterator snapIter(snapItems);
170170
m_ui.QuantizeTimeComboBox->clear();
171171
m_ui.QuantizeTimeComboBox->setIconSize(snapIconSize);
172172
// snapIter.toFront();
173+
snapIter.next();
173174
while (snapIter.hasNext())
174175
m_ui.QuantizeTimeComboBox->addItem(snapIcon, snapIter.next());
175176
// m_ui.QuantizeTimeComboBox->insertItems(0, snapItems);
176177
m_ui.QuantizeDurationComboBox->clear();
177178
m_ui.QuantizeDurationComboBox->setIconSize(snapIconSize);
178179
snapIter.toFront();
180+
snapIter.next();
179181
while (snapIter.hasNext())
180182
m_ui.QuantizeDurationComboBox->addItem(snapIcon, snapIter.next());
181183
// m_ui.QuantizeDurationComboBox->insertItems(0, snapItems);
182184
m_ui.QuantizeSwingComboBox->clear();
183185
m_ui.QuantizeSwingComboBox->setIconSize(snapIconSize);
184186
snapIter.toFront();
187+
snapIter.next();
185188
while (snapIter.hasNext())
186189
m_ui.QuantizeSwingComboBox->addItem(snapIcon, snapIter.next());
187190
// m_ui.QuantizeSwingComboBox->insertItems(0, snapItems);
191+
m_ui.ResizeLegatoQuantizeComboBox->clear();
192+
m_ui.ResizeLegatoQuantizeComboBox->setIconSize(snapIconSize);
193+
snapIter.toFront();
194+
if (snapIter.hasNext())
195+
m_ui.ResizeLegatoQuantizeComboBox->addItem(
196+
QIcon(":/images/itemNone.png"), snapIter.next());
197+
while (snapIter.hasNext())
198+
m_ui.ResizeLegatoQuantizeComboBox->addItem(snapIcon, snapIter.next());
199+
// m_ui.ResizeLegatoQuantizeComboBox->insertItems(0, snapItems);
188200
// Default quantization value...
189201
unsigned short iSnapPerBeat = m_pTimeScale->snapPerBeat();
190202
if (iSnapPerBeat > 0)
@@ -194,6 +206,7 @@ qtractorMidiToolsForm::qtractorMidiToolsForm ( QWidget *pParent )
194206
m_ui.QuantizeDurationComboBox->setCurrentIndex(iSnapIndex);
195207
m_ui.QuantizeSwingComboBox->setCurrentIndex(0);
196208
m_ui.QuantizeSwingTypeComboBox->setCurrentIndex(0);
209+
m_ui.ResizeLegatoQuantizeComboBox->setCurrentIndex(0);
197210
// Initial tempo-ramp range...
198211
if (pSession->editHead() < pSession->editTail()) {
199212
qtractorTimeScale::Cursor cursor(m_pTimeScale);
@@ -377,7 +390,7 @@ qtractorMidiToolsForm::qtractorMidiToolsForm ( QWidget *pParent )
377390
QObject::connect(m_ui.ResizeDurationSpinBox,
378391
SIGNAL(valueChanged(unsigned long)),
379392
SLOT(changed()));
380-
QObject::connect(m_ui.ResizeFormatComboBox,
393+
QObject::connect(m_ui.ResizeDurationFormatComboBox,
381394
SIGNAL(activated(int)),
382395
SLOT(formatChanged(int)));
383396

@@ -399,7 +412,10 @@ qtractorMidiToolsForm::qtractorMidiToolsForm ( QWidget *pParent )
399412
QObject::connect(m_ui.ResizeLegatoSpinBox,
400413
SIGNAL(valueChanged(double)),
401414
SLOT(changed()));
402-
QObject::connect(m_ui.ResizeLegatoComboBox,
415+
QObject::connect(m_ui.ResizeLegatoQuantizeComboBox,
416+
SIGNAL(activated(int)),
417+
SLOT(changed()));
418+
QObject::connect(m_ui.ResizeLegatoModeComboBox,
403419
SIGNAL(activated(int)),
404420
SLOT(changed()));
405421

@@ -609,10 +625,11 @@ void qtractorMidiToolsForm::loadPreset ( const QString& sPreset )
609625
m_ui.ResizeValue2SpinBox->setValue(vlist[6].toInt());
610626
}
611627
// Resize legato mode tool...
612-
if (vlist.count() > 9) {
628+
if (vlist.count() > 10) {
613629
m_ui.ResizeLegatoCheckBox->setChecked(vlist[7].toBool());
614630
m_ui.ResizeLegatoSpinBox->setValue(vlist[8].toDouble());
615-
m_ui.ResizeLegatoComboBox->setCurrentIndex(vlist[9].toInt());
631+
m_ui.ResizeLegatoQuantizeComboBox->setCurrentIndex(vlist[9].toInt());
632+
m_ui.ResizeLegatoModeComboBox->setCurrentIndex(vlist[10].toInt());
616633
}
617634
// Rescale tool...
618635
vlist = settings.value("/Rescale").toList();
@@ -719,7 +736,8 @@ void qtractorMidiToolsForm::savePreset ( const QString& sPreset )
719736
vlist.append(m_ui.ResizeValue2SpinBox->value());
720737
vlist.append(m_ui.ResizeLegatoCheckBox->isChecked());
721738
vlist.append(m_ui.ResizeLegatoSpinBox->value());
722-
vlist.append(m_ui.ResizeLegatoComboBox->currentIndex());
739+
vlist.append(m_ui.ResizeLegatoQuantizeComboBox->currentIndex());
740+
vlist.append(m_ui.ResizeLegatoModeComboBox->currentIndex());
723741
settings.setValue("/Resize", vlist);
724742
// Rescale tool...
725743
vlist.clear();
@@ -1174,16 +1192,23 @@ qtractorMidiEditCommand *qtractorMidiToolsForm::midiEditCommand (
11741192
if (m_ui.ResizeLegatoCheckBox->isChecked()
11751193
&& pEvent->type() == qtractorMidiEvent::NOTEON) {
11761194
if (pLastEvent) {
1177-
const float p
1195+
const float p2
11781196
= 0.01f * float(m_ui.ResizeLegatoSpinBox->value());
11791197
const long d2
1180-
= long(p * float(pLastEvent->time() - pEvent->time()));
1181-
if (m_ui.ResizeLegatoComboBox->currentIndex() > 0) {
1182-
if (iDuration < d2 && d2 > 0)
1183-
iDuration = 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) {
1203+
const unsigned long q = pNode->ticksPerBeat / p;
1204+
iDuration2 = q * ((iDuration2 + q - 1) / q);
1205+
}
1206+
if (m_ui.ResizeLegatoModeComboBox->currentIndex() > 0) {
1207+
if (iDuration < iDuration2 && iDuration2 > 0)
1208+
iDuration = iDuration2;
11841209
}
1185-
else if (d2 > 0)
1186-
iDuration = d2;
1210+
else if (iDuration2 > 0)
1211+
iDuration = iDuration2;
11871212
}
11881213
pLastEvent = pEvent;
11891214
}
@@ -1343,7 +1368,7 @@ void qtractorMidiToolsForm::formatChanged ( int iDisplayFormat )
13431368
= qtractorTimeScale::DisplayFormat(iDisplayFormat);
13441369

13451370
m_ui.TransposeFormatComboBox->setCurrentIndex(iDisplayFormat);
1346-
m_ui.ResizeFormatComboBox->setCurrentIndex(iDisplayFormat);
1371+
m_ui.ResizeDurationFormatComboBox->setCurrentIndex(iDisplayFormat);
13471372

13481373
if (m_pTimeScale) {
13491374
// Set from local time-scale instance...
@@ -1481,12 +1506,7 @@ void qtractorMidiToolsForm::stabilizeForm (void)
14811506
if (bEnabled2)
14821507
++iEnabled;
14831508
m_ui.ResizeDurationSpinBox->setEnabled(bEnabled2);
1484-
m_ui.ResizeFormatComboBox->setEnabled(bEnabled2);
1485-
bEnabled2 = bEnabled && m_ui.ResizeLegatoCheckBox->isChecked();
1486-
if (bEnabled2)
1487-
++iEnabled;
1488-
m_ui.ResizeLegatoSpinBox->setEnabled(bEnabled2);
1489-
m_ui.ResizeLegatoComboBox->setEnabled(bEnabled2);
1509+
m_ui.ResizeDurationFormatComboBox->setEnabled(bEnabled2);
14901510

14911511
m_ui.ResizeValueCheckBox->setEnabled(bEnabled);
14921512
bEnabled2 = bEnabled && m_ui.ResizeValueCheckBox->isChecked();
@@ -1498,6 +1518,15 @@ void qtractorMidiToolsForm::stabilizeForm (void)
14981518
bEnabled2 = (m_ui.ResizeValue2ComboBox->currentIndex() > 0);
14991519
m_ui.ResizeValue2SpinBox->setEnabled(bEnabled2);
15001520

1521+
m_ui.ResizeLegatoCheckBox->setEnabled(bEnabled);
1522+
bEnabled2 = bEnabled && m_ui.ResizeLegatoCheckBox->isChecked();
1523+
if (bEnabled2)
1524+
++iEnabled;
1525+
m_ui.ResizeLegatoSpinBox->setEnabled(bEnabled2);
1526+
m_ui.ResizeLegatoQuantizeComboBox->setEnabled(bEnabled2
1527+
&& qAbs(float(m_ui.ResizeLegatoSpinBox->value()) - 100.0f) > 0.05f);
1528+
m_ui.ResizeLegatoModeComboBox->setEnabled(bEnabled2);
1529+
15011530
// Rescale tool...
15021531

15031532
bEnabled = m_ui.RescaleCheckBox->isChecked();

src/qtractorMidiToolsForm.ui

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -923,7 +923,7 @@
923923
</widget>
924924
</item>
925925
<item row="1" column="4" colspan="2">
926-
<widget class="QComboBox" name="ResizeFormatComboBox">
926+
<widget class="QComboBox" name="ResizeDurationFormatComboBox">
927927
<property name="toolTip">
928928
<string>Resize duration format</string>
929929
</property>
@@ -1042,7 +1042,7 @@
10421042
</size>
10431043
</property>
10441044
<property name="toolTip">
1045-
<string>Legato duration percent</string>
1045+
<string>Legato percent</string>
10461046
</property>
10471047
<property name="suffix">
10481048
<string> %</string>
@@ -1054,10 +1054,10 @@
10541054
<number>1</number>
10551055
</property>
10561056
<property name="minimum">
1057-
<double>0.0</double>
1057+
<double>80.0</double>
10581058
</property>
10591059
<property name="maximum">
1060-
<double>200.0</double>
1060+
<double>120.0</double>
10611061
</property>
10621062
<property name="singleStep">
10631063
<double>0.1</double>
@@ -1068,7 +1068,14 @@
10681068
</widget>
10691069
</item>
10701070
<item row="3" column="3">
1071-
<widget class="QComboBox" name="ResizeLegatoComboBox">
1071+
<widget class="QComboBox" name="ResizeLegatoQuantizeComboBox">
1072+
<property name="toolTip">
1073+
<string>Legato quantize</string>
1074+
</property>
1075+
</widget>
1076+
</item>
1077+
<item row="3" column="4">
1078+
<widget class="QComboBox" name="ResizeLegatoModeComboBox">
10721079
<property name="toolTip">
10731080
<string>Legato mode</string>
10741081
</property>
@@ -1084,7 +1091,7 @@
10841091
</item>
10851092
</widget>
10861093
</item>
1087-
<item row="3" column="3" colspan="3">
1094+
<item row="3" column="3" colspan="2">
10881095
<spacer>
10891096
<property name="orientation">
10901097
<enum>Qt::Horizontal</enum>
@@ -1656,14 +1663,15 @@ Edit head/tail (blue) markers define the shift range.</string>
16561663
<tabstop>ResizeCheckBox</tabstop>
16571664
<tabstop>ResizeDurationCheckBox</tabstop>
16581665
<tabstop>ResizeDurationSpinBox</tabstop>
1659-
<tabstop>ResizeFormatComboBox</tabstop>
1666+
<tabstop>ResizeDurationFormatComboBox</tabstop>
16601667
<tabstop>ResizeValueCheckBox</tabstop>
16611668
<tabstop>ResizeValueSpinBox</tabstop>
16621669
<tabstop>ResizeValue2ComboBox</tabstop>
16631670
<tabstop>ResizeValue2SpinBox</tabstop>
16641671
<tabstop>ResizeLegatoCheckBox</tabstop>
16651672
<tabstop>ResizeLegatoSpinBox</tabstop>
1666-
<tabstop>ResizeLegatoComboBox</tabstop>
1673+
<tabstop>ResizeLegatoQuantizeComboBox</tabstop>
1674+
<tabstop>ResizeLegatoModeComboBox</tabstop>
16671675
<tabstop>RescaleCheckBox</tabstop>
16681676
<tabstop>RescaleTimeCheckBox</tabstop>
16691677
<tabstop>RescaleTimeSpinBox</tabstop>

src/qtractorOptionsForm.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ qtractorOptionsForm::qtractorOptionsForm ( QWidget *pParent )
158158

159159
// Populate the MIDI capture quantize combo-box.
160160
const QIcon snapIcon(":/images/itemBeat.png");
161-
const QStringList& snapItems = qtractorTimeScale::snapItems(0);
161+
const QStringList& snapItems = qtractorTimeScale::snapItems();
162162
QStringListIterator snapIter(snapItems);
163163
m_ui.MidiCaptureQuantizeComboBox->clear();
164164
m_ui.MidiCaptureQuantizeComboBox->setIconSize(QSize(8, 16));

src/qtractorSessionForm.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// qtractorSessionForm.cpp
22
//
33
/****************************************************************************
4-
Copyright (C) 2005-2022, rncbc aka Rui Nuno Capela. All rights reserved.
4+
Copyright (C) 2005-2023, rncbc aka Rui Nuno Capela. All rights reserved.
55
66
This program is free software; you can redistribute it and/or
77
modify it under the terms of the GNU General Public License
@@ -75,7 +75,7 @@ qtractorSessionForm::qtractorSessionForm ( QWidget *pParent )
7575

7676
// Fill-up snap-per-beat items...
7777
const QIcon snapIcon(":/images/itemBeat.png");
78-
const QStringList& snapItems = qtractorTimeScale::snapItems(0);
78+
const QStringList& snapItems = qtractorTimeScale::snapItems();
7979
QStringListIterator snapIter(snapItems);
8080
m_ui.SnapPerBeatComboBox->clear();
8181
m_ui.SnapPerBeatComboBox->setIconSize(QSize(8, 16));

src/qtractorSessionForm.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// qtractorSessionForm.h
22
//
33
/****************************************************************************
4-
Copyright (C) 2005-2022, rncbc aka Rui Nuno Capela. All rights reserved.
4+
Copyright (C) 2005-2023, rncbc aka Rui Nuno Capela. All rights reserved.
55
66
This program is free software; you can redistribute it and/or
77
modify it under the terms of the GNU General Public License

src/qtractorSessionForm.ui

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<author>rncbc aka Rui Nuno Capela</author>
33
<comment>qtractor - An Audio/MIDI multi-track sequencer.
44

5-
Copyright (C) 2005-2022, rncbc aka Rui Nuno Capela. All rights reserved.
5+
Copyright (C) 2005-2023, rncbc aka Rui Nuno Capela. All rights reserved.
66

77
This program is free software; you can redistribute it and/or
88
modify it under the terms of the GNU General Public License

src/qtractorTimeScale.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -736,20 +736,17 @@ int qtractorTimeScale::indexFromSnap ( unsigned short iSnapPerBeat )
736736

737737

738738
// Beat divisor (snap index) text item list.
739-
QStringList qtractorTimeScale::snapItems ( int iSnap )
739+
QStringList qtractorTimeScale::snapItems (void)
740740
{
741741
QStringList items;
742742

743-
if (iSnap == 0) {
744-
items.append(QObject::tr("None"));
745-
++iSnap;
746-
}
743+
int iSnap = 0;
744+
items.append(QObject::tr("None"));
745+
++iSnap;
747746

748747
QString sPrefix = QObject::tr("Beat");
749-
if (iSnap == 1) {
750-
items.append(sPrefix);
751-
++iSnap;
752-
}
748+
items.append(sPrefix);
749+
++iSnap;
753750

754751
sPrefix += "/%1";
755752
while (iSnap < c_iSnapItemCount)

src/qtractorTimeScale.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ class qtractorTimeScale
109109
static int indexFromSnap(unsigned short iSnapPerBeat);
110110

111111
// Beat divisor (snap index) text item list.
112-
static QStringList snapItems(int iSnap = 0);
112+
static QStringList snapItems();
113113

114114
// Time scale node declaration.
115115
class Node : public qtractorList<Node>::Link

0 commit comments

Comments
 (0)