implemented separate waveform cache
This commit is contained in:
@@ -93,11 +93,12 @@ void AudioMonitor::PushSampleBuffer(const SampleBuffer &d)
|
||||
SetUpdateLoop(true);
|
||||
}
|
||||
|
||||
void AudioMonitor::StartWaveform(const AudioVisualWaveform *waveform, const rational &start, int playback_speed)
|
||||
void AudioMonitor::StartWaveform(const AudioWaveformCache *waveform, const rational &start, int playback_speed)
|
||||
{
|
||||
Stop();
|
||||
|
||||
if (start >= waveform->length()) {
|
||||
waveform_length_ = waveform->length();
|
||||
if (start >= waveform_length_) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -239,7 +240,7 @@ void AudioMonitor::paintGL()
|
||||
if (waveform_) {
|
||||
UpdateValuesFromWaveform(v, delta_time);
|
||||
|
||||
if (waveform_time_ >= waveform_->length()) {
|
||||
if (waveform_time_ >= waveform_length_) {
|
||||
Stop();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
#include "audio/audiovisualwaveform.h"
|
||||
#include "common/define.h"
|
||||
#include "render/audioparams.h"
|
||||
#include "render/audioplaybackcache.h"
|
||||
#include "render/audiowaveformcache.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
@@ -45,7 +45,7 @@ public:
|
||||
return waveform_;
|
||||
}
|
||||
|
||||
static void StartWaveformOnAll(const AudioVisualWaveform *waveform, const rational& start, int playback_speed)
|
||||
static void StartWaveformOnAll(const AudioWaveformCache *waveform, const rational& start, int playback_speed)
|
||||
{
|
||||
foreach (AudioMonitor *m, instances_) {
|
||||
m->StartWaveform(waveform, start, playback_speed);
|
||||
@@ -73,7 +73,7 @@ public slots:
|
||||
|
||||
void PushSampleBuffer(const SampleBuffer &samples);
|
||||
|
||||
void StartWaveform(const AudioVisualWaveform *waveform, const rational& start, int playback_speed);
|
||||
void StartWaveform(const AudioWaveformCache *waveform, const rational& start, int playback_speed);
|
||||
|
||||
protected:
|
||||
virtual void paintGL() override;
|
||||
@@ -97,8 +97,9 @@ private:
|
||||
|
||||
qint64 last_time_;
|
||||
|
||||
const AudioVisualWaveform* waveform_;
|
||||
const AudioWaveformCache* waveform_;
|
||||
rational waveform_time_;
|
||||
rational waveform_length_;
|
||||
|
||||
int playback_speed_;
|
||||
|
||||
|
||||
@@ -699,7 +699,8 @@ void PointerTool::FinishDrag(TimelineViewMouseEvent *event)
|
||||
// Place the copy instead of the original block
|
||||
block = static_cast<Block*>(Node::CopyNodeInGraph(block, command));
|
||||
if (ClipBlock *new_clip = dynamic_cast<ClipBlock*>(block)) {
|
||||
new_clip->set_waveform(static_cast<ClipBlock*>(p.block)->waveform());
|
||||
qDebug() << "FIXME: Copy clip stub"; Q_UNUSED(new_clip)
|
||||
//new_clip->set_waveform(static_cast<ClipBlock*>(p.block)->waveform());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,10 @@ void BlockSplitCommand::redo()
|
||||
|
||||
if (ClipBlock *new_clip = dynamic_cast<ClipBlock*>(new_block_)) {
|
||||
ClipBlock *old_clip = static_cast<ClipBlock*>(block_);
|
||||
new_clip->set_waveform(old_clip->waveform());
|
||||
qDebug() << "FIXME: Copy waveform stub";
|
||||
Q_UNUSED(old_clip)
|
||||
Q_UNUSED(new_clip)
|
||||
//new_clip->set_waveform(old_clip->waveform());
|
||||
}
|
||||
|
||||
// Determine our new lengths
|
||||
|
||||
@@ -558,11 +558,11 @@ void TimelineView::DrawBlock(QPainter *painter, bool foreground, Block *block, q
|
||||
|
||||
// Draw waveform
|
||||
if (clip->GetTrackType() == Track::kAudio && show_waveforms_) {
|
||||
if (const AudioVisualWaveform *wave = clip->waveform()) {
|
||||
if (const AudioWaveformCache *wave = clip->waveform()) {
|
||||
rational waveform_start = SceneToTime(block_left - block_in, GetScale(), connected_track_list_->parent()->GetAudioParams().sample_rate_as_time_base()) + media_in;
|
||||
painter->setPen(shadow_color);
|
||||
|
||||
AudioVisualWaveform::DrawWaveform(painter, preview_rect, this->GetScale(), *wave, waveform_start);
|
||||
wave->Draw(painter, preview_rect, this->GetScale(), waveform_start);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -47,13 +47,13 @@ AudioWaveformView::AudioWaveformView(QWidget *parent) :
|
||||
setAlignment(Qt::AlignLeft | Qt::AlignTop);
|
||||
}
|
||||
|
||||
void AudioWaveformView::SetViewer(AudioPlaybackCache *playback)
|
||||
void AudioWaveformView::SetViewer(ViewerOutput *playback)
|
||||
{
|
||||
if (playback_) {
|
||||
pool_.clear();
|
||||
pool_.waitForDone();
|
||||
|
||||
disconnect(playback_, &AudioPlaybackCache::Validated, this, static_cast<void(AudioWaveformView::*)()>(&AudioWaveformView::update));
|
||||
disconnect(playback_, &ViewerOutput::ConnectedWaveformChanged, this, static_cast<void(AudioWaveformView::*)()>(&AudioWaveformView::update));
|
||||
|
||||
SetTimebase(0);
|
||||
}
|
||||
@@ -61,9 +61,9 @@ void AudioWaveformView::SetViewer(AudioPlaybackCache *playback)
|
||||
playback_ = playback;
|
||||
|
||||
if (playback_) {
|
||||
connect(playback_, &AudioPlaybackCache::Validated, this, static_cast<void(AudioWaveformView::*)()>(&AudioWaveformView::update));
|
||||
connect(playback_, &ViewerOutput::ConnectedWaveformChanged, this, static_cast<void(AudioWaveformView::*)()>(&AudioWaveformView::update));
|
||||
|
||||
SetTimebase(playback_->GetParameters().sample_rate_as_time_base());
|
||||
SetTimebase(playback_->GetAudioParams().sample_rate_as_time_base());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,8 +75,12 @@ void AudioWaveformView::drawForeground(QPainter *p, const QRectF &rect)
|
||||
return;
|
||||
}
|
||||
|
||||
const AudioParams& params = playback_->GetParameters();
|
||||
const AudioWaveformCache *wave = playback_->GetConnectedWaveform();
|
||||
if (!wave) {
|
||||
return;
|
||||
}
|
||||
|
||||
const AudioParams& params = wave->GetParameters();
|
||||
if (!params.is_valid()) {
|
||||
return;
|
||||
}
|
||||
@@ -86,7 +90,7 @@ void AudioWaveformView::drawForeground(QPainter *p, const QRectF &rect)
|
||||
|
||||
// Draw waveform
|
||||
p->setPen(QColor(64, 255, 160)); // FIXME: Hardcoded color
|
||||
AudioVisualWaveform::DrawWaveform(p, rect.toRect(), GetScale(), playback_->visual(), SceneToTime(GetScroll()));
|
||||
wave->Draw(p, rect.toRect(), GetScale(), SceneToTime(GetScroll()));
|
||||
|
||||
// Draw playhead
|
||||
p->setPen(PLAYHEAD_COLOR);
|
||||
|
||||
@@ -36,7 +36,7 @@ class AudioWaveformView : public SeekableWidget
|
||||
public:
|
||||
AudioWaveformView(QWidget* parent = nullptr);
|
||||
|
||||
void SetViewer(AudioPlaybackCache *playback);
|
||||
void SetViewer(ViewerOutput *playback);
|
||||
|
||||
protected:
|
||||
virtual void drawForeground(QPainter *painter, const QRectF &rect) override;
|
||||
@@ -44,7 +44,7 @@ protected:
|
||||
private:
|
||||
QThreadPool pool_;
|
||||
|
||||
AudioPlaybackCache *playback_;
|
||||
ViewerOutput *playback_;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -232,7 +232,7 @@ void ViewerWidget::ConnectNodeEvent(ViewerOutput *n)
|
||||
|
||||
UpdateStack();
|
||||
|
||||
waveform_view_->SetViewer(GetConnectedNode()->audio_playback_cache());
|
||||
waveform_view_->SetViewer(GetConnectedNode());
|
||||
waveform_view_->ConnectTimelinePoints(GetConnectedNode()->GetTimelinePoints());
|
||||
|
||||
UpdateRendererVideoParameters();
|
||||
@@ -947,7 +947,7 @@ void ViewerWidget::FinishPlayPreprocess()
|
||||
}
|
||||
prequeued_audio_.clear();
|
||||
|
||||
AudioMonitor::StartWaveformOnAll(&GetConnectedNode()->audio_playback_cache()->visual(),
|
||||
AudioMonitor::StartWaveformOnAll(GetConnectedNode()->GetConnectedWaveform(),
|
||||
GetTime(), playback_speed_);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user