nodes: minor overhaul to functionality
The nodes now have more control over how their accelerated shaders/sample functions are run, as well as how items are popped off the value tables. This allows for various optimizations that we didn't have access to before.
This commit is contained in:
@@ -59,17 +59,23 @@ QString PanNode::Description() const
|
||||
return tr("Adjust the stereo panning of an audio source.");
|
||||
}
|
||||
|
||||
Node::Capabilities PanNode::GetCapabilities(const NodeValueDatabase &) const
|
||||
NodeValueTable PanNode::Value(NodeValueDatabase &value) const
|
||||
{
|
||||
return kSampleProcessor;
|
||||
// Create a sample job
|
||||
SampleJob job(samples_input_);
|
||||
job.InsertValue(panning_input_, value);
|
||||
|
||||
// Push it to our table
|
||||
NodeValueTable table = value.Merge();
|
||||
|
||||
if (!qIsNull(job.GetValue(samples_input_).data().toDouble())) {
|
||||
table.Push(NodeParam::kSampleJob, QVariant::fromValue(job), this);
|
||||
}
|
||||
|
||||
return table;
|
||||
}
|
||||
|
||||
NodeInput *PanNode::ProcessesSamplesFrom(const NodeValueDatabase &) const
|
||||
{
|
||||
return samples_input_;
|
||||
}
|
||||
|
||||
void PanNode::ProcessSamples(const NodeValueDatabase &values, const AudioParams ¶ms, const SampleBufferPtr input, SampleBufferPtr output, int index) const
|
||||
void PanNode::ProcessSamples(NodeValueDatabase &values, const AudioParams ¶ms, const SampleBufferPtr input, SampleBufferPtr output, int index) const
|
||||
{
|
||||
if (params.channel_count() != 2) {
|
||||
// This node currently only works for stereo audio
|
||||
|
||||
@@ -37,9 +37,9 @@ public:
|
||||
virtual QList<CategoryID> Category() const override;
|
||||
virtual QString Description() const override;
|
||||
|
||||
virtual Capabilities GetCapabilities(const NodeValueDatabase&) const override;
|
||||
virtual NodeInput* ProcessesSamplesFrom(const NodeValueDatabase &value) const override;
|
||||
virtual void ProcessSamples(const NodeValueDatabase& values, const AudioParams& params, const SampleBufferPtr input, SampleBufferPtr output, int index) const override;
|
||||
virtual NodeValueTable Value(NodeValueDatabase &value) const override;
|
||||
|
||||
virtual void ProcessSamples(NodeValueDatabase &values, const AudioParams& params, const SampleBufferPtr input, SampleBufferPtr output, int index) const override;
|
||||
|
||||
virtual void Retranslate() override;
|
||||
|
||||
|
||||
@@ -58,17 +58,21 @@ QString VolumeNode::Description() const
|
||||
return tr("Adjusts the volume of an audio source.");
|
||||
}
|
||||
|
||||
Node::Capabilities VolumeNode::GetCapabilities(const NodeValueDatabase &) const
|
||||
NodeValueTable VolumeNode::Value(NodeValueDatabase &value) const
|
||||
{
|
||||
return kSampleProcessor;
|
||||
SampleJob job(samples_input_);
|
||||
job.InsertValue(volume_input_, value);
|
||||
|
||||
NodeValueTable table = value.Merge();
|
||||
|
||||
if (qFuzzyCompare(job.GetValue(volume_input_).data().toDouble(), 1.0)) {
|
||||
table.Push(NodeParam::kSampleJob, QVariant::fromValue(job), this);
|
||||
}
|
||||
|
||||
return table;
|
||||
}
|
||||
|
||||
NodeInput *VolumeNode::ProcessesSamplesFrom(const NodeValueDatabase &) const
|
||||
{
|
||||
return samples_input_;
|
||||
}
|
||||
|
||||
void VolumeNode::ProcessSamples(const NodeValueDatabase &values, const AudioParams& params, const SampleBufferPtr input, SampleBufferPtr output, int index) const
|
||||
void VolumeNode::ProcessSamples(NodeValueDatabase &values, const AudioParams& params, const SampleBufferPtr input, SampleBufferPtr output, int index) const
|
||||
{
|
||||
float volume_val = values[volume_input_].Get(NodeParam::kFloat).toFloat();
|
||||
|
||||
@@ -83,9 +87,4 @@ void VolumeNode::Retranslate()
|
||||
volume_input_->set_name(tr("Volume"));
|
||||
}
|
||||
|
||||
NodeInput *VolumeNode::samples_input() const
|
||||
{
|
||||
return samples_input_;
|
||||
}
|
||||
|
||||
OLIVE_NAMESPACE_EXIT
|
||||
|
||||
@@ -37,13 +37,16 @@ public:
|
||||
virtual QList<CategoryID> Category() const override;
|
||||
virtual QString Description() const override;
|
||||
|
||||
virtual Capabilities GetCapabilities(const NodeValueDatabase&) const override;
|
||||
virtual NodeInput* ProcessesSamplesFrom(const NodeValueDatabase &value) const override;
|
||||
virtual void ProcessSamples(const NodeValueDatabase& values, const AudioParams& params, const SampleBufferPtr input, SampleBufferPtr output, int index) const override;
|
||||
virtual NodeValueTable Value(NodeValueDatabase &value) const override;
|
||||
|
||||
virtual void ProcessSamples(NodeValueDatabase &values, const AudioParams& params, const SampleBufferPtr input, SampleBufferPtr output, int index) const override;
|
||||
|
||||
virtual void Retranslate() override;
|
||||
|
||||
NodeInput* samples_input() const;
|
||||
NodeInput* samples_input() const
|
||||
{
|
||||
return samples_input_;
|
||||
}
|
||||
|
||||
private:
|
||||
NodeInput* samples_input_;
|
||||
|
||||
Reference in New Issue
Block a user