volume: implement custom value function
This commit is contained in:
@@ -63,14 +63,27 @@ QString VolumeNode::Description() const
|
||||
|
||||
void VolumeNode::Value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const
|
||||
{
|
||||
return ValueInternal(kOpMultiply,
|
||||
kPairSampleNumber,
|
||||
kSamplesInput,
|
||||
value[kSamplesInput],
|
||||
kVolumeInput,
|
||||
value[kVolumeInput],
|
||||
globals,
|
||||
table);
|
||||
Q_UNUSED(globals)
|
||||
|
||||
// Create a sample job
|
||||
SampleBuffer buffer = value[kSamplesInput].toSamples();
|
||||
|
||||
if (buffer.is_allocated()) {
|
||||
// If the input is static, we can just do it now which will be faster
|
||||
if (IsInputStatic(kVolumeInput)) {
|
||||
auto volume = value[kVolumeInput].toDouble();
|
||||
|
||||
if (!qFuzzyCompare(volume, 1.0)) {
|
||||
buffer.transform_volume(volume);
|
||||
}
|
||||
|
||||
table->Push(NodeValue::kSamples, QVariant::fromValue(buffer), this);
|
||||
} else {
|
||||
// Requires job
|
||||
SampleJob job(kSamplesInput, value);
|
||||
table->Push(NodeValue::kSamples, QVariant::fromValue(job), this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void VolumeNode::ProcessSamples(const NodeValueRow &values, const SampleBuffer &input, SampleBuffer &output, int index) const
|
||||
|
||||
Reference in New Issue
Block a user