Files
oak-editor/app/node/audio/volume/volume.cpp
T
itsmattkc c168bf1a80 nodeparam: implemented parameters that allow arbitrary properties to be set
for UI representations

Allows properties to be set without adding explicit extra members to NodeInputs.
Crucially this means parameters like slider value representations (percent,
decibel, etc.) can be set from NodeInputs now.
2020-03-07 01:21:36 +11:00

64 lines
1.3 KiB
C++

#include "volume.h"
VolumeNode::VolumeNode()
{
samples_input_ = new NodeInput("samples_in", NodeParam::kSamples);
AddInput(samples_input_);
volume_input_ = new NodeInput("volume_in", NodeParam::kFloat, 1);
volume_input_->set_property("min", 0.0);
volume_input_->set_property("max", 1.0);
volume_input_->set_property("view", "db");
AddInput(volume_input_);
}
Node *VolumeNode::copy() const
{
return new VolumeNode();
}
QString VolumeNode::Name() const
{
return tr("Volume");
}
QString VolumeNode::id() const
{
return "org.olivevideoeditor.Olive.volume";
}
QString VolumeNode::Category() const
{
return tr("Audio");
}
QString VolumeNode::Description() const
{
return tr("Adjusts the volume of an audio source.");
}
NodeInput *VolumeNode::ProcessesSamplesFrom() const
{
return samples_input_;
}
void VolumeNode::ProcessSamples(const NodeValueDatabase *values, const AudioRenderingParams& params, const float* input, float* output, int index) const
{
Q_UNUSED(params)
float volume_val = (*values)[volume_input_].Get(NodeParam::kFloat).toFloat();
output[index] = input[index] * volume_val;
}
void VolumeNode::Retranslate()
{
samples_input_->set_name(tr("Samples"));
volume_input_->set_name(tr("Volume"));
}
NodeInput *VolumeNode::samples_input() const
{
return samples_input_;
}