implemented volume and pan effects
This commit implements a structure for sample processing and two implemenations of this structure in volume and pan effects.
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
# Olive - Non-Linear Video Editor
|
||||
# Copyright (C) 2019 Olive Team
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
set(OLIVE_SOURCES
|
||||
${OLIVE_SOURCES}
|
||||
node/audio/volume/volume.h
|
||||
node/audio/volume/volume.cpp
|
||||
PARENT_SCOPE
|
||||
)
|
||||
@@ -0,0 +1,52 @@
|
||||
#include "volume.h"
|
||||
|
||||
VolumeNode::VolumeNode()
|
||||
{
|
||||
samples_input_ = new NodeInput("samples_in");
|
||||
samples_input_->set_data_type(NodeParam::kSamples);
|
||||
AddInput(samples_input_);
|
||||
|
||||
volume_input_ = new NodeInput("volume_in");
|
||||
volume_input_->set_data_type(NodeParam::kFloat);
|
||||
volume_input_->set_minimum(0);
|
||||
volume_input_->set_maximum(1);
|
||||
volume_input_->set_value_at_time(0, 1);
|
||||
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.");
|
||||
}
|
||||
|
||||
bool VolumeNode::ProcessesSamples() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void VolumeNode::ProcessSamples(const NodeValueDatabase& values, const AudioRenderingParams& params, const float* input, float* output, int index) const
|
||||
{
|
||||
float volume_val = values[volume_input_].Get(NodeParam::kFloat).toFloat();
|
||||
|
||||
output[index] = input[index] * volume_val;
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
#ifndef VOLUMENODE_H
|
||||
#define VOLUMENODE_H
|
||||
|
||||
#include "node/node.h"
|
||||
|
||||
class VolumeNode : public Node
|
||||
{
|
||||
public:
|
||||
VolumeNode();
|
||||
|
||||
virtual Node* copy() const override;
|
||||
|
||||
virtual QString Name() const override;
|
||||
virtual QString id() const override;
|
||||
virtual QString Category() const override;
|
||||
virtual QString Description() const override;
|
||||
|
||||
virtual bool ProcessesSamples() const override;
|
||||
virtual void ProcessSamples(const NodeValueDatabase& values, const AudioRenderingParams& params, const float* input, float* output, int index) const override;
|
||||
|
||||
private:
|
||||
NodeInput* samples_input_;
|
||||
NodeInput* volume_input_;
|
||||
|
||||
};
|
||||
|
||||
#endif // VOLUMENODE_H
|
||||
Reference in New Issue
Block a user