change: change code style to Linux style except indent.
This commit is contained in:
+61
-51
@@ -22,7 +22,8 @@
|
||||
|
||||
#include "widget/slider/floatslider.h"
|
||||
|
||||
namespace olive {
|
||||
namespace olive
|
||||
{
|
||||
|
||||
const QString PanNode::kSamplesInput = QStringLiteral("samples_in");
|
||||
const QString PanNode::kPanningInput = QStringLiteral("panning_in");
|
||||
@@ -31,88 +32,97 @@ const QString PanNode::kPanningInput = QStringLiteral("panning_in");
|
||||
|
||||
PanNode::PanNode()
|
||||
{
|
||||
AddInput(kSamplesInput, NodeValue::kSamples, InputFlags(kInputFlagNotKeyframable));
|
||||
AddInput(kSamplesInput, NodeValue::kSamples,
|
||||
InputFlags(kInputFlagNotKeyframable));
|
||||
|
||||
AddInput(kPanningInput, NodeValue::kFloat, 0.0);
|
||||
SetInputProperty(kPanningInput, QStringLiteral("min"), -1.0);
|
||||
SetInputProperty(kPanningInput, QStringLiteral("max"), 1.0);
|
||||
SetInputProperty(kPanningInput, QStringLiteral("view"), FloatSlider::kPercentage);
|
||||
AddInput(kPanningInput, NodeValue::kFloat, 0.0);
|
||||
SetInputProperty(kPanningInput, QStringLiteral("min"), -1.0);
|
||||
SetInputProperty(kPanningInput, QStringLiteral("max"), 1.0);
|
||||
SetInputProperty(kPanningInput, QStringLiteral("view"),
|
||||
FloatSlider::kPercentage);
|
||||
|
||||
SetFlag(kAudioEffect);
|
||||
SetEffectInput(kSamplesInput);
|
||||
SetFlag(kAudioEffect);
|
||||
SetEffectInput(kSamplesInput);
|
||||
}
|
||||
|
||||
QString PanNode::Name() const
|
||||
{
|
||||
return tr("Pan");
|
||||
return tr("Pan");
|
||||
}
|
||||
|
||||
QString PanNode::id() const
|
||||
{
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.pan");
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.pan");
|
||||
}
|
||||
|
||||
QVector<Node::CategoryID> PanNode::Category() const
|
||||
{
|
||||
return {kCategoryFilter};
|
||||
return { kCategoryFilter };
|
||||
}
|
||||
|
||||
QString PanNode::Description() const
|
||||
{
|
||||
return tr("Adjust the stereo panning of an audio source.");
|
||||
return tr("Adjust the stereo panning of an audio source.");
|
||||
}
|
||||
|
||||
void PanNode::Value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const
|
||||
void PanNode::Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const
|
||||
{
|
||||
// Create a sample job
|
||||
SampleBuffer samples = value[kSamplesInput].toSamples();
|
||||
if (samples.is_allocated()) {
|
||||
// This node is only compatible with stereo audio
|
||||
if (samples.audio_params().channel_count() == 2) {
|
||||
// If the input is static, we can just do it now which will be faster
|
||||
if (IsInputStatic(kPanningInput)) {
|
||||
float pan_volume = value[kPanningInput].toDouble();
|
||||
if (!qIsNull(pan_volume)) {
|
||||
if (pan_volume > 0) {
|
||||
samples.transform_volume_for_channel(0, 1.0f - pan_volume);
|
||||
} else {
|
||||
samples.transform_volume_for_channel(1, 1.0f + pan_volume);
|
||||
}
|
||||
}
|
||||
// Create a sample job
|
||||
SampleBuffer samples = value[kSamplesInput].toSamples();
|
||||
if (samples.is_allocated()) {
|
||||
// This node is only compatible with stereo audio
|
||||
if (samples.audio_params().channel_count() == 2) {
|
||||
// If the input is static, we can just do it now which will be faster
|
||||
if (IsInputStatic(kPanningInput)) {
|
||||
float pan_volume = value[kPanningInput].toDouble();
|
||||
if (!qIsNull(pan_volume)) {
|
||||
if (pan_volume > 0) {
|
||||
samples.transform_volume_for_channel(0,
|
||||
1.0f - pan_volume);
|
||||
} else {
|
||||
samples.transform_volume_for_channel(1,
|
||||
1.0f + pan_volume);
|
||||
}
|
||||
}
|
||||
|
||||
table->Push(NodeValue(NodeValue::kSamples, samples, this));
|
||||
} else {
|
||||
// Requires job
|
||||
table->Push(NodeValue::kSamples, SampleJob(globals.time(), kSamplesInput, value), this);
|
||||
}
|
||||
} else {
|
||||
// Pass right through
|
||||
table->Push(value[kSamplesInput]);
|
||||
}
|
||||
}
|
||||
table->Push(NodeValue(NodeValue::kSamples, samples, this));
|
||||
} else {
|
||||
// Requires job
|
||||
table->Push(NodeValue::kSamples,
|
||||
SampleJob(globals.time(), kSamplesInput, value),
|
||||
this);
|
||||
}
|
||||
} else {
|
||||
// Pass right through
|
||||
table->Push(value[kSamplesInput]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PanNode::ProcessSamples(const NodeValueRow &values, const SampleBuffer &input, SampleBuffer &output, int index) const
|
||||
void PanNode::ProcessSamples(const NodeValueRow &values,
|
||||
const SampleBuffer &input, SampleBuffer &output,
|
||||
int index) const
|
||||
{
|
||||
float pan_val = values[kPanningInput].toDouble();
|
||||
float pan_val = values[kPanningInput].toDouble();
|
||||
|
||||
for (int i=0;i<input.audio_params().channel_count();i++) {
|
||||
output.data(i)[index] = input.data(i)[index];
|
||||
}
|
||||
for (int i = 0; i < input.audio_params().channel_count(); i++) {
|
||||
output.data(i)[index] = input.data(i)[index];
|
||||
}
|
||||
|
||||
if (pan_val > 0) {
|
||||
output.data(0)[index] *= (1.0F - pan_val);
|
||||
} else if (pan_val < 0) {
|
||||
output.data(1)[index] *= (1.0F - qAbs(pan_val));
|
||||
}
|
||||
if (pan_val > 0) {
|
||||
output.data(0)[index] *= (1.0F - pan_val);
|
||||
} else if (pan_val < 0) {
|
||||
output.data(1)[index] *= (1.0F - qAbs(pan_val));
|
||||
}
|
||||
}
|
||||
|
||||
void PanNode::Retranslate()
|
||||
{
|
||||
super::Retranslate();
|
||||
super::Retranslate();
|
||||
|
||||
SetInputName(kSamplesInput, tr("Samples"));
|
||||
SetInputName(kPanningInput, tr("Pan"));
|
||||
SetInputName(kSamplesInput, tr("Samples"));
|
||||
SetInputName(kPanningInput, tr("Pan"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+20
-18
@@ -23,34 +23,36 @@
|
||||
|
||||
#include "node/node.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
class PanNode : public Node
|
||||
namespace olive
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
class PanNode : public Node {
|
||||
Q_OBJECT
|
||||
public:
|
||||
PanNode();
|
||||
PanNode();
|
||||
|
||||
NODE_DEFAULT_FUNCTIONS(PanNode)
|
||||
NODE_DEFAULT_FUNCTIONS(PanNode)
|
||||
|
||||
virtual QString Name() const override;
|
||||
virtual QString id() const override;
|
||||
virtual QVector<CategoryID> Category() const override;
|
||||
virtual QString Description() const override;
|
||||
virtual QString Name() const override;
|
||||
virtual QString id() const override;
|
||||
virtual QVector<CategoryID> Category() const override;
|
||||
virtual QString Description() const override;
|
||||
|
||||
virtual void Value(const NodeValueRow& value, const NodeGlobals &globals, NodeValueTable *table) const override;
|
||||
virtual void Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const override;
|
||||
|
||||
virtual void ProcessSamples(const NodeValueRow &values, const SampleBuffer &input, SampleBuffer &output, int index) const override;
|
||||
virtual void ProcessSamples(const NodeValueRow &values,
|
||||
const SampleBuffer &input, SampleBuffer &output,
|
||||
int index) const override;
|
||||
|
||||
virtual void Retranslate() override;
|
||||
virtual void Retranslate() override;
|
||||
|
||||
static const QString kSamplesInput;
|
||||
static const QString kPanningInput;
|
||||
static const QString kSamplesInput;
|
||||
static const QString kPanningInput;
|
||||
|
||||
private:
|
||||
NodeInput* samples_input_;
|
||||
NodeInput* panning_input_;
|
||||
|
||||
NodeInput *samples_input_;
|
||||
NodeInput *panning_input_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -22,7 +22,8 @@
|
||||
|
||||
#include "widget/slider/floatslider.h"
|
||||
|
||||
namespace olive {
|
||||
namespace olive
|
||||
{
|
||||
|
||||
const QString VolumeNode::kSamplesInput = QStringLiteral("samples_in");
|
||||
const QString VolumeNode::kVolumeInput = QStringLiteral("volume_in");
|
||||
@@ -31,71 +32,77 @@ const QString VolumeNode::kVolumeInput = QStringLiteral("volume_in");
|
||||
|
||||
VolumeNode::VolumeNode()
|
||||
{
|
||||
AddInput(kSamplesInput, NodeValue::kSamples, InputFlags(kInputFlagNotKeyframable));
|
||||
AddInput(kSamplesInput, NodeValue::kSamples,
|
||||
InputFlags(kInputFlagNotKeyframable));
|
||||
|
||||
AddInput(kVolumeInput, NodeValue::kFloat, 1.0);
|
||||
SetInputProperty(kVolumeInput, QStringLiteral("min"), 0.0);
|
||||
SetInputProperty(kVolumeInput, QStringLiteral("view"), FloatSlider::kDecibel);
|
||||
AddInput(kVolumeInput, NodeValue::kFloat, 1.0);
|
||||
SetInputProperty(kVolumeInput, QStringLiteral("min"), 0.0);
|
||||
SetInputProperty(kVolumeInput, QStringLiteral("view"),
|
||||
FloatSlider::kDecibel);
|
||||
|
||||
SetFlag(kAudioEffect);
|
||||
SetEffectInput(kSamplesInput);
|
||||
SetFlag(kAudioEffect);
|
||||
SetEffectInput(kSamplesInput);
|
||||
}
|
||||
|
||||
QString VolumeNode::Name() const
|
||||
{
|
||||
return tr("Volume");
|
||||
return tr("Volume");
|
||||
}
|
||||
|
||||
QString VolumeNode::id() const
|
||||
{
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.volume");
|
||||
return QStringLiteral("org.olivevideoeditor.Olive.volume");
|
||||
}
|
||||
|
||||
QVector<Node::CategoryID> VolumeNode::Category() const
|
||||
{
|
||||
return {kCategoryFilter};
|
||||
return { kCategoryFilter };
|
||||
}
|
||||
|
||||
QString VolumeNode::Description() const
|
||||
{
|
||||
return tr("Adjusts the volume of an audio source.");
|
||||
return tr("Adjusts the volume of an audio source.");
|
||||
}
|
||||
|
||||
void VolumeNode::Value(const NodeValueRow &value, const NodeGlobals &globals, NodeValueTable *table) const
|
||||
void VolumeNode::Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const
|
||||
{
|
||||
// Create a sample job
|
||||
SampleBuffer buffer = value[kSamplesInput].toSamples();
|
||||
// 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 (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);
|
||||
}
|
||||
if (!qFuzzyCompare(volume, 1.0)) {
|
||||
buffer.transform_volume(volume);
|
||||
}
|
||||
|
||||
table->Push(NodeValue::kSamples, QVariant::fromValue(buffer), this);
|
||||
} else {
|
||||
// Requires job
|
||||
SampleJob job(globals.time(), kSamplesInput, value);
|
||||
job.Insert(kVolumeInput, value);
|
||||
table->Push(NodeValue::kSamples, QVariant::fromValue(job), this);
|
||||
}
|
||||
}
|
||||
table->Push(NodeValue::kSamples, QVariant::fromValue(buffer), this);
|
||||
} else {
|
||||
// Requires job
|
||||
SampleJob job(globals.time(), kSamplesInput, value);
|
||||
job.Insert(kVolumeInput, value);
|
||||
table->Push(NodeValue::kSamples, QVariant::fromValue(job), this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void VolumeNode::ProcessSamples(const NodeValueRow &values, const SampleBuffer &input, SampleBuffer &output, int index) const
|
||||
void VolumeNode::ProcessSamples(const NodeValueRow &values,
|
||||
const SampleBuffer &input, SampleBuffer &output,
|
||||
int index) const
|
||||
{
|
||||
return ProcessSamplesInternal(values, kOpMultiply, kSamplesInput, kVolumeInput, input, output, index);
|
||||
return ProcessSamplesInternal(values, kOpMultiply, kSamplesInput,
|
||||
kVolumeInput, input, output, index);
|
||||
}
|
||||
|
||||
void VolumeNode::Retranslate()
|
||||
{
|
||||
super::Retranslate();
|
||||
super::Retranslate();
|
||||
|
||||
SetInputName(kSamplesInput, tr("Samples"));
|
||||
SetInputName(kVolumeInput, tr("Volume"));
|
||||
SetInputName(kSamplesInput, tr("Samples"));
|
||||
SetInputName(kVolumeInput, tr("Volume"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,30 +23,32 @@
|
||||
|
||||
#include "node/math/math/mathbase.h"
|
||||
|
||||
namespace olive {
|
||||
|
||||
class VolumeNode : public MathNodeBase
|
||||
namespace olive
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
class VolumeNode : public MathNodeBase {
|
||||
Q_OBJECT
|
||||
public:
|
||||
VolumeNode();
|
||||
VolumeNode();
|
||||
|
||||
NODE_DEFAULT_FUNCTIONS(VolumeNode)
|
||||
NODE_DEFAULT_FUNCTIONS(VolumeNode)
|
||||
|
||||
virtual QString Name() const override;
|
||||
virtual QString id() const override;
|
||||
virtual QVector<CategoryID> Category() const override;
|
||||
virtual QString Description() const override;
|
||||
virtual QString Name() const override;
|
||||
virtual QString id() const override;
|
||||
virtual QVector<CategoryID> Category() const override;
|
||||
virtual QString Description() const override;
|
||||
|
||||
virtual void Value(const NodeValueRow& value, const NodeGlobals &globals, NodeValueTable *table) const override;
|
||||
virtual void Value(const NodeValueRow &value, const NodeGlobals &globals,
|
||||
NodeValueTable *table) const override;
|
||||
|
||||
virtual void ProcessSamples(const NodeValueRow &values, const SampleBuffer &input, SampleBuffer &output, int index) const override;
|
||||
virtual void ProcessSamples(const NodeValueRow &values,
|
||||
const SampleBuffer &input, SampleBuffer &output,
|
||||
int index) const override;
|
||||
|
||||
virtual void Retranslate() override;
|
||||
|
||||
static const QString kSamplesInput;
|
||||
static const QString kVolumeInput;
|
||||
virtual void Retranslate() override;
|
||||
|
||||
static const QString kSamplesInput;
|
||||
static const QString kVolumeInput;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user