precision audio playback

This commit is contained in:
itsmattkc
2018-11-11 13:00:03 +11:00
parent 39fe0f726b
commit 5850f8bb59
13 changed files with 125 additions and 19 deletions
+22 -6
View File
@@ -64,7 +64,8 @@ Timeline::Timeline(QWidget *parent) :
transition_tool_clip(-1),
transition_tool_init(false),
transition_tool_proc(false),
move_insert(false)
move_insert(false),
showing_all(false)
{
default_track_height = (QGuiApplication::primaryScreen()->logicalDotsPerInch() / 96) * TRACK_DEFAULT_HEIGHT;
@@ -145,6 +146,16 @@ void Timeline::next_cut() {
if (seek_enabled) panel_sequence_viewer->seek(n_cut);
}
void Timeline::toggle_show_all() {
showing_all = !showing_all;
if (showing_all) {
old_zoom = zoom;
set_zoom_value((double) (ui->timeline_area->width() - 200) / (double) sequence->getEndFrame());
} else {
set_zoom_value(old_zoom);
}
}
int Timeline::get_track_height_size(bool video) {
if (video) {
return video_track_heights.size();
@@ -345,14 +356,19 @@ int lerp(int a, int b, double t) {
return ((1.0 - t) * a) + (t * b);
}
void Timeline::set_zoom(bool in) {
zoom *= (in) ? 2 : 0.5;
void Timeline::set_zoom_value(double v) {
zoom = v;
ui->headers->update_zoom(zoom);
repaint_timeline();
// TODO find a way to gradually move towards target_scroll instead of just setting it?
int target_scroll = getScreenPointFromFrame(zoom, sequence->playhead)-(ui->editAreas->width()>>1);
ui->horizontalScrollBar->setValue(target_scroll);
// TODO find a way to gradually move towards target_scroll instead of just setting it?
int target_scroll = getScreenPointFromFrame(zoom, sequence->playhead)-(ui->editAreas->width()>>1);
ui->horizontalScrollBar->setValue(target_scroll);
}
void Timeline::set_zoom(bool in) {
showing_all = false;
set_zoom_value(zoom * ((in) ? 2 : 0.5));
}
void Timeline::decheck_tool_buttons(QObject* sender) {
+4
View File
@@ -97,6 +97,7 @@ public:
void delete_in_out(bool ripple);
void previous_cut();
void next_cut();
void toggle_show_all();
int getTimelineScreenPointFromFrame(long frame);
long getTimelineFrameFromScreenPoint(int x);
@@ -116,6 +117,8 @@ public:
long drag_frame_start;
int drag_track_start;
void update_effect_controls();
bool showing_all;
double old_zoom;
QVector<int> video_track_heights;
QVector<int> audio_track_heights;
@@ -216,6 +219,7 @@ private slots:
void transition_menu_select(QAction*);
private:
void set_zoom_value(double v);
QVector<QPushButton*> tool_buttons;
void decheck_tool_buttons(QObject* sender);
void set_tool(int tool);
+18 -6
View File
@@ -35,7 +35,8 @@ Viewer::Viewer(QWidget *parent) :
seq(NULL),
playing(false),
created_sequence(false),
cue_recording_internal(false)
cue_recording_internal(false),
just_played(false)
{
ui->setupUi(this);
ui->headers->viewer = this;
@@ -283,17 +284,26 @@ void Viewer::play() {
return;
}
playhead_start = seq->playhead;
start_msecs = QDateTime::currentMSecsSinceEpoch();
playing = true;
just_played = true;
set_playpause_icon(false);
playback_updater.start();
start_msecs = QDateTime::currentMSecsSinceEpoch();
timer_update();
audio_thread->notifyReceiver();
}
}
void Viewer::play_wake() {
if (just_played) {
start_msecs = QDateTime::currentMSecsSinceEpoch();
playback_updater.start();
audio_thread->notifyReceiver();
just_played = false;
}
}
void Viewer::pause() {
playing = false;
just_played = false;
set_playpause_icon(true);
playback_updater.stop();
@@ -394,8 +404,10 @@ void Viewer::set_media(int type, void* media) {
seq->name = footage->name;
seq->using_workarea = footage->using_inout;
seq->workarea_in = footage->in;
seq->workarea_out = footage->out;
if (footage->using_inout) {
seq->workarea_in = footage->in;
seq->workarea_out = footage->out;
}
seq->frame_rate = 30;
+2
View File
@@ -50,6 +50,7 @@ public:
long playhead_start;
qint64 start_msecs;
QTimer playback_updater;
bool just_played;
void cue_recording(long start, long end, int track);
void uncue_recording();
@@ -69,6 +70,7 @@ public:
Ui::Viewer *ui;
public slots:
void play_wake();
private slots:
void on_pushButton_clicked();