While planar audio cannot be used for playback, it's much easier for processing. This should lead to cleaner and easier to write code in the future.
68 lines
1.4 KiB
C++
68 lines
1.4 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("view", "db");
|
|
AddInput(volume_input_);
|
|
}
|
|
|
|
Node *VolumeNode::copy() const
|
|
{
|
|
return new VolumeNode();
|
|
}
|
|
|
|
QString VolumeNode::Name() const
|
|
{
|
|
return tr("Volume");
|
|
}
|
|
|
|
QString VolumeNode::id() const
|
|
{
|
|
return QStringLiteral("org.olivevideoeditor.Olive.volume");
|
|
}
|
|
|
|
QString VolumeNode::Category() const
|
|
{
|
|
return tr("Audio");
|
|
}
|
|
|
|
QString VolumeNode::Description() const
|
|
{
|
|
return tr("Adjusts the volume of an audio source.");
|
|
}
|
|
|
|
Node::Capabilities VolumeNode::GetCapabilities(const NodeValueDatabase &) const
|
|
{
|
|
return kSampleProcessor;
|
|
}
|
|
|
|
NodeInput *VolumeNode::ProcessesSamplesFrom() const
|
|
{
|
|
return samples_input_;
|
|
}
|
|
|
|
void VolumeNode::ProcessSamples(const NodeValueDatabase *values, const AudioRenderingParams& params, const SampleBufferPtr input, SampleBufferPtr output, int index) const
|
|
{
|
|
float volume_val = (*values)[volume_input_].Get(NodeParam::kFloat).toFloat();
|
|
|
|
for (int i=0;i<params.channel_count();i++) {
|
|
output->data()[i][index] = input->data()[i][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_;
|
|
}
|