Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pitch compensation for speed change. #828

Merged
merged 1 commit into from Feb 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
36 changes: 34 additions & 2 deletions src/widgets/avformatproducerwidget.cpp
Expand Up @@ -123,8 +123,12 @@ Mlt::Producer* AvformatProducerWidget::newProducer(Mlt::Profile& profile)
p = new Mlt::Producer(profile, s.toUtf8().constData());
p->set(kShotcutProducerProperty, "avformat");
}
if (p->is_valid())
if (p->is_valid()) {
p->set("video_delay", double(ui->syncSlider->value()) / 1000);
if (ui->pitchCheckBox->checkState() == Qt::Checked) {
m_producer->set("warp_pitch", 1);
}
}
return p;
}

Expand Down Expand Up @@ -223,7 +227,7 @@ void AvformatProducerWidget::recreateProducer()
{
Mlt::Producer* p = newProducer(MLT.profile());
p->pass_list(*m_producer, "audio_index, video_index, force_aspect_ratio,"
"video_delay, force_progressive, force_tff, set.force_full_luma, color_range,"
"video_delay, force_progressive, force_tff, set.force_full_luma, color_range, warp_pitch,"
kAspectRatioNumerator ","
kAspectRatioDenominator ","
kShotcutHashProperty ","
Expand Down Expand Up @@ -275,6 +279,16 @@ void AvformatProducerWidget::onFrameDecoded()
ui->durationSpinBox->setValue(m_producer->get_length());
m_recalcDuration = false;
ui->speedSpinBox->setValue(warpSpeed);
if (warpSpeed == 1.0) {
ui->pitchCheckBox->setEnabled(false);
} else {
ui->pitchCheckBox->setEnabled(true);
}
if (m_producer->get_int("warp_pitch") == 1) {
ui->pitchCheckBox->setCheckState(Qt::Checked);
} else {
ui->pitchCheckBox->setCheckState(Qt::Unchecked);
}
ui->rangeComboBox->setEnabled(true);

// populate the track combos
Expand Down Expand Up @@ -508,6 +522,7 @@ void AvformatProducerWidget::onFrameDecoded()
void AvformatProducerWidget::on_resetButton_clicked()
{
ui->speedSpinBox->setValue(1.0);
ui->pitchCheckBox->setCheckState(Qt::Unchecked);
Mlt::Producer* p = newProducer(MLT.profile());
ui->durationSpinBox->setValue(m_defaultDuration);
ui->syncSlider->setValue(0);
Expand Down Expand Up @@ -607,10 +622,27 @@ void AvformatProducerWidget::on_speedSpinBox_editingFinished()
return;
if (ui->speedSpinBox->value() == GetSpeedFromProducer(producer()))
return;
if (ui->speedSpinBox->value() == 1.0) {
ui->pitchCheckBox->setEnabled(false);
} else {
ui->pitchCheckBox->setEnabled(true);
}
m_recalcDuration = true;
recreateProducer();
}

void AvformatProducerWidget::on_pitchCheckBox_stateChanged(int state)
{
if (!m_producer)
return;
if (state == Qt::Unchecked) {
m_producer->set("warp_pitch", 0);
} else {
m_producer->set("warp_pitch", 1);
}
emit modified();
}

void AvformatProducerWidget::on_syncSlider_valueChanged(int value)
{
double delay = double(value) / 1000.0;
Expand Down
2 changes: 2 additions & 0 deletions src/widgets/avformatproducerwidget.h
Expand Up @@ -73,6 +73,8 @@ private slots:

void on_speedSpinBox_editingFinished();

void on_pitchCheckBox_stateChanged(int state);

void on_syncSlider_valueChanged(int value);

void on_actionOpenFolder_triggered();
Expand Down
52 changes: 31 additions & 21 deletions src/widgets/avformatproducerwidget.ui
Expand Up @@ -48,8 +48,8 @@
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<layout class="QGridLayout" name="gridLayout_1">
<item row="0" column="0">
<widget class="QLabel" name="speedLabel">
<property name="text">
<string>Speed</string>
Expand All @@ -59,7 +59,7 @@
</property>
</widget>
</item>
<item>
<item row="0" column="1">
<widget class="QDoubleSpinBox" name="speedSpinBox">
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
Expand Down Expand Up @@ -93,7 +93,17 @@
</property>
</widget>
</item>
<item>
<item row="0" column="2">
<widget class="QCheckBox" name="pitchCheckBox">
<property name="text">
<string>Pitch Compensation</string>
</property>
<property name="toolTip">
<string>Apply pitch compensation when the speed is changed.</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="durationLabel">
<property name="text">
<string>Duration</string>
Expand All @@ -103,7 +113,7 @@
</property>
</widget>
</item>
<item>
<item row="1" column="1">
<widget class="TimeSpinBox" name="durationSpinBox">
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
Expand All @@ -122,8 +132,8 @@
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_4">
<item row="1" column="2">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
Expand All @@ -146,7 +156,7 @@
<attribute name="title">
<string>Video</string>
</attribute>
<layout class="QGridLayout" name="gridLayout">
<layout class="QGridLayout" name="gridLayout_2">
<item row="5" column="0" colspan="3">
<spacer name="verticalSpacer_3">
<property name="orientation">
Expand Down Expand Up @@ -293,7 +303,7 @@
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
Expand All @@ -318,7 +328,7 @@
</widget>
</item>
<item row="0" column="0" colspan="3">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="trackLabel">
<property name="text">
Expand All @@ -337,7 +347,7 @@
</widget>
</item>
<item>
<spacer name="horizontalSpacer_5">
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
Expand All @@ -352,7 +362,7 @@
</layout>
</item>
<item row="2" column="2">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QSpinBox" name="aspectNumSpinBox">
<property name="alignment">
Expand Down Expand Up @@ -414,7 +424,7 @@
</layout>
</item>
<item row="3" column="2">
<layout class="QHBoxLayout" name="horizontalLayout_9">
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
<widget class="QComboBox" name="scanComboBox">
<item>
Expand Down Expand Up @@ -444,7 +454,7 @@
</widget>
</item>
<item>
<spacer name="horizontalSpacer_9">
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
Expand All @@ -464,7 +474,7 @@
<attribute name="title">
<string>Audio</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_2">
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QLabel" name="trackLabel_2">
<property name="text">
Expand All @@ -476,12 +486,12 @@
</widget>
</item>
<item row="0" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_8">
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QComboBox" name="audioTrackComboBox"/>
</item>
<item>
<spacer name="horizontalSpacer_7">
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
Expand Down Expand Up @@ -634,9 +644,9 @@
</widget>
</item>
<item row="3" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<spacer name="horizontalSpacer_6">
<spacer name="horizontalSpacer_7">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
Expand Down Expand Up @@ -729,7 +739,7 @@
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<layout class="QHBoxLayout" name="horizontalLayout_8">
<item>
<widget class="QPushButton" name="resetButton">
<property name="text">
Expand Down Expand Up @@ -759,7 +769,7 @@
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<spacer name="horizontalSpacer_9">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
Expand Down