waveforms: moved waveform to track rather than block

This is a much more robust and thread-safe system of storing the waveforms.
This commit is contained in:
itsmattkc
2020-06-04 18:03:21 +10:00
parent 9ff9817b95
commit 0e87762afa
19 changed files with 184 additions and 336 deletions
-7
View File
@@ -28,13 +28,6 @@ OLIVE_NAMESPACE_ENTER
/**
* @brief A Node that represents a block of time, also displayable on a Timeline
*
* This is an abstract function. Since different types of Block will provide their lengths in different ways, it's
* necessary to subclass and override the length() function for a Block to be usable.
*
* When overriding Node::copy(), the derivative class should also call Block::CopyParameters() on the new Block instance
* which will copy the block's name, length, and media in point. It does not copy any node-specific parameters like any
* input values or connections as per standard with Node::copy().
*/
class Block : public Node
{
-20
View File
@@ -59,26 +59,6 @@ NodeInput *ClipBlock::texture_input() const
return texture_input_;
}
void ClipBlock::LengthChangedEvent(const rational &old_length, const rational &new_length, const Timeline::MovementMode &mode)
{
// Positive if made longer, negative if made shorter
rational diff = new_length - old_length;
if (diff < rational()) {
if (mode == Timeline::kTrimIn) {
waveform().TrimIn(-diff);
} else {
waveform().TrimOut(-diff);
}
} else {
if (mode == Timeline::kTrimIn) {
waveform().PrependSilence(diff);
} else {
waveform().AppendSilence(diff);
}
}
}
void ClipBlock::InvalidateCache(const TimeRange &range, NodeInput *from, NodeInput *source)
{
// If signal is from texture input, transform all times from media time to sequence time
-23
View File
@@ -21,7 +21,6 @@
#ifndef CLIPBLOCK_H
#define CLIPBLOCK_H
#include "audio/audiovisualwaveform.h"
#include "node/block/block.h"
OLIVE_NAMESPACE_ENTER
@@ -57,31 +56,9 @@ public:
virtual void Hash(QCryptographicHash &hash, const rational &time) const override;
AudioVisualWaveform& waveform()
{
return waveform_;
}
void set_waveform(const AudioVisualWaveform& wave)
{
waveform_ = wave;
emit PreviewUpdated();
}
signals:
void PreviewUpdated();
protected:
virtual void LengthChangedEvent(const rational& old_length,
const rational& new_length,
const Timeline::MovementMode& mode) override;
private:
NodeInput* texture_input_;
AudioVisualWaveform waveform_;
};
OLIVE_NAMESPACE_EXIT
+2 -7
View File
@@ -63,12 +63,7 @@ const Timeline::TrackType& TrackOutput::track_type() const
return track_type_;
}
Block::Type TrackOutput::type() const
{
return kClip;
}
Block *TrackOutput::copy() const
Node *TrackOutput::copy() const
{
return new TrackOutput();
}
@@ -116,7 +111,7 @@ void TrackOutput::SetTrackHeight(const int &height)
void TrackOutput::Retranslate()
{
Block::Retranslate();
Node::Retranslate();
block_input_->set_name(tr("Blocks"));
muted_input_->set_name(tr("Muted"));
+15 -4
View File
@@ -21,6 +21,7 @@
#ifndef TRACKOUTPUT_H
#define TRACKOUTPUT_H
#include "audio/audiovisualwaveform.h"
#include "node/block/block.h"
#include "timeline/timelinecommon.h"
@@ -29,7 +30,7 @@ OLIVE_NAMESPACE_ENTER
/**
* @brief A time traversal Node for sorting through one channel/track of Blocks
*/
class TrackOutput : public Block
class TrackOutput : public Node
{
Q_OBJECT
public:
@@ -38,9 +39,7 @@ public:
const Timeline::TrackType& track_type() const;
void set_track_type(const Timeline::TrackType& track_type);
virtual Type type() const override;
virtual Block* copy() const override;
virtual Node* copy() const override;
virtual QString Name() const override;
virtual QString id() const override;
@@ -195,6 +194,11 @@ public:
void PushLengthChangeSignal();
AudioVisualWaveform& waveform()
{
return waveform_;
}
public slots:
void SetTrackName(const QString& name);
@@ -233,6 +237,11 @@ signals:
*/
void IndexChanged(int i);
/**
* @brief Signal emitted when preview (waveform) has changed and UI should be updated
*/
void PreviewChanged();
protected:
private:
@@ -266,6 +275,8 @@ private:
bool queued_length_change_;
rational queued_length_;
AudioVisualWaveform waveform_;
private slots:
void BlockConnected(NodeEdgePtr edge);