volume: implement custom value function

This commit is contained in:
itsmattkc
2022-05-09 14:56:42 -07:00
parent 7af12bda95
commit bc126ce1b7
+21 -8
View File
@@ -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