implemented separate waveform cache
This commit is contained in:
@@ -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