added speed changes while maintaining audio pitch
This commit is contained in:
@@ -43,9 +43,12 @@ SpeedDialog::SpeedDialog(QWidget *parent) : QDialog(parent) {
|
||||
main_layout->addLayout(grid);
|
||||
|
||||
reverse = new QCheckBox("Reverse");
|
||||
maintain_pitch = new QCheckBox("Maintain Audio Pitch");
|
||||
ripple = new QCheckBox("Ripple Changes");
|
||||
|
||||
main_layout->addWidget(reverse);
|
||||
main_layout->addWidget(new QCheckBox("Maintain Audio Pitch"));
|
||||
main_layout->addWidget(new QCheckBox("Ripple"));
|
||||
main_layout->addWidget(maintain_pitch);
|
||||
main_layout->addWidget(ripple);
|
||||
|
||||
QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||
buttonBox->setCenterButtons(true);
|
||||
@@ -179,6 +182,8 @@ void SpeedDialog::accept() {
|
||||
c->timeline_out = proposed_out;
|
||||
|
||||
c->recalculateMaxLength();
|
||||
|
||||
c->maintain_audio_pitch = maintain_pitch->isChecked();
|
||||
}
|
||||
panel_timeline->redraw_all_clips(true);
|
||||
QDialog::accept();
|
||||
|
||||
@@ -26,6 +26,8 @@ private:
|
||||
LabelSlider* frame_rate;
|
||||
|
||||
QCheckBox* reverse;
|
||||
QCheckBox* maintain_pitch;
|
||||
QCheckBox* ripple;
|
||||
|
||||
double default_frame_rate;
|
||||
double current_frame_rate;
|
||||
|
||||
+18
-3
@@ -490,13 +490,28 @@ void open_clip_worker(Clip* clip) {
|
||||
qDebug() << "[ERROR] Could not set output sample format";
|
||||
}
|
||||
|
||||
int sample_rates[] = { qRound(sequence->audio_frequency / clip->speed), 0 };
|
||||
int target_sample_rate = sequence->audio_frequency;
|
||||
|
||||
if (qFuzzyCompare(clip->speed, 1.0)) {
|
||||
avfilter_link(clip->buffersrc_ctx, 0, clip->buffersink_ctx, 0);
|
||||
} else if (clip->maintain_audio_pitch) {
|
||||
char speed_param[10];
|
||||
snprintf(speed_param, sizeof(speed_param), "%f", clip->speed);
|
||||
|
||||
AVFilterContext* tempo_filter;
|
||||
avfilter_graph_create_filter(&tempo_filter, avfilter_get_by_name("atempo"), "atempo", speed_param, NULL, clip->filter_graph);
|
||||
avfilter_link(clip->buffersrc_ctx, 0, tempo_filter, 0);
|
||||
avfilter_link(tempo_filter, 0, clip->buffersink_ctx, 0);
|
||||
} else {
|
||||
target_sample_rate = qRound(sequence->audio_frequency / clip->speed);
|
||||
avfilter_link(clip->buffersrc_ctx, 0, clip->buffersink_ctx, 0);
|
||||
}
|
||||
|
||||
int sample_rates[] = { target_sample_rate, 0 };
|
||||
if (av_opt_set_int_list(clip->buffersink_ctx, "sample_rates", sample_rates, 0, AV_OPT_SEARCH_CHILDREN) < 0) {
|
||||
qDebug() << "[ERROR] Could not set output sample rates";
|
||||
}
|
||||
|
||||
avfilter_link(clip->buffersrc_ctx, 0, clip->buffersink_ctx, 0);
|
||||
|
||||
avfilter_graph_config(clip->filter_graph, NULL);
|
||||
|
||||
clip->audio_reset = true;
|
||||
|
||||
+2
-1
@@ -33,7 +33,8 @@ Clip::Clip(Sequence* s) :
|
||||
filter_graph(NULL),
|
||||
texture(NULL),
|
||||
fbo(NULL),
|
||||
autoscale(config.autoscale_by_default)
|
||||
autoscale(config.autoscale_by_default),
|
||||
maintain_audio_pitch(false)
|
||||
{
|
||||
reset();
|
||||
}
|
||||
|
||||
+2
-2
@@ -116,8 +116,8 @@ struct Clip
|
||||
long texture_frame;
|
||||
bool autoscale;
|
||||
|
||||
// audio playback variables
|
||||
// SwrContext* swr_ctx;
|
||||
// audio playback variables
|
||||
bool maintain_audio_pitch;
|
||||
int frame_sample_index;
|
||||
int audio_buffer_write;
|
||||
bool audio_reset;
|
||||
|
||||
Reference in New Issue
Block a user