merge of long discussed new pipeline
This commit is contained in:
@@ -1,61 +1,94 @@
|
||||
/*
|
||||
* Olive. Olive is a free non-linear video editor for Windows, macOS, and Linux.
|
||||
* Copyright (C) 2018 {{ organization }}
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
/***
|
||||
|
||||
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/>.
|
||||
|
||||
***/
|
||||
|
||||
#include "audionoiseeffect.h"
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QtMath>
|
||||
|
||||
AudioNoiseEffect::AudioNoiseEffect(Clip* c, const EffectMeta *em) : Effect(c, em) {
|
||||
EffectRow* amount_row = new EffectRow(this, tr("Amount"));
|
||||
amount_val = new DoubleField(amount_row, "amount");
|
||||
AudioNoiseEffect::AudioNoiseEffect(Clip* c) : Node(c) {
|
||||
amount_val = new DoubleInput(this, "amount", tr("Amount"));
|
||||
amount_val->SetMinimum(0);
|
||||
amount_val->SetDefault(20);
|
||||
amount_val->SetMaximum(100);
|
||||
|
||||
EffectRow* mix_row = new EffectRow(this, tr("Mix"));
|
||||
mix_val = new BoolField(mix_row, "mix");
|
||||
mix_val = new BoolInput(this, "mix", tr("Mix"));
|
||||
mix_val->SetValueAt(0, true);
|
||||
}
|
||||
|
||||
void AudioNoiseEffect::process_audio(double timecode_start, double timecode_end, quint8 *samples, int nb_bytes, int) {
|
||||
double interval = (timecode_end - timecode_start)/nb_bytes;
|
||||
for (int i=0;i<nb_bytes;i+=4) {
|
||||
QString AudioNoiseEffect::name()
|
||||
{
|
||||
return tr("Noise");
|
||||
}
|
||||
|
||||
QString AudioNoiseEffect::id()
|
||||
{
|
||||
return "org.olivevideoeditor.Olive.noise";
|
||||
}
|
||||
|
||||
QString AudioNoiseEffect::description()
|
||||
{
|
||||
return tr("Generate audio noise that can be mixed with this clip.");
|
||||
}
|
||||
|
||||
EffectType AudioNoiseEffect::type()
|
||||
{
|
||||
return EFFECT_TYPE_EFFECT;
|
||||
}
|
||||
|
||||
olive::TrackType AudioNoiseEffect::subtype()
|
||||
{
|
||||
return olive::kTypeAudio;
|
||||
}
|
||||
|
||||
NodePtr AudioNoiseEffect::Create(Clip *c)
|
||||
{
|
||||
return std::make_shared<AudioNoiseEffect>(c);
|
||||
}
|
||||
|
||||
void AudioNoiseEffect::process_audio(double timecode_start,
|
||||
double timecode_end,
|
||||
float **samples,
|
||||
int nb_samples,
|
||||
int channel_count,
|
||||
int type) {
|
||||
|
||||
Q_UNUSED(type)
|
||||
|
||||
double interval = (timecode_end - timecode_start)/nb_samples;
|
||||
for (int i=0;i<nb_samples;i+=4) {
|
||||
double timecode = timecode_start+(interval*i);
|
||||
|
||||
qint16 left_noise_sample = this->randomNumber<qint16>();
|
||||
qint16 right_noise_sample = this->randomNumber<qint16>();
|
||||
|
||||
// set noise volume
|
||||
double vol = log_volume( amount_val->GetDoubleAt(timecode)*0.01 );
|
||||
left_noise_sample *= vol;
|
||||
right_noise_sample *= vol;
|
||||
float vol = log_volume( amount_val->GetDoubleAt(timecode)*0.01 );
|
||||
|
||||
// mix with source audio
|
||||
if (mix_val->GetBoolAt(timecode)) {
|
||||
qint16 left_sample = static_cast<qint16> (((samples[i+1] & 0xFF) << 8) | (samples[i] & 0xFF));
|
||||
qint16 right_sample = static_cast<qint16> (((samples[i+3] & 0xFF) << 8) | (samples[i+2] & 0xFF));
|
||||
left_noise_sample = mix_audio_sample(left_noise_sample, left_sample);
|
||||
right_noise_sample = mix_audio_sample(right_noise_sample, right_sample);
|
||||
for (int j=0;j<channel_count;j++) {
|
||||
// Generate noise sample
|
||||
float noise_sample = this->randomFloat<float>() * vol;
|
||||
|
||||
// mix with source audio
|
||||
if (mix_val->GetBoolAt(timecode)) {
|
||||
samples[j][i] += noise_sample;
|
||||
} else {
|
||||
samples[j][i] = noise_sample;
|
||||
}
|
||||
}
|
||||
|
||||
samples[i+3] = static_cast<quint8> (right_noise_sample >> 8);
|
||||
samples[i+2] = static_cast<quint8> (right_noise_sample);
|
||||
samples[i+1] = static_cast<quint8> (left_noise_sample >> 8);
|
||||
samples[i] = static_cast<quint8> (left_noise_sample);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,36 +1,49 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2019 Olive Team
|
||||
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 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.
|
||||
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/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#ifndef AUDIONOISEEFFECT_H
|
||||
#define AUDIONOISEEFFECT_H
|
||||
|
||||
#include "effects/effect.h"
|
||||
#include "nodes/node.h"
|
||||
|
||||
class AudioNoiseEffect : public Effect {
|
||||
class AudioNoiseEffect : public Node {
|
||||
Q_OBJECT
|
||||
public:
|
||||
AudioNoiseEffect(Clip* c, const EffectMeta* em);
|
||||
void process_audio(double timecode_start, double timecode_end, quint8* samples, int nb_bytes, int channel_count);
|
||||
AudioNoiseEffect(Clip* c);
|
||||
|
||||
DoubleField* amount_val;
|
||||
BoolField* mix_val;
|
||||
virtual QString name() override;
|
||||
virtual QString id() override;
|
||||
virtual QString description() override;
|
||||
virtual EffectType type() override;
|
||||
virtual olive::TrackType subtype() override;
|
||||
virtual NodePtr Create(Clip *c) override;
|
||||
|
||||
virtual void process_audio(double timecode_start,
|
||||
double timecode_end,
|
||||
float **samples,
|
||||
int nb_samples,
|
||||
int channel_count,
|
||||
int type) override;
|
||||
|
||||
DoubleInput* amount_val;
|
||||
BoolInput* mix_val;
|
||||
};
|
||||
|
||||
#endif // AUDIONOISEEFFECT_H
|
||||
|
||||
@@ -1,207 +0,0 @@
|
||||
#version 110
|
||||
|
||||
const int BLEND_MODE_ADD = 0;
|
||||
const int BLEND_MODE_AVERAGE = 1;
|
||||
const int BLEND_MODE_COLORBURN = 2;
|
||||
const int BLEND_MODE_COLORDODGE = 3;
|
||||
const int BLEND_MODE_DARKEN = 4;
|
||||
const int BLEND_MODE_DIFFERENCE = 5;
|
||||
const int BLEND_MODE_EXCLUSION = 6;
|
||||
const int BLEND_MODE_GLOW = 7;
|
||||
const int BLEND_MODE_HARDLIGHT = 8;
|
||||
const int BLEND_MODE_HARDMIX = 9;
|
||||
const int BLEND_MODE_LIGHTEN = 10;
|
||||
const int BLEND_MODE_LINEARBURN = 11;
|
||||
const int BLEND_MODE_LINEARDODGE = 12;
|
||||
const int BLEND_MODE_LINEARLIGHT = 13;
|
||||
const int BLEND_MODE_MULTIPLY = 14;
|
||||
const int BLEND_MODE_NEGATION = 15;
|
||||
const int BLEND_MODE_NORMAL = 16;
|
||||
const int BLEND_MODE_OVERLAY = 17;
|
||||
const int BLEND_MODE_PHOENIX = 18;
|
||||
const int BLEND_MODE_PINLIGHT = 19;
|
||||
const int BLEND_MODE_REFLECT = 20;
|
||||
const int BLEND_MODE_SCREEN = 21;
|
||||
const int BLEND_MODE_SOFTLIGHT = 22;
|
||||
const int BLEND_MODE_SUBSTRACT = 23;
|
||||
const int BLEND_MODE_SUBTRACT = 24;
|
||||
const int BLEND_MODE_VIVIDLIGHT = 25;
|
||||
|
||||
uniform sampler2D background;
|
||||
uniform sampler2D foreground;
|
||||
|
||||
uniform int blendmode;
|
||||
uniform float opacity;
|
||||
|
||||
varying vec2 vTexCoord;
|
||||
|
||||
// adapted from https://github.com/jamieowen/glsl-blend
|
||||
// and http://www.deepskycolors.com/archivo/2010/04/21/formulas-for-Photoshop-blending-modes.html
|
||||
|
||||
// float blending functions
|
||||
float blend_color_burn(float base, float blend) {
|
||||
return (blend==0.0)?blend:max((1.0-((1.0-base)/blend)),0.0);
|
||||
}
|
||||
|
||||
float blend_color_dodge(float base, float blend) {
|
||||
return (blend==1.0)?blend:min(base/(1.0-blend),1.0);
|
||||
}
|
||||
|
||||
float blend_vivid_light(float base, float blend) {
|
||||
return (blend<0.5)?blend_color_burn(base,(2.0*blend)):blend_color_dodge(base,(2.0*(blend-0.5)));
|
||||
}
|
||||
|
||||
vec3 blend_vivid_light(vec3 base, vec3 blend) {
|
||||
return vec3(blend_vivid_light(base.r,blend.r),blend_vivid_light(base.g,blend.g),blend_vivid_light(base.b,blend.b));
|
||||
}
|
||||
|
||||
float blend_hard_mix(float base, float blend) {
|
||||
return (blend_vivid_light(base,blend)<0.5)?0.0:1.0;
|
||||
}
|
||||
|
||||
float blend_lighten(float base, float blend) {
|
||||
return max(blend,base);
|
||||
}
|
||||
|
||||
float blend_overlay(float base, float blend) {
|
||||
return base<0.5?(2.0*base*blend):(1.0-2.0*(1.0-base)*(1.0-blend));
|
||||
}
|
||||
|
||||
vec3 blend_overlay(vec3 base, vec3 blend) {
|
||||
return vec3(blend_overlay(base.r,blend.r),blend_overlay(base.g,blend.g),blend_overlay(base.b,blend.b));
|
||||
}
|
||||
|
||||
float blend_darken(float base, float blend) {
|
||||
return min(blend, base);
|
||||
}
|
||||
|
||||
float blend_linear_burn(float base, float blend) {
|
||||
return max(base+blend-1.0,0.0);
|
||||
}
|
||||
|
||||
vec3 blend_linear_burn(vec3 base, vec3 blend) {
|
||||
return max(base+blend-vec3(1.0),vec3(0.0));
|
||||
}
|
||||
|
||||
float blend_linear_dodge(float base, float blend) {
|
||||
return min(base+blend,1.0);
|
||||
}
|
||||
|
||||
vec3 blend_linear_dodge(vec3 base, vec3 blend) {
|
||||
return min(base+blend,vec3(1.0));
|
||||
}
|
||||
|
||||
float blend_linear_light(float base, float blend) {
|
||||
return blend<0.5?blend_linear_burn(base,(2.0*blend)):blend_linear_dodge(base,(2.0*(blend-0.5)));
|
||||
}
|
||||
|
||||
float blend_pin_light(float base, float blend) {
|
||||
return (blend<0.5)?blend_darken(base,(2.0*blend)):blend_lighten(base,(2.0*(blend-0.5)));
|
||||
}
|
||||
|
||||
float blend_reflect(float base, float blend) {
|
||||
return (blend==1.0)?blend:min(base*base/(1.0-blend),1.0);
|
||||
}
|
||||
|
||||
vec3 blend_reflect(vec3 base, vec3 blend) {
|
||||
return vec3(blend_reflect(base.r,blend.r),blend_reflect(base.g,blend.g),blend_reflect(base.b,blend.b));
|
||||
}
|
||||
|
||||
float blend_screen(float base, float blend) {
|
||||
return 1.0-((1.0-base)*(1.0-blend));
|
||||
}
|
||||
|
||||
float blend_substract(float base, float blend) {
|
||||
return max(base+blend-1.0,0.0);
|
||||
}
|
||||
|
||||
float blend_soft_light(float base, float blend) {
|
||||
return (blend<0.5)?(2.0*base*blend+base*base*(1.0-2.0*blend)):(sqrt(base)*(2.0*blend-1.0)+2.0*base*(1.0-blend));
|
||||
}
|
||||
|
||||
// RGB blending function, alpha is handled below
|
||||
vec3 blend(vec3 base, vec3 blend) {
|
||||
if (blendmode == BLEND_MODE_AVERAGE) {
|
||||
return (base+blend)/2.0;
|
||||
} else if (blendmode == BLEND_MODE_COLORBURN) {
|
||||
return vec3(blend_color_burn(base.r, blend.r), blend_color_burn(base.g, blend.g), blend_color_burn(base.b, blend.b));
|
||||
} else if (blendmode == BLEND_MODE_COLORDODGE) {
|
||||
return vec3(blend_color_dodge(base.r, blend.r), blend_color_dodge(base.g, blend.g), blend_color_dodge(base.b, blend.b));
|
||||
} else if (blendmode == BLEND_MODE_DARKEN) {
|
||||
return vec3(blend_darken(base.r, blend.r), blend_darken(base.g, blend.g), blend_darken(base.b, blend.b));
|
||||
} else if (blendmode == BLEND_MODE_DIFFERENCE) {
|
||||
return abs(base-blend);
|
||||
} else if (blendmode == BLEND_MODE_EXCLUSION) {
|
||||
return base+blend-2.0*base*blend;
|
||||
} else if (blendmode == BLEND_MODE_GLOW) {
|
||||
return blend_reflect(blend, base);
|
||||
} else if (blendmode == BLEND_MODE_HARDLIGHT) {
|
||||
return blend_overlay(blend,base);
|
||||
} else if (blendmode == BLEND_MODE_HARDMIX) {
|
||||
return vec3(blend_hard_mix(base.r,blend.r),blend_hard_mix(base.g,blend.g),blend_hard_mix(base.b,blend.b));
|
||||
} else if (blendmode == BLEND_MODE_LIGHTEN) {
|
||||
return vec3(blend_lighten(base.r,blend.r),blend_lighten(base.g,blend.g),blend_lighten(base.b,blend.b));
|
||||
} else if (blendmode == BLEND_MODE_LINEARBURN || blendmode == BLEND_MODE_SUBTRACT) {
|
||||
return blend_linear_burn(base, blend);
|
||||
} else if (blendmode == BLEND_MODE_LINEARDODGE || blendmode == BLEND_MODE_ADD) {
|
||||
return blend_linear_dodge(base, blend);
|
||||
} else if (blendmode == BLEND_MODE_LINEARLIGHT) {
|
||||
return vec3(blend_linear_light(base.r,blend.r),blend_linear_light(base.g,blend.g),blend_linear_light(base.b,blend.b));
|
||||
} else if (blendmode == BLEND_MODE_MULTIPLY) {
|
||||
return (base * blend);
|
||||
} else if (blendmode == BLEND_MODE_NEGATION) {
|
||||
return vec3(1.0)-abs(vec3(1.0)-base-blend);
|
||||
} else if (blendmode == BLEND_MODE_OVERLAY) {
|
||||
return blend_overlay(base, blend);
|
||||
} else if (blendmode == BLEND_MODE_PHOENIX) {
|
||||
return min(base,blend)-max(base,blend)+vec3(1.0);
|
||||
} else if (blendmode == BLEND_MODE_PINLIGHT) {
|
||||
return vec3(blend_pin_light(base.r,blend.r),blend_pin_light(base.g,blend.g),blend_pin_light(base.b,blend.b));
|
||||
} else if (blendmode == BLEND_MODE_REFLECT) {
|
||||
return blend_reflect(base, blend);
|
||||
} else if (blendmode == BLEND_MODE_SCREEN) {
|
||||
return vec3(blend_screen(base.r,blend.r),blend_screen(base.g,blend.g),blend_screen(base.b,blend.b));
|
||||
} else if (blendmode == BLEND_MODE_SUBSTRACT) {
|
||||
return max(base+blend-vec3(1.0),vec3(0.0));
|
||||
} else if (blendmode == BLEND_MODE_SOFTLIGHT) {
|
||||
return vec3(blend_soft_light(base.r,blend.r),blend_soft_light(base.g,blend.g),blend_soft_light(base.b,blend.b));
|
||||
} else if (blendmode == BLEND_MODE_VIVIDLIGHT) {
|
||||
return vec3(blend_vivid_light(base.r,blend.r),blend_vivid_light(base.g,blend.g),blend_vivid_light(base.b,blend.b));
|
||||
} else {
|
||||
return blend;
|
||||
}
|
||||
}
|
||||
|
||||
void main(void) {
|
||||
vec4 bg_color = texture2D(background, vTexCoord);
|
||||
vec4 fg_color = texture2D(foreground, vTexCoord);
|
||||
|
||||
// blend textures together
|
||||
vec3 composite = blend(bg_color.rgb, fg_color.rgb);
|
||||
|
||||
// add foreground and background alpha's together
|
||||
// float alpha_opac = fg_color.a*opacity;
|
||||
|
||||
if (blendmode == BLEND_MODE_OVERLAY
|
||||
|| blendmode == BLEND_MODE_LIGHTEN
|
||||
|| blendmode == BLEND_MODE_SCREEN
|
||||
|| blendmode == BLEND_MODE_COLORDODGE
|
||||
|| blendmode == BLEND_MODE_LINEARDODGE
|
||||
|| blendmode == BLEND_MODE_ADD
|
||||
|| blendmode == BLEND_MODE_SOFTLIGHT
|
||||
|| blendmode == BLEND_MODE_NEGATION
|
||||
|| blendmode == BLEND_MODE_AVERAGE
|
||||
|| blendmode == BLEND_MODE_REFLECT
|
||||
|| blendmode == BLEND_MODE_EXCLUSION
|
||||
|| blendmode == BLEND_MODE_DIFFERENCE) {
|
||||
composite *= fg_color.a;
|
||||
}
|
||||
|
||||
vec4 full_composite = vec4(composite + bg_color.rgb*(1.0-fg_color.a), bg_color.a + fg_color.a);
|
||||
// vec4 full_composite = vec4(mix(bg_color.rgb, composite, alpha_opac), bg_color.a + alpha_opac);
|
||||
|
||||
full_composite = mix(bg_color, full_composite, opacity);
|
||||
|
||||
// output to color
|
||||
gl_FragColor = full_composite;
|
||||
}
|
||||
@@ -1,20 +1,20 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2019 Olive Team
|
||||
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 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.
|
||||
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/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
@@ -24,74 +24,93 @@
|
||||
#include "timeline/clip.h"
|
||||
#include "global/debug.h"
|
||||
|
||||
CornerPinEffect::CornerPinEffect(Clip* c, const EffectMeta *em) : Effect(c, em) {
|
||||
SetFlags(Effect::CoordsFlag | Effect::ShaderFlag);
|
||||
CornerPinEffect::CornerPinEffect(Clip* c) : Node(c) {
|
||||
SetFlags(Node::CoordsFlag | Node::ShaderFlag);
|
||||
|
||||
EffectRow* top_left = new EffectRow(this, tr("Top Left"));
|
||||
top_left_x = new DoubleField(top_left, "topleftx");
|
||||
top_left_y = new DoubleField(top_left, "toplefty");
|
||||
top_left = new Vec2Input(this, "topleft", tr("Top Left"));
|
||||
|
||||
EffectRow* top_right = new EffectRow(this, tr("Top Right"));
|
||||
top_right_x = new DoubleField(top_right, "toprightx");
|
||||
top_right_y = new DoubleField(top_right, "toprighty");
|
||||
top_right = new Vec2Input(this, "topright", tr("Top Right"));
|
||||
|
||||
EffectRow* bottom_left = new EffectRow(this, tr("Bottom Left"));
|
||||
bottom_left_x = new DoubleField(bottom_left, "bottomleftx");
|
||||
bottom_left_y = new DoubleField(bottom_left, "bottomlefty");
|
||||
bottom_left = new Vec2Input(this, "bottomleft", tr("Bottom Left"));
|
||||
|
||||
EffectRow* bottom_right = new EffectRow(this, tr("Bottom Right"));
|
||||
bottom_right_x = new DoubleField(bottom_right, "bottomrightx");
|
||||
bottom_right_y = new DoubleField(bottom_right, "bottomrighty");
|
||||
bottom_right = new Vec2Input(this, "bottomright", tr("Bottom Right"));
|
||||
|
||||
EffectRow* perspective_row = new EffectRow(this, tr("Perspective"));
|
||||
perspective = new BoolField(perspective_row, "perspective");
|
||||
perspective = new BoolInput(this, "perspective", tr("Perspective"));
|
||||
perspective->SetValueAt(0, true);
|
||||
|
||||
top_left_gizmo = add_gizmo(GIZMO_TYPE_DOT);
|
||||
top_left_gizmo->x_field1 = top_left_x;
|
||||
top_left_gizmo->y_field1 = top_left_y;
|
||||
top_left_gizmo->x_field1 = static_cast<DoubleField*>(top_left->Field(0));
|
||||
top_left_gizmo->y_field1 = static_cast<DoubleField*>(top_left->Field(1));
|
||||
|
||||
top_right_gizmo = add_gizmo(GIZMO_TYPE_DOT);
|
||||
top_right_gizmo->x_field1 = top_right_x;
|
||||
top_right_gizmo->y_field1 = top_right_y;
|
||||
top_right_gizmo->x_field1 = static_cast<DoubleField*>(top_right->Field(0));
|
||||
top_right_gizmo->y_field1 = static_cast<DoubleField*>(top_right->Field(1));
|
||||
|
||||
bottom_left_gizmo = add_gizmo(GIZMO_TYPE_DOT);
|
||||
bottom_left_gizmo->x_field1 = bottom_left_x;
|
||||
bottom_left_gizmo->y_field1 = bottom_left_y;
|
||||
bottom_left_gizmo->x_field1 = static_cast<DoubleField*>(bottom_left->Field(0));
|
||||
bottom_left_gizmo->y_field1 = static_cast<DoubleField*>(bottom_left->Field(1));
|
||||
|
||||
bottom_right_gizmo = add_gizmo(GIZMO_TYPE_DOT);
|
||||
bottom_right_gizmo->x_field1 = bottom_right_x;
|
||||
bottom_right_gizmo->y_field1 = bottom_right_y;
|
||||
bottom_right_gizmo->x_field1 = static_cast<DoubleField*>(bottom_right->Field(0));
|
||||
bottom_right_gizmo->y_field1 = static_cast<DoubleField*>(bottom_right->Field(1));
|
||||
|
||||
vertPath = "cornerpin.vert";
|
||||
fragPath = "cornerpin.frag";
|
||||
shader_vert_path_ = "cornerpin.vert";
|
||||
shader_frag_path_ = "cornerpin.frag";
|
||||
}
|
||||
|
||||
QString CornerPinEffect::name()
|
||||
{
|
||||
return tr("Corner Pin");
|
||||
}
|
||||
|
||||
QString CornerPinEffect::id()
|
||||
{
|
||||
return "org.olivevideoeditor.Olive.cornerpin";
|
||||
}
|
||||
|
||||
QString CornerPinEffect::category()
|
||||
{
|
||||
return tr("Distort");
|
||||
}
|
||||
|
||||
QString CornerPinEffect::description()
|
||||
{
|
||||
return tr("Distort/warp this clip by pinning each of its four corners.");
|
||||
}
|
||||
|
||||
EffectType CornerPinEffect::type()
|
||||
{
|
||||
return EFFECT_TYPE_EFFECT;
|
||||
}
|
||||
|
||||
olive::TrackType CornerPinEffect::subtype()
|
||||
{
|
||||
return olive::kTypeVideo;
|
||||
}
|
||||
|
||||
NodePtr CornerPinEffect::Create(Clip *c)
|
||||
{
|
||||
return std::make_shared<CornerPinEffect>(c);
|
||||
}
|
||||
|
||||
void CornerPinEffect::process_coords(double timecode, GLTextureCoords &coords, int) {
|
||||
coords.vertexTopLeftX += top_left_x->GetDoubleAt(timecode);
|
||||
coords.vertexTopLeftY += top_left_y->GetDoubleAt(timecode);
|
||||
|
||||
coords.vertexTopRightX += top_right_x->GetDoubleAt(timecode);
|
||||
coords.vertexTopRightY += top_right_y->GetDoubleAt(timecode);
|
||||
|
||||
coords.vertexBottomLeftX += bottom_left_x->GetDoubleAt(timecode);
|
||||
coords.vertexBottomLeftY += bottom_left_y->GetDoubleAt(timecode);
|
||||
|
||||
coords.vertexBottomRightX += bottom_right_x->GetDoubleAt(timecode);
|
||||
coords.vertexBottomRightY += bottom_right_y->GetDoubleAt(timecode);
|
||||
coords.vertex_top_left += top_left->GetVector2DAt(timecode);
|
||||
coords.vertex_top_right += top_right->GetVector2DAt(timecode);
|
||||
coords.vertex_bottom_left += bottom_left->GetVector2DAt(timecode);
|
||||
coords.vertex_bottom_right += bottom_right->GetVector2DAt(timecode);
|
||||
}
|
||||
|
||||
void CornerPinEffect::process_shader(double timecode, GLTextureCoords &coords, int) {
|
||||
glslProgram->setUniformValue("p0", GLfloat(coords.vertexBottomLeftX), GLfloat(coords.vertexBottomLeftY));
|
||||
glslProgram->setUniformValue("p1", GLfloat(coords.vertexBottomRightX), GLfloat(coords.vertexBottomRightY));
|
||||
glslProgram->setUniformValue("p2", GLfloat(coords.vertexTopLeftX), GLfloat(coords.vertexTopLeftY));
|
||||
glslProgram->setUniformValue("p3", GLfloat(coords.vertexTopRightX), GLfloat(coords.vertexTopRightY));
|
||||
glslProgram->setUniformValue("perspective", perspective->GetBoolAt(timecode));
|
||||
shader_program_->setUniformValue("p0", coords.vertex_bottom_left.x(), coords.vertex_bottom_left.y());
|
||||
shader_program_->setUniformValue("p1", coords.vertex_bottom_right.x(), coords.vertex_bottom_right.y());
|
||||
shader_program_->setUniformValue("p2", coords.vertex_top_left.x(), coords.vertex_top_left.y());
|
||||
shader_program_->setUniformValue("p3", coords.vertex_top_right.x(), coords.vertex_top_right.y());
|
||||
shader_program_->setUniformValue("perspective", perspective->GetBoolAt(timecode));
|
||||
}
|
||||
|
||||
void CornerPinEffect::gizmo_draw(double, GLTextureCoords &coords) {
|
||||
top_left_gizmo->world_pos[0] = QPoint(coords.vertexTopLeftX, coords.vertexTopLeftY);
|
||||
top_right_gizmo->world_pos[0] = QPoint(coords.vertexTopRightX, coords.vertexTopRightY);
|
||||
bottom_right_gizmo->world_pos[0] = QPoint(coords.vertexBottomRightX, coords.vertexBottomRightY);
|
||||
bottom_left_gizmo->world_pos[0] = QPoint(coords.vertexBottomLeftX, coords.vertexBottomLeftY);
|
||||
top_left_gizmo->world_pos[0] = coords.vertex_top_left;
|
||||
top_right_gizmo->world_pos[0] = coords.vertex_top_right;
|
||||
bottom_right_gizmo->world_pos[0] = coords.vertex_bottom_right;
|
||||
bottom_left_gizmo->world_pos[0] = coords.vertex_bottom_left;
|
||||
}
|
||||
|
||||
@@ -1,45 +1,51 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2019 Olive Team
|
||||
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 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.
|
||||
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/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#ifndef CORNERPINEFFECT_H
|
||||
#define CORNERPINEFFECT_H
|
||||
|
||||
#include "effects/effect.h"
|
||||
#include "nodes/node.h"
|
||||
|
||||
class CornerPinEffect : public Effect {
|
||||
class CornerPinEffect : public Node {
|
||||
Q_OBJECT
|
||||
public:
|
||||
CornerPinEffect(Clip* c, const EffectMeta* em);
|
||||
CornerPinEffect(Clip* c);
|
||||
|
||||
virtual QString name() override;
|
||||
virtual QString id() override;
|
||||
virtual QString category() override;
|
||||
virtual QString description() override;
|
||||
virtual EffectType type() override;
|
||||
virtual olive::TrackType subtype() override;
|
||||
virtual NodePtr Create(Clip *c) override;
|
||||
|
||||
void process_coords(double timecode, GLTextureCoords& coords, int data);
|
||||
void process_shader(double timecode, GLTextureCoords& coords, int iterations);
|
||||
void gizmo_draw(double timecode, GLTextureCoords& coords);
|
||||
private:
|
||||
DoubleField* top_left_x;
|
||||
DoubleField* top_left_y;
|
||||
DoubleField* top_right_x;
|
||||
DoubleField* top_right_y;
|
||||
DoubleField* bottom_left_x;
|
||||
DoubleField* bottom_left_y;
|
||||
DoubleField* bottom_right_x;
|
||||
DoubleField* bottom_right_y;
|
||||
BoolField* perspective;
|
||||
Vec2Input* top_left;
|
||||
Vec2Input* top_right;
|
||||
Vec2Input* bottom_left;
|
||||
Vec2Input* bottom_right;
|
||||
|
||||
BoolInput* perspective;
|
||||
|
||||
EffectGizmo* top_left_gizmo;
|
||||
EffectGizmo* top_right_gizmo;
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2019 Olive Team
|
||||
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 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.
|
||||
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/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
@@ -22,13 +22,49 @@
|
||||
|
||||
#include <QOpenGLFunctions>
|
||||
|
||||
CrossDissolveTransition::CrossDissolveTransition(Clip* c, Clip* s, const EffectMeta* em) : Transition(c, s, em) {
|
||||
SetFlags(Effect::CoordsFlag);
|
||||
CrossDissolveTransition::CrossDissolveTransition(Clip* c) : Transition(c) {
|
||||
SetFlags(Node::CoordsFlag);
|
||||
}
|
||||
|
||||
QString CrossDissolveTransition::name()
|
||||
{
|
||||
return tr("Cross Dissolve");
|
||||
}
|
||||
|
||||
QString CrossDissolveTransition::id()
|
||||
{
|
||||
return "org.olivevideoeditor.Olive.crossdissolve";
|
||||
}
|
||||
|
||||
QString CrossDissolveTransition::category()
|
||||
{
|
||||
return tr("Dissolves");
|
||||
}
|
||||
|
||||
QString CrossDissolveTransition::description()
|
||||
{
|
||||
return tr("Dissolve clips evenly.");
|
||||
}
|
||||
|
||||
EffectType CrossDissolveTransition::type()
|
||||
{
|
||||
return EFFECT_TYPE_TRANSITION;
|
||||
}
|
||||
|
||||
olive::TrackType CrossDissolveTransition::subtype()
|
||||
{
|
||||
return olive::kTypeVideo;
|
||||
}
|
||||
|
||||
NodePtr CrossDissolveTransition::Create(Clip *c)
|
||||
{
|
||||
return std::make_shared<CrossDissolveTransition>(c);
|
||||
}
|
||||
|
||||
void CrossDissolveTransition::process_coords(double progress, GLTextureCoords& coords, int data) {
|
||||
if (!(data == kTransitionClosing && secondary_clip != nullptr)) {
|
||||
if (data == kTransitionClosing) progress = 1.0 - progress;
|
||||
if (data == kTransitionClosing) {
|
||||
coords.opacity *= (1.0 - progress);
|
||||
} else {
|
||||
coords.opacity *= progress;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2019 Olive Team
|
||||
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 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.
|
||||
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/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
@@ -25,8 +25,17 @@
|
||||
|
||||
class CrossDissolveTransition : public Transition {
|
||||
public:
|
||||
CrossDissolveTransition(Clip *c, Clip *s, const EffectMeta* em);
|
||||
void process_coords(double timecode, GLTextureCoords &, int data);
|
||||
CrossDissolveTransition(Clip *c);
|
||||
|
||||
virtual QString name() override;
|
||||
virtual QString id() override;
|
||||
virtual QString category() override;
|
||||
virtual QString description() override;
|
||||
virtual EffectType type() override;
|
||||
virtual olive::TrackType subtype() override;
|
||||
virtual NodePtr Create(Clip *c) override;
|
||||
|
||||
virtual void process_coords(double timecode, GLTextureCoords &, int data) override;
|
||||
};
|
||||
|
||||
#endif // CROSSDISSOLVETRANSITION_H
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2019 Olive Team
|
||||
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 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.
|
||||
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/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
@@ -25,8 +25,8 @@
|
||||
|
||||
class CubeTransition : public Transition {
|
||||
public:
|
||||
CubeTransition(Clip* c, Clip* s, const EffectMeta* em);
|
||||
void process_coords(double timecode, GLTextureCoords &, int data);
|
||||
CubeTransition(Clip* c, Clip* s);
|
||||
void process_coords(double timecode, GLTextureCoords &, int data);
|
||||
};
|
||||
|
||||
#endif // CUBETRANSITION_H
|
||||
|
||||
@@ -1,3 +1,23 @@
|
||||
/***
|
||||
|
||||
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/>.
|
||||
|
||||
***/
|
||||
|
||||
#include "dropshadoweffect.h"
|
||||
|
||||
DropShadowEffect::DropShadowEffect() {
|
||||
|
||||
@@ -1,3 +1,23 @@
|
||||
/***
|
||||
|
||||
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/>.
|
||||
|
||||
***/
|
||||
|
||||
#ifndef DROPSHADOWEFFECT_H
|
||||
#define DROPSHADOWEFFECT_H
|
||||
|
||||
@@ -8,4 +28,4 @@ public:
|
||||
DropShadowEffect();
|
||||
};
|
||||
|
||||
#endif // DROPSHADOWEFFECT_H
|
||||
#endif // DROPSHADOWEFFECT_H
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2019 Olive Team
|
||||
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 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.
|
||||
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/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
@@ -22,34 +22,62 @@
|
||||
|
||||
#include <QtMath>
|
||||
|
||||
ExponentialFadeTransition::ExponentialFadeTransition(Clip* c, Clip* s, const EffectMeta* em) : Transition(c, s, em) {}
|
||||
|
||||
void ExponentialFadeTransition::process_audio(double timecode_start, double timecode_end, quint8* samples, int nb_bytes, int type) {
|
||||
double interval = (timecode_end-timecode_start)/nb_bytes;
|
||||
|
||||
for (int i=0;i<nb_bytes;i+=2) {
|
||||
qint16 samp = (qint16) (((samples[i+1] & 0xFF) << 8) | (samples[i] & 0xFF));
|
||||
|
||||
/*switch (type) {
|
||||
case TRAN_TYPE_OPEN:
|
||||
case TRAN_TYPE_OPENWLINK:
|
||||
samp *= qSqrt(timecode_start + (interval * i));
|
||||
break;
|
||||
case TRAN_TYPE_CLOSE:
|
||||
case TRAN_TYPE_CLOSEWLINK:
|
||||
samp *= qSqrt(1 - (timecode_start + (interval * i)));
|
||||
break;
|
||||
}*/
|
||||
switch (type) {
|
||||
case kTransitionOpening:
|
||||
samp *= qPow(timecode_start + (interval * i), 2);
|
||||
break;
|
||||
case kTransitionClosing:
|
||||
samp *= qPow(1 - (timecode_start + (interval * i)), 2);
|
||||
break;
|
||||
}
|
||||
|
||||
samples[i+1] = (quint8) (samp >> 8);
|
||||
samples[i] = (quint8) samp;
|
||||
}
|
||||
ExponentialFadeTransition::ExponentialFadeTransition(Clip* c) :
|
||||
Transition(c)
|
||||
{
|
||||
}
|
||||
|
||||
QString ExponentialFadeTransition::name()
|
||||
{
|
||||
return tr("Exponential Fade");
|
||||
}
|
||||
|
||||
QString ExponentialFadeTransition::id()
|
||||
{
|
||||
return "org.olivevideoeditor.Olive.exponentialfade";
|
||||
}
|
||||
|
||||
QString ExponentialFadeTransition::description()
|
||||
{
|
||||
return tr("An exponential audio fade that starts slow and ends fast.");
|
||||
}
|
||||
|
||||
EffectType ExponentialFadeTransition::type()
|
||||
{
|
||||
return EFFECT_TYPE_TRANSITION;
|
||||
}
|
||||
|
||||
olive::TrackType ExponentialFadeTransition::subtype()
|
||||
{
|
||||
return olive::kTypeAudio;
|
||||
}
|
||||
|
||||
NodePtr ExponentialFadeTransition::Create(Clip *c)
|
||||
{
|
||||
return std::make_shared<ExponentialFadeTransition>(c);
|
||||
}
|
||||
|
||||
void ExponentialFadeTransition::process_audio(double timecode_start,
|
||||
double timecode_end,
|
||||
float **samples,
|
||||
int nb_samples,
|
||||
int channel_count,
|
||||
int type) {
|
||||
double interval = (timecode_end-timecode_start)/nb_samples;
|
||||
|
||||
for (int i=0;i<nb_samples;i++) {
|
||||
|
||||
double multi = timecode_start + (interval * i);
|
||||
|
||||
for (int j=0;j<channel_count;j++) {
|
||||
switch (type) {
|
||||
case kTransitionOpening:
|
||||
samples[j][i] *= qPow(multi, 2);
|
||||
break;
|
||||
case kTransitionClosing:
|
||||
samples[j][i] *= qPow(1.0 - multi, 2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2019 Olive Team
|
||||
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 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.
|
||||
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/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
@@ -25,8 +25,21 @@
|
||||
|
||||
class ExponentialFadeTransition : public Transition {
|
||||
public:
|
||||
ExponentialFadeTransition(Clip* c, Clip* s, const EffectMeta* em);
|
||||
void process_audio(double timecode_start, double timecode_end, quint8* samples, int nb_bytes, int channel_count);
|
||||
ExponentialFadeTransition(Clip* c);
|
||||
|
||||
virtual QString name() override;
|
||||
virtual QString id() override;
|
||||
virtual QString description() override;
|
||||
virtual EffectType type() override;
|
||||
virtual olive::TrackType subtype() override;
|
||||
virtual NodePtr Create(Clip *c) override;
|
||||
|
||||
virtual void process_audio(double timecode_start,
|
||||
double timecode_end,
|
||||
float **samples,
|
||||
int nb_samples,
|
||||
int channel_count,
|
||||
int type) override;
|
||||
};
|
||||
|
||||
#endif // LINEARFADETRANSITION_H
|
||||
|
||||
@@ -1,44 +1,84 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2019 Olive Team
|
||||
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 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.
|
||||
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/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#include "fillleftrighteffect.h"
|
||||
|
||||
#define FILL_TYPE_LEFT 0
|
||||
#define FILL_TYPE_RIGHT 1
|
||||
enum FillType {
|
||||
FILL_TYPE_LEFT,
|
||||
FILL_TYPE_RIGHT
|
||||
};
|
||||
|
||||
FillLeftRightEffect::FillLeftRightEffect(Clip* c, const EffectMeta *em) : Effect(c, em) {
|
||||
EffectRow* type_row = new EffectRow(this, tr("Type"));
|
||||
fill_type = new ComboField(type_row, "type");
|
||||
FillLeftRightEffect::FillLeftRightEffect(Clip* c) : Node(c) {
|
||||
fill_type = new ComboInput(this, "type", tr("Type"));
|
||||
fill_type->AddItem(tr("Fill Left with Right"), FILL_TYPE_LEFT);
|
||||
fill_type->AddItem(tr("Fill Right with Left"), FILL_TYPE_RIGHT);
|
||||
}
|
||||
|
||||
void FillLeftRightEffect::process_audio(double timecode_start, double timecode_end, quint8* samples, int nb_bytes, int) {
|
||||
double interval = (timecode_end-timecode_start)/nb_bytes;
|
||||
for (int i=0;i<nb_bytes;i+=4) {
|
||||
if (fill_type->GetValueAt(timecode_start+(interval*i)) == FILL_TYPE_LEFT) {
|
||||
samples[i+1] = samples[i+3];
|
||||
samples[i] = samples[i+2];
|
||||
} else {
|
||||
samples[i+3] = samples[i+1];
|
||||
samples[i+2] = samples[i];
|
||||
QString FillLeftRightEffect::name()
|
||||
{
|
||||
return tr("Fill Left/Right");
|
||||
}
|
||||
|
||||
QString FillLeftRightEffect::id()
|
||||
{
|
||||
return "org.olivevideoeditor.Olive.fillleftright";
|
||||
}
|
||||
|
||||
QString FillLeftRightEffect::description()
|
||||
{
|
||||
return tr("Replaces either the left or right channel with the other");
|
||||
}
|
||||
|
||||
EffectType FillLeftRightEffect::type()
|
||||
{
|
||||
return EFFECT_TYPE_EFFECT;
|
||||
}
|
||||
|
||||
olive::TrackType FillLeftRightEffect::subtype()
|
||||
{
|
||||
return olive::kTypeAudio;
|
||||
}
|
||||
|
||||
NodePtr FillLeftRightEffect::Create(Clip *c)
|
||||
{
|
||||
return std::make_shared<FillLeftRightEffect>(c);
|
||||
}
|
||||
|
||||
void FillLeftRightEffect::process_audio(double timecode_start,
|
||||
double timecode_end,
|
||||
float **samples,
|
||||
int nb_samples,
|
||||
int channel_count,
|
||||
int type) {
|
||||
|
||||
Q_UNUSED(type)
|
||||
|
||||
double interval = (timecode_end-timecode_start)/nb_samples;
|
||||
|
||||
if (channel_count == 2) {
|
||||
for (int i=0;i<nb_samples;i++) {
|
||||
if (fill_type->GetValueAt(timecode_start+(interval*i)) == FILL_TYPE_LEFT) {
|
||||
samples[0][i] = samples[1][i];
|
||||
} else {
|
||||
samples[1][i] = samples[0][i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,35 +1,48 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2019 Olive Team
|
||||
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 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.
|
||||
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/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#ifndef FILLLEFTRIGHTEFFECT_H
|
||||
#define FILLLEFTRIGHTEFFECT_H
|
||||
|
||||
#include "effects/effect.h"
|
||||
#include "nodes/node.h"
|
||||
|
||||
class FillLeftRightEffect : public Effect {
|
||||
class FillLeftRightEffect : public Node {
|
||||
Q_OBJECT
|
||||
public:
|
||||
FillLeftRightEffect(Clip* c, const EffectMeta* em);
|
||||
void process_audio(double timecode_start, double timecode_end, quint8* samples, int nb_bytes, int channel_count);
|
||||
FillLeftRightEffect(Clip* c);
|
||||
|
||||
virtual QString name() override;
|
||||
virtual QString id() override;
|
||||
virtual QString description() override;
|
||||
virtual EffectType type() override;
|
||||
virtual olive::TrackType subtype() override;
|
||||
virtual NodePtr Create(Clip *c) override;
|
||||
|
||||
virtual void process_audio(double timecode_start,
|
||||
double timecode_end,
|
||||
float **samples,
|
||||
int nb_samples,
|
||||
int channel_count,
|
||||
int type) override;
|
||||
private:
|
||||
ComboField* fill_type;
|
||||
ComboInput* fill_type;
|
||||
};
|
||||
|
||||
#endif // FILLLEFTRIGHTEFFECT_H
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<RCC>
|
||||
<qresource prefix="/internalshaders">
|
||||
<file>blending.frag</file>
|
||||
<file>common.vert</file>
|
||||
<file>cornerpin.frag</file>
|
||||
<file>cornerpin.vert</file>
|
||||
|
||||
@@ -1,43 +1,79 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2019 Olive Team
|
||||
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 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.
|
||||
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/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#include "linearfadetransition.h"
|
||||
|
||||
LinearFadeTransition::LinearFadeTransition(Clip* c, Clip* s, const EffectMeta* em) : Transition(c, s, em) {}
|
||||
LinearFadeTransition::LinearFadeTransition(Clip* c) : Transition(c) {}
|
||||
|
||||
void LinearFadeTransition::process_audio(double timecode_start, double timecode_end, quint8* samples, int nb_bytes, int type) {
|
||||
double interval = (timecode_end-timecode_start)/nb_bytes;
|
||||
|
||||
for (int i=0;i<nb_bytes;i+=2) {
|
||||
qint16 samp = (qint16) (((samples[i+1] & 0xFF) << 8) | (samples[i] & 0xFF));
|
||||
|
||||
switch (type) {
|
||||
case kTransitionOpening:
|
||||
samp *= timecode_start + (interval * i);
|
||||
break;
|
||||
case kTransitionClosing:
|
||||
samp *= 1 - (timecode_start + (interval * i));
|
||||
break;
|
||||
}
|
||||
|
||||
samples[i+1] = (quint8) (samp >> 8);
|
||||
samples[i] = (quint8) samp;
|
||||
}
|
||||
QString LinearFadeTransition::name()
|
||||
{
|
||||
return tr("Linear Fade");
|
||||
}
|
||||
|
||||
QString LinearFadeTransition::id()
|
||||
{
|
||||
return "org.olivevideoeditor.Olive.linearfade";
|
||||
}
|
||||
|
||||
QString LinearFadeTransition::description()
|
||||
{
|
||||
return tr("An linear audio fade that fades evenly at a constant rate.");
|
||||
}
|
||||
|
||||
EffectType LinearFadeTransition::type()
|
||||
{
|
||||
return EFFECT_TYPE_TRANSITION;
|
||||
}
|
||||
|
||||
olive::TrackType LinearFadeTransition::subtype()
|
||||
{
|
||||
return olive::kTypeAudio;
|
||||
}
|
||||
|
||||
NodePtr LinearFadeTransition::Create(Clip *c)
|
||||
{
|
||||
return std::make_shared<LinearFadeTransition>(c);
|
||||
}
|
||||
|
||||
void LinearFadeTransition::process_audio(double timecode_start,
|
||||
double timecode_end,
|
||||
float **samples,
|
||||
int nb_samples,
|
||||
int channel_count,
|
||||
int type) {
|
||||
double interval = (timecode_end-timecode_start)/nb_samples;
|
||||
|
||||
for (int i=0;i<nb_samples;i++) {
|
||||
|
||||
float multi = timecode_start + (interval * i);
|
||||
|
||||
for (int j=0;j<channel_count;j++) {
|
||||
|
||||
switch (type) {
|
||||
case kTransitionOpening:
|
||||
samples[j][i] *= multi;
|
||||
break;
|
||||
case kTransitionClosing:
|
||||
samples[j][i] *= 1.0f - multi;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2019 Olive Team
|
||||
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 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.
|
||||
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/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
@@ -25,8 +25,21 @@
|
||||
|
||||
class LinearFadeTransition : public Transition {
|
||||
public:
|
||||
LinearFadeTransition(Clip* c, Clip* s, const EffectMeta* em);
|
||||
void process_audio(double timecode_start, double timecode_end, quint8* samples, int nb_bytes, int channel_count);
|
||||
LinearFadeTransition(Clip* c);
|
||||
|
||||
virtual QString name() override;
|
||||
virtual QString id() override;
|
||||
virtual QString description() override;
|
||||
virtual EffectType type() override;
|
||||
virtual olive::TrackType subtype() override;
|
||||
virtual NodePtr Create(Clip *c) override;
|
||||
|
||||
virtual void process_audio(double timecode_start,
|
||||
double timecode_end,
|
||||
float **samples,
|
||||
int nb_samples,
|
||||
int channel_count,
|
||||
int type) override;
|
||||
};
|
||||
|
||||
#endif // LINEARFADETRANSITION_H
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2019 Olive Team
|
||||
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 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.
|
||||
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/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
@@ -22,24 +22,62 @@
|
||||
|
||||
#include <QtMath>
|
||||
|
||||
LogarithmicFadeTransition::LogarithmicFadeTransition(Clip* c, Clip* s, const EffectMeta* em) : Transition(c, s, em) {}
|
||||
|
||||
void LogarithmicFadeTransition::process_audio(double timecode_start, double timecode_end, quint8* samples, int nb_bytes, int type) {
|
||||
double interval = (timecode_end-timecode_start)/nb_bytes;
|
||||
|
||||
for (int i=0;i<nb_bytes;i+=2) {
|
||||
qint16 samp = (qint16) (((samples[i+1] & 0xFF) << 8) | (samples[i] & 0xFF));
|
||||
|
||||
switch (type) {
|
||||
case kTransitionOpening:
|
||||
samp *= qSqrt(timecode_start + (interval * i));
|
||||
break;
|
||||
case kTransitionClosing:
|
||||
samp *= qSqrt(1 - (timecode_start + (interval * i)));
|
||||
break;
|
||||
}
|
||||
|
||||
samples[i+1] = (quint8) (samp >> 8);
|
||||
samples[i] = (quint8) samp;
|
||||
}
|
||||
LogarithmicFadeTransition::LogarithmicFadeTransition(Clip* c) :
|
||||
Transition(c)
|
||||
{
|
||||
}
|
||||
|
||||
QString LogarithmicFadeTransition::name()
|
||||
{
|
||||
return tr("Logarithmic Fade");
|
||||
}
|
||||
|
||||
QString LogarithmicFadeTransition::id()
|
||||
{
|
||||
return "org.olivevideoeditor.Olive.logarithmicfade";
|
||||
}
|
||||
|
||||
QString LogarithmicFadeTransition::description()
|
||||
{
|
||||
return tr("An logarithmic audio fade that starts fast and ends slow.");
|
||||
}
|
||||
|
||||
EffectType LogarithmicFadeTransition::type()
|
||||
{
|
||||
return EFFECT_TYPE_TRANSITION;
|
||||
}
|
||||
|
||||
olive::TrackType LogarithmicFadeTransition::subtype()
|
||||
{
|
||||
return olive::kTypeAudio;
|
||||
}
|
||||
|
||||
NodePtr LogarithmicFadeTransition::Create(Clip *c)
|
||||
{
|
||||
return std::make_shared<LogarithmicFadeTransition>(c);
|
||||
}
|
||||
|
||||
void LogarithmicFadeTransition::process_audio(double timecode_start,
|
||||
double timecode_end,
|
||||
float **samples,
|
||||
int nb_samples,
|
||||
int channel_count,
|
||||
int type) {
|
||||
double interval = (timecode_end-timecode_start)/nb_samples;
|
||||
|
||||
for (int i=0;i<nb_samples;i++) {
|
||||
|
||||
float multi = timecode_start + (interval * i);
|
||||
|
||||
for (int j=0;j<channel_count;j++) {
|
||||
switch (type) {
|
||||
case kTransitionOpening:
|
||||
samples[j][i] *= qSqrt(multi);
|
||||
break;
|
||||
case kTransitionClosing:
|
||||
samples[j][i] *= qSqrt(1.0f - multi);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2019 Olive Team
|
||||
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 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.
|
||||
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/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
@@ -25,8 +25,21 @@
|
||||
|
||||
class LogarithmicFadeTransition : public Transition {
|
||||
public:
|
||||
LogarithmicFadeTransition(Clip* c, Clip* s, const EffectMeta* em);
|
||||
void process_audio(double timecode_start, double timecode_end, quint8* samples, int nb_bytes, int channel_count);
|
||||
LogarithmicFadeTransition(Clip* c);
|
||||
|
||||
virtual QString name() override;
|
||||
virtual QString id() override;
|
||||
virtual QString description() override;
|
||||
virtual EffectType type() override;
|
||||
virtual olive::TrackType subtype() override;
|
||||
virtual NodePtr Create(Clip* c) override;
|
||||
|
||||
virtual void process_audio(double timecode_start,
|
||||
double timecode_end,
|
||||
float **samples,
|
||||
int nb_samples,
|
||||
int channel_count,
|
||||
int type) override;
|
||||
};
|
||||
|
||||
#endif // LOGARITHMICFADETRANSITION_H
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2019 Olive Team
|
||||
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 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.
|
||||
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/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
@@ -28,34 +28,69 @@
|
||||
#include "ui/labelslider.h"
|
||||
#include "ui/collapsiblewidget.h"
|
||||
|
||||
PanEffect::PanEffect(Clip* c, const EffectMeta *em) : Effect(c, em) {
|
||||
EffectRow* pan_row = new EffectRow(this, tr("Pan"));
|
||||
pan_val = new DoubleField(pan_row, "pan");
|
||||
PanEffect::PanEffect(Clip* c) : Node(c) {
|
||||
pan_val = new DoubleInput(this, "pan", tr("Pan"));
|
||||
pan_val->SetMinimum(-100);
|
||||
pan_val->SetDefault(0);
|
||||
pan_val->SetMaximum(100);
|
||||
}
|
||||
|
||||
void PanEffect::process_audio(double timecode_start, double timecode_end, quint8* samples, int nb_bytes, int) {
|
||||
double interval = (timecode_end - timecode_start)/nb_bytes;
|
||||
for (int i=0;i<nb_bytes;i+=4) {
|
||||
QString PanEffect::name()
|
||||
{
|
||||
return tr("Pan");
|
||||
}
|
||||
|
||||
QString PanEffect::id()
|
||||
{
|
||||
return "org.olivevideoeditor.Olive.pan";
|
||||
}
|
||||
|
||||
QString PanEffect::description()
|
||||
{
|
||||
return tr("Modifying the panning on a stereo audio clip.");
|
||||
}
|
||||
|
||||
EffectType PanEffect::type()
|
||||
{
|
||||
return EFFECT_TYPE_EFFECT;
|
||||
}
|
||||
|
||||
olive::TrackType PanEffect::subtype()
|
||||
{
|
||||
return olive::kTypeAudio;
|
||||
}
|
||||
|
||||
NodePtr PanEffect::Create(Clip *c)
|
||||
{
|
||||
return std::make_shared<PanEffect>(c);
|
||||
}
|
||||
|
||||
void PanEffect::process_audio(double timecode_start,
|
||||
double timecode_end,
|
||||
float **samples,
|
||||
int nb_samples,
|
||||
int channel_count,
|
||||
int type) {
|
||||
|
||||
Q_UNUSED(type)
|
||||
|
||||
// This has no effect on mono sources
|
||||
if (channel_count < 2) {
|
||||
return;
|
||||
}
|
||||
|
||||
double interval = (timecode_end - timecode_start)/nb_samples;
|
||||
|
||||
for (int i=0;i<nb_samples;i++) {
|
||||
double pan_field_val = pan_val->GetDoubleAt(timecode_start+(interval*i));
|
||||
double pval = log_volume(qAbs(pan_field_val)*0.01);
|
||||
|
||||
qint16 left_sample = qint16(((samples[i+1] & 0xFF) << 8) | (samples[i] & 0xFF));
|
||||
qint16 right_sample = qint16(((samples[i+3] & 0xFF) << 8) | (samples[i+2] & 0xFF));
|
||||
|
||||
if (pan_field_val < 0) {
|
||||
// affect right channel
|
||||
right_sample *= (1.0-pval);
|
||||
samples[1][i] *= (1.0-pval);
|
||||
} else {
|
||||
// affect left channel
|
||||
left_sample *= (1.0-pval);
|
||||
samples[0][i] *= (1.0-pval);
|
||||
}
|
||||
|
||||
samples[i+3] = quint8(right_sample >> 8);
|
||||
samples[i+2] = quint8(right_sample);
|
||||
samples[i+1] = quint8(left_sample >> 8);
|
||||
samples[i] = quint8(left_sample);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,35 +1,48 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2019 Olive Team
|
||||
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 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.
|
||||
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/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#ifndef PANEFFECT_H
|
||||
#define PANEFFECT_H
|
||||
|
||||
#include "effects/effect.h"
|
||||
#include "nodes/node.h"
|
||||
|
||||
class PanEffect : public Effect {
|
||||
class PanEffect : public Node {
|
||||
Q_OBJECT
|
||||
public:
|
||||
PanEffect(Clip* c, const EffectMeta* em);
|
||||
void process_audio(double timecode_start, double timecode_end, quint8* samples, int nb_bytes, int channel_count);
|
||||
PanEffect(Clip* c);
|
||||
|
||||
DoubleField* pan_val;
|
||||
virtual QString name() override;
|
||||
virtual QString id() override;
|
||||
virtual QString description() override;
|
||||
virtual EffectType type() override;
|
||||
virtual olive::TrackType subtype() override;
|
||||
virtual NodePtr Create(Clip *c) override;
|
||||
|
||||
virtual void process_audio(double timecode_start,
|
||||
double timecode_end,
|
||||
float **samples,
|
||||
int nb_samples,
|
||||
int channel_count,
|
||||
int type) override;
|
||||
|
||||
DoubleInput* pan_val;
|
||||
};
|
||||
|
||||
#endif // PANEFFECT_H
|
||||
|
||||
@@ -1,3 +1,23 @@
|
||||
/***
|
||||
|
||||
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/>.
|
||||
|
||||
***/
|
||||
|
||||
#include "richtexteffect.h"
|
||||
|
||||
#include <QTextDocument>
|
||||
@@ -14,65 +34,43 @@ enum AutoscrollDirection {
|
||||
SCROLL_RIGHT,
|
||||
};
|
||||
|
||||
RichTextEffect::RichTextEffect(Clip *c, const EffectMeta *em) :
|
||||
Effect(c, em)
|
||||
RichTextEffect::RichTextEffect(Clip *c) :
|
||||
Node(c)
|
||||
{
|
||||
SetFlags(Effect::SuperimposeFlag);
|
||||
SetFlags(Node::SuperimposeFlag);
|
||||
|
||||
EffectRow* text_row = new EffectRow(this, tr("Text"));
|
||||
text_val = new StringField(text_row, "text");
|
||||
text_val->SetColumnSpan(2);
|
||||
text_val = new StringInput(this, "text", tr("Text"));
|
||||
|
||||
EffectRow* padding_row = new EffectRow(this, tr("Padding"));
|
||||
padding_field = new DoubleField(padding_row, "padding");
|
||||
padding_field->SetColumnSpan(2);
|
||||
padding_field = new DoubleInput(this, "padding", tr("Padding"));
|
||||
|
||||
EffectRow* position_row = new EffectRow(this, tr("Position"));
|
||||
position_x = new DoubleField(position_row, "posx");
|
||||
position_y = new DoubleField(position_row, "posy");
|
||||
position = new Vec2Input(this, "pos", tr("Position"));
|
||||
|
||||
EffectRow* vertical_align_row = new EffectRow(this, tr("Vertical Align:"));
|
||||
vertical_align = new ComboField(vertical_align_row, "valign");
|
||||
vertical_align = new ComboInput(this, "valign", tr("Vertical Align:"));
|
||||
vertical_align->AddItem(tr("Top"), Qt::AlignTop);
|
||||
vertical_align->AddItem(tr("Center"), Qt::AlignCenter);
|
||||
vertical_align->AddItem(tr("Bottom"), Qt::AlignBottom);
|
||||
vertical_align->SetValueAt(0, Qt::AlignCenter);
|
||||
vertical_align->SetColumnSpan(2);
|
||||
|
||||
EffectRow* autoscroll_row = new EffectRow(this, tr("Auto-Scroll"));
|
||||
autoscroll = new ComboField(autoscroll_row, "autoscroll");
|
||||
autoscroll = new ComboInput(this, "autoscroll", tr("Auto-Scroll"));
|
||||
autoscroll->AddItem(tr("Off"), SCROLL_OFF);
|
||||
autoscroll->AddItem(tr("Up"), SCROLL_UP);
|
||||
autoscroll->AddItem(tr("Down"), SCROLL_DOWN);
|
||||
autoscroll->AddItem(tr("Left"), SCROLL_LEFT);
|
||||
autoscroll->AddItem(tr("Right"), SCROLL_RIGHT);
|
||||
autoscroll->SetColumnSpan(2);
|
||||
|
||||
EffectRow* shadow_row = new EffectRow(this, tr("Shadow"));
|
||||
shadow_bool = new BoolField(shadow_row, "shadow");
|
||||
shadow_bool->SetColumnSpan(2);
|
||||
shadow_bool = new BoolInput(this, "shadow", tr("Shadow"));
|
||||
|
||||
EffectRow* shadow_color_row = new EffectRow(this, tr("Shadow Color"));
|
||||
shadow_color = new ColorField(shadow_color_row, "shadowcolor");
|
||||
shadow_color->SetColumnSpan(2);
|
||||
shadow_color = new ColorInput(this, "shadowcolor", tr("Shadow Color"));
|
||||
|
||||
EffectRow* shadow_angle_row = new EffectRow(this, tr("Shadow Angle"));
|
||||
shadow_angle = new DoubleField(shadow_angle_row, "shadowangle");
|
||||
shadow_angle->SetColumnSpan(2);
|
||||
shadow_angle = new DoubleInput(this, "shadowangle", tr("Shadow Angle"));
|
||||
|
||||
EffectRow* shadow_distance_row = new EffectRow(this, tr("Shadow Distance"));
|
||||
shadow_distance = new DoubleField(shadow_distance_row, "shadowdistance");
|
||||
shadow_distance->SetColumnSpan(2);
|
||||
shadow_distance = new DoubleInput(this, "shadowdistance", tr("Shadow Distance"));
|
||||
shadow_distance->SetMinimum(0);
|
||||
|
||||
EffectRow* shadow_softness_row = new EffectRow(this, tr("Shadow Softness"));
|
||||
shadow_softness = new DoubleField(shadow_softness_row, "shadowsoftness");
|
||||
shadow_softness->SetColumnSpan(2);
|
||||
shadow_softness = new DoubleInput(this, "shadowsoftness", tr("Shadow Softness"));
|
||||
shadow_softness->SetMinimum(0);
|
||||
|
||||
EffectRow* shadow_opacity_row = new EffectRow(this, tr("Shadow Opacity"));
|
||||
shadow_opacity = new DoubleField(shadow_opacity_row, "shadowopacity");
|
||||
shadow_opacity->SetColumnSpan(2);
|
||||
shadow_opacity = new DoubleInput(this, "shadowopacity", tr("Shadow Opacity"));
|
||||
shadow_opacity->SetMinimum(0);
|
||||
shadow_opacity->SetMaximum(100);
|
||||
|
||||
@@ -84,6 +82,41 @@ RichTextEffect::RichTextEffect(Clip *c, const EffectMeta *em) :
|
||||
"</html>");
|
||||
}
|
||||
|
||||
QString RichTextEffect::name()
|
||||
{
|
||||
return tr("Rich Text");
|
||||
}
|
||||
|
||||
QString RichTextEffect::id()
|
||||
{
|
||||
return "org.olivevideoeditor.Olive.richtext";
|
||||
}
|
||||
|
||||
QString RichTextEffect::category()
|
||||
{
|
||||
return tr("Render");
|
||||
}
|
||||
|
||||
QString RichTextEffect::description()
|
||||
{
|
||||
return tr("Render formatted rich text over a clip.");
|
||||
}
|
||||
|
||||
EffectType RichTextEffect::type()
|
||||
{
|
||||
return EFFECT_TYPE_EFFECT;
|
||||
}
|
||||
|
||||
olive::TrackType RichTextEffect::subtype()
|
||||
{
|
||||
return olive::kTypeVideo;
|
||||
}
|
||||
|
||||
NodePtr RichTextEffect::Create(Clip *c)
|
||||
{
|
||||
return std::make_shared<RichTextEffect>(c);
|
||||
}
|
||||
|
||||
void RichTextEffect::redraw(double timecode)
|
||||
{
|
||||
QPainter p(&img);
|
||||
@@ -100,8 +133,8 @@ void RichTextEffect::redraw(double timecode)
|
||||
td.setHtml(text_val->GetStringAt(timecode));
|
||||
td.setTextWidth(width);
|
||||
|
||||
int translate_x = qRound(position_x->GetDoubleAt(timecode) + padding);
|
||||
int translate_y = qRound(position_y->GetDoubleAt(timecode) + padding);
|
||||
QPoint translation = position->GetVector2DAt(timecode).toPoint();
|
||||
translation += {padding, padding};
|
||||
|
||||
int doc_height = qRound(td.size().height());
|
||||
|
||||
@@ -118,9 +151,9 @@ void RichTextEffect::redraw(double timecode)
|
||||
|
||||
// If we're not auto-scrolling the vertical direction, respect the vertical alignment
|
||||
if (vertical_align->GetValueAt(timecode).toInt() == Qt::AlignCenter) {
|
||||
translate_y += height / 2 - doc_height / 2;
|
||||
translation.setY(translation.y() + height / 2 - doc_height / 2);
|
||||
} else if (vertical_align->GetValueAt(timecode).toInt() == Qt::AlignBottom) {
|
||||
translate_y += height - doc_height;
|
||||
translation.setY(translation.y() + height - doc_height);
|
||||
}
|
||||
|
||||
// Check if we are autoscrolling
|
||||
@@ -131,7 +164,7 @@ void RichTextEffect::redraw(double timecode)
|
||||
}
|
||||
|
||||
int doc_width = qRound(td.size().width());
|
||||
translate_x += qRound(-doc_width + (img.width() + doc_width) * scroll_progress);
|
||||
translation.setX(translation.x() + qRound(-doc_width + (img.width() + doc_width) * scroll_progress));
|
||||
}
|
||||
|
||||
} else if (auto_scroll_dir == SCROLL_UP || auto_scroll_dir == SCROLL_DOWN) {
|
||||
@@ -142,13 +175,13 @@ void RichTextEffect::redraw(double timecode)
|
||||
scroll_progress = 1.0 - scroll_progress;
|
||||
}
|
||||
|
||||
translate_y += qRound(-doc_height + (img.height() + doc_height)*scroll_progress);
|
||||
translation.setY(translation.y() + qRound(-doc_height + (img.height() + doc_height)*scroll_progress));
|
||||
|
||||
}
|
||||
|
||||
QRect clip_rect = img.rect();
|
||||
clip_rect.translate(-translate_x, -translate_y);
|
||||
p.translate(translate_x, translate_y);
|
||||
clip_rect.translate(-translation);
|
||||
p.translate(translation);
|
||||
|
||||
img.fill(Qt::transparent);
|
||||
|
||||
@@ -188,5 +221,5 @@ void RichTextEffect::redraw(double timecode)
|
||||
|
||||
bool RichTextEffect::AlwaysUpdate()
|
||||
{
|
||||
return autoscroll->GetValueAt(autoscroll->Now()).toInt() != SCROLL_OFF;
|
||||
return autoscroll->GetValueAt(Now()).toInt() != SCROLL_OFF;
|
||||
}
|
||||
|
||||
@@ -1,29 +1,58 @@
|
||||
/***
|
||||
|
||||
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/>.
|
||||
|
||||
***/
|
||||
|
||||
#ifndef RICHTEXTEFFECT_H
|
||||
#define RICHTEXTEFFECT_H
|
||||
|
||||
#include "effects/effect.h"
|
||||
#include "nodes/node.h"
|
||||
|
||||
class RichTextEffect : public Effect {
|
||||
class RichTextEffect : public Node {
|
||||
Q_OBJECT
|
||||
public:
|
||||
RichTextEffect(Clip* c, const EffectMeta *em);
|
||||
void redraw(double timecode);
|
||||
RichTextEffect(Clip* c);
|
||||
|
||||
virtual QString name() override;
|
||||
virtual QString id() override;
|
||||
virtual QString category() override;
|
||||
virtual QString description() override;
|
||||
virtual EffectType type() override;
|
||||
virtual olive::TrackType subtype() override;
|
||||
virtual NodePtr Create(Clip *c) override;
|
||||
|
||||
virtual void redraw(double timecode) override;
|
||||
|
||||
protected:
|
||||
virtual bool AlwaysUpdate() override;
|
||||
private:
|
||||
StringField* text_val;
|
||||
DoubleField* padding_field;
|
||||
DoubleField* position_x;
|
||||
DoubleField* position_y;
|
||||
ComboField* vertical_align;
|
||||
ComboField* autoscroll;
|
||||
StringInput* text_val;
|
||||
DoubleInput* padding_field;
|
||||
Vec2Input* position;
|
||||
ComboInput* vertical_align;
|
||||
ComboInput* autoscroll;
|
||||
|
||||
BoolField* shadow_bool;
|
||||
DoubleField* shadow_angle;
|
||||
DoubleField* shadow_distance;
|
||||
ColorField* shadow_color;
|
||||
DoubleField* shadow_softness;
|
||||
DoubleField* shadow_opacity;
|
||||
BoolInput* shadow_bool;
|
||||
DoubleInput* shadow_angle;
|
||||
DoubleInput* shadow_distance;
|
||||
ColorInput* shadow_color;
|
||||
DoubleInput* shadow_softness;
|
||||
DoubleInput* shadow_opacity;
|
||||
};
|
||||
|
||||
#endif // RICHTEXTEFFECT_H
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2019 Olive Team
|
||||
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 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.
|
||||
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/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
@@ -32,21 +32,18 @@
|
||||
#include "panels/timeline.h"
|
||||
#include "global/debug.h"
|
||||
|
||||
ShakeEffect::ShakeEffect(Clip* c, const EffectMeta *em) : Effect(c, em) {
|
||||
SetFlags(Effect::CoordsFlag);
|
||||
ShakeEffect::ShakeEffect(Clip* c) : Node(c) {
|
||||
SetFlags(Node::CoordsFlag);
|
||||
|
||||
EffectRow* intensity_row = new EffectRow(this, tr("Intensity"));
|
||||
intensity_val = new DoubleField(intensity_row, "intensity");
|
||||
intensity_val = new DoubleInput(this, "intensity", tr("Intensity"));
|
||||
intensity_val->SetMinimum(0);
|
||||
intensity_val->SetDefault(25);
|
||||
|
||||
EffectRow* rotation_row = new EffectRow(this, tr("Rotation"));
|
||||
rotation_val = new DoubleField(rotation_row, "rotation");
|
||||
rotation_val = new DoubleInput(this, "rotation", tr("Rotation"));
|
||||
rotation_val->SetMinimum(0);
|
||||
rotation_val->SetDefault(10);
|
||||
|
||||
EffectRow* frequency_row = new EffectRow(this, tr("Frequency"));
|
||||
frequency_val = new DoubleField(frequency_row, "frequency");
|
||||
frequency_val = new DoubleInput(this, "frequency", tr("Frequency"));
|
||||
frequency_val->SetMinimum(0);
|
||||
frequency_val->SetDefault(5);
|
||||
|
||||
@@ -78,15 +75,42 @@ void ShakeEffect::process_coords(double timecode, GLTextureCoords& coords, int)
|
||||
yoff *= multiplier;
|
||||
rotoff *= rotmult;
|
||||
|
||||
coords.vertexTopLeftX += xoff;
|
||||
coords.vertexTopRightX += xoff;
|
||||
coords.vertexBottomLeftX += xoff;
|
||||
coords.vertexBottomRightX += xoff;
|
||||
coords.matrix.translate(xoff, yoff, 0.0);
|
||||
|
||||
coords.vertexTopLeftY += yoff;
|
||||
coords.vertexTopRightY += yoff;
|
||||
coords.vertexBottomLeftY += yoff;
|
||||
coords.vertexBottomRightY += yoff;
|
||||
coords.matrix.rotate(QQuaternion::fromEulerAngles(0.0f, 0.0f, rotoff));
|
||||
}
|
||||
|
||||
glRotatef(rotoff, 0, 0, 1);
|
||||
QString ShakeEffect::name()
|
||||
{
|
||||
return tr("Shake");
|
||||
}
|
||||
|
||||
QString ShakeEffect::id()
|
||||
{
|
||||
return "org.olivevideoeditor.Olive.shake";
|
||||
}
|
||||
|
||||
QString ShakeEffect::category()
|
||||
{
|
||||
return tr("Distort");
|
||||
}
|
||||
|
||||
QString ShakeEffect::description()
|
||||
{
|
||||
return tr("Simulate a camera shake movement.");
|
||||
}
|
||||
|
||||
EffectType ShakeEffect::type()
|
||||
{
|
||||
return EFFECT_TYPE_EFFECT;
|
||||
}
|
||||
|
||||
olive::TrackType ShakeEffect::subtype()
|
||||
{
|
||||
return olive::kTypeVideo;
|
||||
}
|
||||
|
||||
NodePtr ShakeEffect::Create(Clip *c)
|
||||
{
|
||||
return std::make_shared<ShakeEffect>(c);
|
||||
}
|
||||
|
||||
@@ -1,39 +1,47 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2019 Olive Team
|
||||
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 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.
|
||||
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/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#ifndef SHAKEEFFECT_H
|
||||
#define SHAKEEFFECT_H
|
||||
|
||||
#include "effects/effect.h"
|
||||
#include "nodes/node.h"
|
||||
|
||||
#define RANDOM_VAL_SIZE 30
|
||||
|
||||
class ShakeEffect : public Effect {
|
||||
class ShakeEffect : public Node {
|
||||
Q_OBJECT
|
||||
public:
|
||||
ShakeEffect(Clip* c, const EffectMeta* em);
|
||||
void process_coords(double timecode, GLTextureCoords& coords, int data);
|
||||
ShakeEffect(Clip* c);
|
||||
virtual void process_coords(double timecode, GLTextureCoords& coords, int data) override;
|
||||
|
||||
DoubleField* intensity_val;
|
||||
DoubleField* rotation_val;
|
||||
DoubleField* frequency_val;
|
||||
virtual QString name() override;
|
||||
virtual QString id() override;
|
||||
virtual QString category() override;
|
||||
virtual QString description() override;
|
||||
virtual EffectType type() override;
|
||||
virtual olive::TrackType subtype() override;
|
||||
virtual NodePtr Create(Clip *c) override;
|
||||
|
||||
DoubleInput* intensity_val;
|
||||
DoubleInput* rotation_val;
|
||||
DoubleInput* frequency_val;
|
||||
private:
|
||||
double random_vals[RANDOM_VAL_SIZE];
|
||||
};
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2019 Olive Team
|
||||
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 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.
|
||||
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/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
@@ -34,30 +34,26 @@ const int SMPTE_BARS = 7;
|
||||
const int SMPTE_STRIP_COUNT = 3;
|
||||
const int SMPTE_LOWER_BARS = 4;
|
||||
|
||||
SolidEffect::SolidEffect(Clip* c, const EffectMeta* em) :
|
||||
Effect(c, em)
|
||||
SolidEffect::SolidEffect(Clip* c) :
|
||||
Node(c)
|
||||
{
|
||||
SetFlags(Effect::SuperimposeFlag);
|
||||
SetFlags(Node::SuperimposeFlag);
|
||||
|
||||
// Field for solid type
|
||||
EffectRow* type_row = new EffectRow(this, tr("Type"));
|
||||
solid_type = new ComboField(type_row, "type");
|
||||
solid_type = new ComboInput(this, "type", tr("Type"));
|
||||
solid_type->AddItem(tr("Solid Color"), SOLID_TYPE_COLOR);
|
||||
solid_type->AddItem(tr("SMPTE Bars"), SOLID_TYPE_BARS);
|
||||
solid_type->AddItem(tr("Checkerboard"), SOLID_TYPE_CHECKERBOARD);
|
||||
|
||||
EffectRow* opacity_row = new EffectRow(this, tr("Opacity"));
|
||||
opacity_field = new DoubleField(opacity_row, "opacity");
|
||||
opacity_field = new DoubleInput(this, "opacity", tr("Opacity"));
|
||||
opacity_field->SetMinimum(0);
|
||||
opacity_field->SetDefault(100);
|
||||
opacity_field->SetMaximum(100);
|
||||
|
||||
EffectRow* solid_color_row = new EffectRow(this, tr("Color"));
|
||||
solid_color_field = new ColorField(solid_color_row, "color");
|
||||
solid_color_field = new ColorInput(this, "color", tr("Color"));
|
||||
solid_color_field->SetValueAt(0, QColor(Qt::red));
|
||||
|
||||
EffectRow* checkerboard_size = new EffectRow(this, tr("Checkerboard Size"));
|
||||
checkerboard_size_field = new DoubleField(checkerboard_size, "checker_size");
|
||||
checkerboard_size_field = new DoubleInput(this, "checker_size", tr("Checkerboard Size"));
|
||||
checkerboard_size_field->SetMinimum(1);
|
||||
checkerboard_size_field->SetDefault(10);
|
||||
|
||||
@@ -73,6 +69,41 @@ SolidEffect::SolidEffect(Clip* c, const EffectMeta* em) :
|
||||
fragPath = ":/shaders/solideffect.frag";*/
|
||||
}
|
||||
|
||||
QString SolidEffect::name()
|
||||
{
|
||||
return tr("Solid");
|
||||
}
|
||||
|
||||
QString SolidEffect::id()
|
||||
{
|
||||
return "org.olivevideoeditor.Olive.solid";
|
||||
}
|
||||
|
||||
QString SolidEffect::category()
|
||||
{
|
||||
return tr("Render");
|
||||
}
|
||||
|
||||
QString SolidEffect::description()
|
||||
{
|
||||
return tr("Render a solid color over this clip.");
|
||||
}
|
||||
|
||||
EffectType SolidEffect::type()
|
||||
{
|
||||
return EFFECT_TYPE_EFFECT;
|
||||
}
|
||||
|
||||
olive::TrackType SolidEffect::subtype()
|
||||
{
|
||||
return olive::kTypeVideo;
|
||||
}
|
||||
|
||||
NodePtr SolidEffect::Create(Clip *c)
|
||||
{
|
||||
return std::make_shared<SolidEffect>(c);
|
||||
}
|
||||
|
||||
void SolidEffect::redraw(double timecode) {
|
||||
int w = img.width();
|
||||
int h = img.height();
|
||||
|
||||
@@ -1,31 +1,31 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2019 Olive Team
|
||||
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 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.
|
||||
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/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#ifndef SOLIDEFFECT_H
|
||||
#define SOLIDEFFECT_H
|
||||
|
||||
#include "effects/effect.h"
|
||||
#include "nodes/node.h"
|
||||
|
||||
#include <QImage>
|
||||
|
||||
class SolidEffect : public Effect {
|
||||
class SolidEffect : public Node {
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum SolidType {
|
||||
@@ -34,17 +34,26 @@ public:
|
||||
SOLID_TYPE_CHECKERBOARD
|
||||
};
|
||||
|
||||
SolidEffect(Clip* c, const EffectMeta *em);
|
||||
virtual void redraw(double timecode);
|
||||
SolidEffect(Clip* c);
|
||||
|
||||
virtual QString name() override;
|
||||
virtual QString id() override;
|
||||
virtual QString category() override;
|
||||
virtual QString description() override;
|
||||
virtual EffectType type() override;
|
||||
virtual olive::TrackType subtype() override;
|
||||
virtual NodePtr Create(Clip *c) override;
|
||||
|
||||
virtual void redraw(double timecode) override;
|
||||
|
||||
void SetType(SolidType type);
|
||||
private slots:
|
||||
void ui_update(const QVariant &d);
|
||||
private:
|
||||
ComboField* solid_type;
|
||||
ColorField* solid_color_field;
|
||||
DoubleField* opacity_field;
|
||||
DoubleField* checkerboard_size_field;
|
||||
ComboInput* solid_type;
|
||||
ColorInput* solid_color_field;
|
||||
DoubleInput* opacity_field;
|
||||
DoubleInput* checkerboard_size_field;
|
||||
};
|
||||
|
||||
#endif // SOLIDEFFECT_H
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2019 Olive Team
|
||||
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 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.
|
||||
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/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
@@ -39,94 +39,60 @@
|
||||
#include "timeline/sequence.h"
|
||||
#include "ui/comboboxex.h"
|
||||
#include "ui/colorbutton.h"
|
||||
#include "ui/fontcombobox.h"
|
||||
#include "ui/blur.h"
|
||||
#include "global/config.h"
|
||||
|
||||
TextEffect::TextEffect(Clip* c, const EffectMeta* em) :
|
||||
Effect(c, em)
|
||||
TextEffect::TextEffect(Clip* c) :
|
||||
Node(c)
|
||||
{
|
||||
SetFlags(Effect::SuperimposeFlag);
|
||||
SetFlags(Node::SuperimposeFlag);
|
||||
|
||||
EffectRow* text_field = new EffectRow(this, tr("Text"));
|
||||
text_val = new StringField(text_field, "text", false);
|
||||
text_val->SetColumnSpan(2);
|
||||
text_val = new StringInput(this, "text", tr("Text"), false);
|
||||
|
||||
EffectRow* font_row = new EffectRow(this, tr("Font"));
|
||||
set_font_combobox = new FontField(font_row, "font");
|
||||
set_font_combobox->SetColumnSpan(2);
|
||||
set_font_combobox = new FontInput(this, "font", tr("Font"));
|
||||
|
||||
EffectRow* size_row = new EffectRow(this, tr("Size"));
|
||||
size_val = new DoubleField(size_row, "size");
|
||||
size_val = new DoubleInput(this, "size", tr("Size"));
|
||||
size_val->SetMinimum(0);
|
||||
size_val->SetColumnSpan(2);
|
||||
|
||||
EffectRow* color_row = new EffectRow(this, tr("Color"));
|
||||
set_color_button = new ColorField(color_row, "color");
|
||||
set_color_button->SetColumnSpan(2);
|
||||
set_color_button = new ColorInput(this, "color", tr("Color"));
|
||||
|
||||
EffectRow* alignment_row = new EffectRow(this, tr("Alignment"));
|
||||
halign_field = new ComboField(alignment_row, "halign");
|
||||
halign_field = new ComboInput(this, "halign", tr("Horizontal Alignment"));
|
||||
halign_field->AddItem(tr("Left"), Qt::AlignLeft);
|
||||
halign_field->AddItem(tr("Center"), Qt::AlignHCenter);
|
||||
halign_field->AddItem(tr("Right"), Qt::AlignRight);
|
||||
halign_field->AddItem(tr("Justify"), Qt::AlignJustify);
|
||||
|
||||
valign_field = new ComboField(alignment_row, "valign");
|
||||
valign_field = new ComboInput(this, "valign", tr("Vertical Alignment"));
|
||||
valign_field->AddItem(tr("Top"), Qt::AlignTop);
|
||||
valign_field->AddItem(tr("Center"), Qt::AlignVCenter);
|
||||
valign_field->AddItem(tr("Bottom"), Qt::AlignBottom);
|
||||
|
||||
EffectRow* word_wrap_row = new EffectRow(this, tr("Word Wrap"));
|
||||
word_wrap_field = new BoolField(word_wrap_row, "wordwrap");
|
||||
word_wrap_field->SetColumnSpan(2);
|
||||
word_wrap_field = new BoolInput(this, "wordwrap", tr("Word Wrap"));
|
||||
|
||||
EffectRow* padding_row = new EffectRow(this, tr("Padding"));
|
||||
padding_field = new DoubleField(padding_row, "padding");
|
||||
padding_field->SetColumnSpan(2);
|
||||
padding_field = new DoubleInput(this, "padding", tr("Padding"));
|
||||
|
||||
EffectRow* position_row = new EffectRow(this, tr("Position"));
|
||||
position_x = new DoubleField(position_row, "posx");
|
||||
position_y = new DoubleField(position_row, "posy");
|
||||
position = new Vec2Input(this, "pos", tr("Position"));
|
||||
|
||||
EffectRow* outline_row = new EffectRow(this, tr("Outline"));
|
||||
outline_bool = new BoolField(outline_row, "outline");
|
||||
outline_bool->SetColumnSpan(2);
|
||||
outline_bool = new BoolInput(this, "outline", tr("Outline"));
|
||||
|
||||
EffectRow* outline_color_row = new EffectRow(this, tr("Outline Color"));
|
||||
outline_color = new ColorField(outline_color_row, "outlinecolor");
|
||||
outline_color->SetColumnSpan(2);
|
||||
outline_color = new ColorInput(this, "outlinecolor", tr("Outline Color"));
|
||||
|
||||
EffectRow* outline_width_row = new EffectRow(this, tr("Outline Width"));
|
||||
outline_width = new DoubleField(outline_width_row, "outlinewidth");
|
||||
outline_width->SetColumnSpan(2);
|
||||
outline_width = new DoubleInput(this, "outlinewidth", tr("Outline Width"));
|
||||
outline_width->SetMinimum(0);
|
||||
|
||||
EffectRow* shadow_row = new EffectRow(this, tr("Shadow"));
|
||||
shadow_bool = new BoolField(shadow_row, "shadow");
|
||||
shadow_bool->SetColumnSpan(2);
|
||||
shadow_bool = new BoolInput(this, "shadow", tr("Shadow"));
|
||||
|
||||
EffectRow* shadow_color_row = new EffectRow(this, tr("Shadow Color"));
|
||||
shadow_color = new ColorField(shadow_color_row, "shadowcolor");
|
||||
shadow_color->SetColumnSpan(2);
|
||||
shadow_color = new ColorInput(this, "shadowcolor", tr("Shadow Color"));
|
||||
|
||||
EffectRow* shadow_angle_row = new EffectRow(this, tr("Shadow Angle"));
|
||||
shadow_angle = new DoubleField(shadow_angle_row, "shadowangle");
|
||||
shadow_angle->SetColumnSpan(2);
|
||||
shadow_angle = new DoubleInput(this, "shadowangle", tr("Shadow Angle"));
|
||||
|
||||
EffectRow* shadow_distance_row = new EffectRow(this, tr("Shadow Distance"));
|
||||
shadow_distance = new DoubleField(shadow_distance_row, "shadowdistance");
|
||||
shadow_distance->SetColumnSpan(2);
|
||||
shadow_distance = new DoubleInput(this, "shadowdistance", tr("Shadow Distance"));
|
||||
shadow_distance->SetMinimum(0);
|
||||
|
||||
EffectRow* shadow_softness_row = new EffectRow(this, tr("Shadow Softness"));
|
||||
shadow_softness = new DoubleField(shadow_softness_row, "shadowsoftness");
|
||||
shadow_softness->SetColumnSpan(2);
|
||||
shadow_softness = new DoubleInput(this, "shadowsoftness", tr("Shadow Softness"));
|
||||
shadow_softness->SetMinimum(0);
|
||||
|
||||
EffectRow* shadow_opacity_row = new EffectRow(this, tr("Shadow Opacity"));
|
||||
shadow_opacity = new DoubleField(shadow_opacity_row, "shadowopacity");
|
||||
shadow_opacity->SetColumnSpan(2);
|
||||
shadow_opacity = new DoubleInput(this, "shadowopacity", tr("Shadow Opacity"));
|
||||
shadow_opacity->SetMinimum(0);
|
||||
shadow_opacity->SetMaximum(100);
|
||||
|
||||
@@ -151,8 +117,43 @@ TextEffect::TextEffect(Clip* c, const EffectMeta* em) :
|
||||
connect(shadow_bool, SIGNAL(Toggled(bool)), this, SLOT(shadow_enable(bool)));
|
||||
connect(outline_bool, SIGNAL(Toggled(bool)), this, SLOT(outline_enable(bool)));
|
||||
|
||||
vertPath = "common.vert";
|
||||
fragPath = "dropshadow.frag";
|
||||
shader_vert_path_ = "common.vert";
|
||||
shader_frag_path_ = "dropshadow.frag";
|
||||
}
|
||||
|
||||
QString TextEffect::name()
|
||||
{
|
||||
return tr("Text");
|
||||
}
|
||||
|
||||
QString TextEffect::id()
|
||||
{
|
||||
return "org.olivevideoeditor.Olive.text";
|
||||
}
|
||||
|
||||
QString TextEffect::category()
|
||||
{
|
||||
return tr("Render");
|
||||
}
|
||||
|
||||
QString TextEffect::description()
|
||||
{
|
||||
return tr("Generate simple text over this clip");
|
||||
}
|
||||
|
||||
EffectType TextEffect::type()
|
||||
{
|
||||
return EFFECT_TYPE_EFFECT;
|
||||
}
|
||||
|
||||
olive::TrackType TextEffect::subtype()
|
||||
{
|
||||
return olive::kTypeVideo;
|
||||
}
|
||||
|
||||
NodePtr TextEffect::Create(Clip *c)
|
||||
{
|
||||
return std::make_shared<TextEffect>(c);
|
||||
}
|
||||
|
||||
void TextEffect::redraw(double timecode) {
|
||||
@@ -257,7 +258,7 @@ void TextEffect::redraw(double timecode) {
|
||||
path.addText(text_x, text_y, font, lines.at(i));
|
||||
}
|
||||
|
||||
path.translate(position_x->GetDoubleAt(timecode) + padding, position_y->GetDoubleAt(timecode) + padding);
|
||||
path.translate(position->GetVector2DAt(timecode).toPointF() + QPointF(padding, padding));
|
||||
|
||||
// draw software shadow
|
||||
if (shadow_bool->GetBoolAt(timecode)) {
|
||||
|
||||
@@ -1,63 +1,71 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2019 Olive Team
|
||||
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 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.
|
||||
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/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#ifndef TEXTEFFECT_H
|
||||
#define TEXTEFFECT_H
|
||||
|
||||
#include "effects/effect.h"
|
||||
#include "nodes/node.h"
|
||||
|
||||
#include <QFont>
|
||||
#include <QImage>
|
||||
|
||||
class TextEffect : public Effect {
|
||||
class TextEffect : public Node {
|
||||
Q_OBJECT
|
||||
public:
|
||||
TextEffect(Clip* c, const EffectMeta *em);
|
||||
void redraw(double timecode);
|
||||
TextEffect(Clip* c);
|
||||
|
||||
virtual QString name() override;
|
||||
virtual QString id() override;
|
||||
virtual QString category() override;
|
||||
virtual QString description() override;
|
||||
virtual EffectType type() override;
|
||||
virtual olive::TrackType subtype() override;
|
||||
virtual NodePtr Create(Clip *c) override;
|
||||
|
||||
virtual void redraw(double timecode) override;
|
||||
private slots:
|
||||
void outline_enable(bool);
|
||||
void shadow_enable(bool);
|
||||
private:
|
||||
QFont font;
|
||||
|
||||
StringField* text_val;
|
||||
DoubleField* size_val;
|
||||
ColorField* set_color_button;
|
||||
FontField* set_font_combobox;
|
||||
ComboField* halign_field;
|
||||
ComboField* valign_field;
|
||||
BoolField* word_wrap_field;
|
||||
DoubleField* padding_field;
|
||||
DoubleField* position_x;
|
||||
DoubleField* position_y;
|
||||
StringInput* text_val;
|
||||
DoubleInput* size_val;
|
||||
ColorInput* set_color_button;
|
||||
FontInput* set_font_combobox;
|
||||
ComboInput* halign_field;
|
||||
ComboInput* valign_field;
|
||||
BoolInput* word_wrap_field;
|
||||
DoubleInput* padding_field;
|
||||
Vec2Input* position;
|
||||
|
||||
BoolField* outline_bool;
|
||||
DoubleField* outline_width;
|
||||
ColorField* outline_color;
|
||||
BoolInput* outline_bool;
|
||||
DoubleInput* outline_width;
|
||||
ColorInput* outline_color;
|
||||
|
||||
BoolField* shadow_bool;
|
||||
DoubleField* shadow_angle;
|
||||
DoubleField* shadow_distance;
|
||||
ColorField* shadow_color;
|
||||
DoubleField* shadow_softness;
|
||||
DoubleField* shadow_opacity;
|
||||
BoolInput* shadow_bool;
|
||||
DoubleInput* shadow_angle;
|
||||
DoubleInput* shadow_distance;
|
||||
ColorInput* shadow_color;
|
||||
DoubleInput* shadow_softness;
|
||||
DoubleInput* shadow_opacity;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2019 Olive Team
|
||||
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 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.
|
||||
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/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
@@ -37,66 +37,90 @@
|
||||
#include "ui/collapsiblewidget.h"
|
||||
#include "timeline/clip.h"
|
||||
#include "timeline/sequence.h"
|
||||
#include "panels/viewer.h"
|
||||
#include "global/timing.h"
|
||||
#include "ui/comboboxex.h"
|
||||
#include "ui/colorbutton.h"
|
||||
#include "ui/fontcombobox.h"
|
||||
#include "global/config.h"
|
||||
|
||||
TimecodeEffect::TimecodeEffect(Clip* c, const EffectMeta* em) :
|
||||
Effect(c, em)
|
||||
TimecodeEffect::TimecodeEffect(Clip* c) :
|
||||
Node(c)
|
||||
{
|
||||
SetFlags(Effect::SuperimposeFlag);
|
||||
SetFlags(Node::SuperimposeFlag);
|
||||
|
||||
EffectRow* tc_row = new EffectRow(this, tr("Timecode"));
|
||||
tc_select = new ComboField(tc_row, "tc_selector");
|
||||
tc_select = new ComboInput(this, "tc_selector", tr("Timecode"));
|
||||
tc_select->AddItem(tr("Sequence"), true);
|
||||
tc_select->AddItem(tr("Media"), false);
|
||||
tc_select->SetValueAt(0, true);
|
||||
|
||||
EffectRow* scale_row = new EffectRow(this, tr("Scale"));
|
||||
scale_val = new DoubleField(scale_row, "scale");
|
||||
scale_val->SetColumnSpan(2);
|
||||
scale_val = new DoubleInput(this, "scale", tr("Scale"));
|
||||
scale_val->SetMinimum(1);
|
||||
scale_val->SetDefault(100);
|
||||
scale_val->SetMaximum(1000);
|
||||
|
||||
EffectRow* color_row = new EffectRow(this, tr("Color"));
|
||||
color_val = new ColorField(color_row, "color");
|
||||
color_val->SetColumnSpan(2);
|
||||
color_val = new ColorInput(this, "color", tr("Color"));
|
||||
color_val->SetValueAt(0, QColor(Qt::white));
|
||||
|
||||
EffectRow* color_bg_row = new EffectRow(this, tr("Background Color"));
|
||||
color_bg_val = new ColorField(color_bg_row, "bgcolor");
|
||||
color_bg_val->SetColumnSpan(2);
|
||||
color_bg_val = new ColorInput(this, "bgcolor", tr("Background Color"));
|
||||
color_bg_val->SetValueAt(0, QColor(Qt::black));
|
||||
|
||||
EffectRow* bg_alpha_row = new EffectRow(this, tr("Background Opacity"));
|
||||
bg_alpha = new DoubleField(bg_alpha_row, "bgalpha");
|
||||
bg_alpha->SetColumnSpan(2);
|
||||
bg_alpha = new DoubleInput(this, "bgalpha", tr("Background Opacity"));
|
||||
bg_alpha->SetMinimum(0);
|
||||
bg_alpha->SetDefault(50);
|
||||
bg_alpha->SetMaximum(100);
|
||||
|
||||
EffectRow* offset_row = new EffectRow(this, tr("Offset"));
|
||||
offset_x_val = new DoubleField(offset_row, "offsetx");
|
||||
offset_y_val = new DoubleField(offset_row, "offsety");
|
||||
offset_val = new Vec2Input(this, "offset", tr("Offset"));
|
||||
offset_val->SetDefault(0);
|
||||
|
||||
EffectRow* prepent_text_row = new EffectRow(this, tr("Prepend"));
|
||||
prepend_text = new StringField(prepent_text_row, "prepend", false);
|
||||
prepend_text->SetColumnSpan(2);
|
||||
prepend_text = new StringInput(this, "prepend", tr("Prepend"), false);
|
||||
}
|
||||
|
||||
QString TimecodeEffect::name()
|
||||
{
|
||||
return tr("Timecode");
|
||||
}
|
||||
|
||||
QString TimecodeEffect::id()
|
||||
{
|
||||
return "org.olivevideoeditor.Olive.timecode";
|
||||
}
|
||||
|
||||
QString TimecodeEffect::category()
|
||||
{
|
||||
return tr("Render");
|
||||
}
|
||||
|
||||
QString TimecodeEffect::description()
|
||||
{
|
||||
return tr("Render the media or sequence timecode on this clip.");
|
||||
}
|
||||
|
||||
EffectType TimecodeEffect::type()
|
||||
{
|
||||
return EFFECT_TYPE_EFFECT;
|
||||
}
|
||||
|
||||
olive::TrackType TimecodeEffect::subtype()
|
||||
{
|
||||
return olive::kTypeVideo;
|
||||
}
|
||||
|
||||
NodePtr TimecodeEffect::Create(Clip *c)
|
||||
{
|
||||
return std::make_shared<TimecodeEffect>(c);
|
||||
}
|
||||
|
||||
|
||||
void TimecodeEffect::redraw(double timecode) {
|
||||
Sequence* sequence = parent_clip->track()->sequence();
|
||||
|
||||
if (tc_select->GetValueAt(timecode).toBool()) {
|
||||
display_timecode = prepend_text->GetStringAt(timecode) + frame_to_timecode(olive::ActiveSequence->playhead,
|
||||
olive::CurrentConfig.timecode_view,
|
||||
olive::ActiveSequence->frame_rate);
|
||||
display_timecode = prepend_text->GetStringAt(timecode) + frame_to_timecode(sequence->playhead,
|
||||
olive::config.timecode_view,
|
||||
sequence->frame_rate);
|
||||
} else {
|
||||
double media_rate = parent_clip->media_frame_rate();
|
||||
display_timecode = prepend_text->GetStringAt(timecode) + frame_to_timecode(qRound(timecode * media_rate),
|
||||
olive::CurrentConfig.timecode_view,
|
||||
olive::config.timecode_view,
|
||||
media_rate);
|
||||
}
|
||||
img.fill(Qt::transparent);
|
||||
@@ -115,18 +139,17 @@ void TimecodeEffect::redraw(double timecode) {
|
||||
|
||||
QPainterPath path;
|
||||
|
||||
int text_x, text_y, rect_y, offset_x, offset_y;
|
||||
int text_x, text_y, rect_y;
|
||||
int text_height = fm.height();
|
||||
int text_width = fm.width(display_timecode);
|
||||
QColor background_color = color_bg_val->GetColorAt(timecode);
|
||||
int alpha_val = qCeil(bg_alpha->GetDoubleAt(timecode)*2.55);
|
||||
background_color.setAlpha(alpha_val);
|
||||
|
||||
offset_x = int(offset_x_val->GetDoubleAt(timecode));
|
||||
offset_y = int(offset_y_val->GetDoubleAt(timecode));
|
||||
QVector2D offset = offset_val->GetVector2DAt(timecode);
|
||||
|
||||
text_x = offset_x + (width/2) - (text_width/2);
|
||||
text_y = offset_y + height - height/10;
|
||||
text_x = offset.x() + (width/2) - (text_width/2);
|
||||
text_y = offset.y() + height - height/10;
|
||||
rect_y = text_y + fm.descent() - text_height;
|
||||
|
||||
path.addText(text_x, text_y, font, display_timecode);
|
||||
|
||||
@@ -1,44 +1,52 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2019 Olive Team
|
||||
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 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.
|
||||
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/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#ifndef TIMECODEEFFECT_H
|
||||
#define TIMECODEEFFECT_H
|
||||
|
||||
#include "effects/effect.h"
|
||||
#include "nodes/node.h"
|
||||
|
||||
#include <QFont>
|
||||
#include <QImage>
|
||||
|
||||
class TimecodeEffect : public Effect {
|
||||
class TimecodeEffect : public Node {
|
||||
Q_OBJECT
|
||||
public:
|
||||
TimecodeEffect(Clip* c, const EffectMeta *em);
|
||||
void redraw(double timecode);
|
||||
DoubleField* scale_val;
|
||||
ColorField* color_val;
|
||||
ColorField* color_bg_val;
|
||||
DoubleField* bg_alpha;
|
||||
DoubleField* offset_x_val;
|
||||
DoubleField* offset_y_val;
|
||||
StringField* prepend_text;
|
||||
ComboField* tc_select;
|
||||
TimecodeEffect(Clip* c);
|
||||
|
||||
virtual QString name() override;
|
||||
virtual QString id() override;
|
||||
virtual QString category() override;
|
||||
virtual QString description() override;
|
||||
virtual EffectType type() override;
|
||||
virtual olive::TrackType subtype() override;
|
||||
virtual NodePtr Create(Clip *c) override;
|
||||
|
||||
virtual void redraw(double timecode) override;
|
||||
DoubleInput* scale_val;
|
||||
ColorInput* color_val;
|
||||
ColorInput* color_bg_val;
|
||||
DoubleInput* bg_alpha;
|
||||
Vec2Input* offset_val;
|
||||
StringInput* prepend_text;
|
||||
ComboInput* tc_select;
|
||||
|
||||
protected:
|
||||
virtual bool AlwaysUpdate() override;
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2019 Olive Team
|
||||
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 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.
|
||||
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/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
@@ -27,51 +27,88 @@
|
||||
#include "timeline/clip.h"
|
||||
#include "timeline/sequence.h"
|
||||
|
||||
ToneEffect::ToneEffect(Clip* c, const EffectMeta *em) : Effect(c, em), sinX(INT_MIN) {
|
||||
EffectRow* type_row = new EffectRow(this, tr("Type"));
|
||||
type_val = new ComboField(type_row, "type");
|
||||
ToneEffect::ToneEffect(Clip* c) : Node(c), sinX(INT_MIN) {
|
||||
type_val = new ComboInput(this, "type", tr("Type"));
|
||||
type_val->AddItem(tr("Sine"), TONE_TYPE_SINE);
|
||||
|
||||
EffectRow* frequency_row = new EffectRow(this, tr("Frequency"));
|
||||
freq_val = new DoubleField(frequency_row, "frequency");
|
||||
freq_val = new DoubleInput(this, "frequency", tr("Frequency"));
|
||||
freq_val->SetMinimum(20);
|
||||
freq_val->SetMaximum(20000);
|
||||
freq_val->SetDefault(1000);
|
||||
|
||||
EffectRow* amount_row = new EffectRow(this, tr("Amount"));
|
||||
amount_val = new DoubleField(amount_row, "amount");
|
||||
amount_val = new DoubleInput(this, "amount", tr("Amount"));
|
||||
amount_val->SetMinimum(0);
|
||||
amount_val->SetMaximum(100);
|
||||
amount_val->SetDefault(25);
|
||||
|
||||
EffectRow* mix_row = new EffectRow(this, tr("Mix"));
|
||||
mix_val = new BoolField(mix_row, "mix");
|
||||
mix_val = new BoolInput(this, "mix", tr("Mix"));
|
||||
mix_val->SetValueAt(0, true);
|
||||
}
|
||||
|
||||
void ToneEffect::process_audio(double timecode_start, double timecode_end, quint8 *samples, int nb_bytes, int) {
|
||||
double interval = (timecode_end - timecode_start)/nb_bytes;
|
||||
for (int i=0;i<nb_bytes;i+=4) {
|
||||
QString ToneEffect::name()
|
||||
{
|
||||
return tr("Tone");
|
||||
}
|
||||
|
||||
QString ToneEffect::id()
|
||||
{
|
||||
return "org.olivevideoeditor.Olive.tone";
|
||||
}
|
||||
|
||||
QString ToneEffect::description()
|
||||
{
|
||||
return tr("Generate a sine wave tone to mix into this clip's audio.");
|
||||
}
|
||||
|
||||
EffectType ToneEffect::type()
|
||||
{
|
||||
return EFFECT_TYPE_EFFECT;
|
||||
}
|
||||
|
||||
olive::TrackType ToneEffect::subtype()
|
||||
{
|
||||
return olive::kTypeAudio;
|
||||
}
|
||||
|
||||
NodePtr ToneEffect::Create(Clip *c)
|
||||
{
|
||||
return std::make_shared<ToneEffect>(c);
|
||||
}
|
||||
|
||||
void ToneEffect::process_audio(double timecode_start,
|
||||
double timecode_end,
|
||||
float **samples,
|
||||
int nb_samples,
|
||||
int channel_count,
|
||||
int type) {
|
||||
|
||||
Q_UNUSED(type)
|
||||
|
||||
double interval = (timecode_end - timecode_start)/nb_samples;
|
||||
|
||||
for (int i=0;i<nb_samples;i++) {
|
||||
|
||||
double timecode = timecode_start+(interval*i);
|
||||
float tone_sample = qSin((2*M_PI*sinX*freq_val->GetDoubleAt(timecode))
|
||||
/parent_clip->track()->sequence()->audio_frequency)
|
||||
*log_volume(amount_val->GetDoubleAt(timecode)*0.01);
|
||||
|
||||
qint16 left_tone_sample = qint16(qRound(qSin((2*M_PI*sinX*freq_val->GetDoubleAt(timecode))
|
||||
/parent_clip->sequence->audio_frequency)
|
||||
*log_volume(amount_val->GetDoubleAt(timecode)*0.01)*INT16_MAX));
|
||||
qint16 right_tone_sample = left_tone_sample;
|
||||
for (int j=0;j<channel_count;j++) {
|
||||
|
||||
if (mix_val->GetBoolAt(timecode)) {
|
||||
|
||||
// mix with source audio
|
||||
samples[j][i] += tone_sample;
|
||||
|
||||
} else {
|
||||
|
||||
// replace source audio
|
||||
samples[j][i] = tone_sample;
|
||||
|
||||
}
|
||||
|
||||
// mix with source audio
|
||||
if (mix_val->GetBoolAt(timecode)) {
|
||||
qint16 left_sample = qint16(((samples[i+1] & 0xFF) << 8) | (samples[i] & 0xFF));
|
||||
qint16 right_sample = qint16(((samples[i+3] & 0xFF) << 8) | (samples[i+2] & 0xFF));
|
||||
left_tone_sample = mix_audio_sample(left_tone_sample, left_sample);
|
||||
right_tone_sample = mix_audio_sample(right_tone_sample, right_sample);
|
||||
}
|
||||
|
||||
samples[i+3] = quint8(right_tone_sample >> 8);
|
||||
samples[i+2] = quint8(right_tone_sample);
|
||||
samples[i+1] = quint8(left_tone_sample >> 8);
|
||||
samples[i] = quint8(left_tone_sample);
|
||||
|
||||
sinX++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,39 +1,53 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2019 Olive Team
|
||||
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 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.
|
||||
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/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#ifndef TONEEFFECT_H
|
||||
#define TONEEFFECT_H
|
||||
|
||||
#include "effects/effect.h"
|
||||
#include "nodes/node.h"
|
||||
|
||||
class ToneEffect : public Effect {
|
||||
class ToneEffect : public Node {
|
||||
Q_OBJECT
|
||||
public:
|
||||
ToneEffect(Clip* c, const EffectMeta* em);
|
||||
void process_audio(double timecode_start, double timecode_end, quint8* samples, int nb_bytes, int channel_count);
|
||||
ToneEffect(Clip* c);
|
||||
|
||||
virtual QString name() override;
|
||||
virtual QString id() override;
|
||||
virtual QString description() override;
|
||||
virtual EffectType type() override;
|
||||
virtual olive::TrackType subtype() override;
|
||||
virtual NodePtr Create(Clip *c) override;
|
||||
|
||||
virtual void process_audio(double timecode_start,
|
||||
double timecode_end,
|
||||
float **samples,
|
||||
int nb_samples,
|
||||
int channel_count,
|
||||
int type) override;
|
||||
|
||||
ComboField* type_val;
|
||||
DoubleField* freq_val;
|
||||
DoubleField* amount_val;
|
||||
BoolField* mix_val;
|
||||
private:
|
||||
ComboInput* type_val;
|
||||
DoubleInput* freq_val;
|
||||
DoubleInput* amount_val;
|
||||
BoolInput* mix_val;
|
||||
|
||||
int sinX;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2019 Olive Team
|
||||
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 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.
|
||||
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/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
@@ -43,122 +43,131 @@
|
||||
#include "panels/viewer.h"
|
||||
#include "ui/viewerwidget.h"
|
||||
|
||||
TransformEffect::TransformEffect(Clip* c, const EffectMeta* em) : Effect(c, em) {
|
||||
SetFlags(Effect::CoordsFlag);
|
||||
TransformEffect::TransformEffect(Clip* c) : Node(c) {
|
||||
SetFlags(Node::CoordsFlag);
|
||||
|
||||
EffectRow* position_row = new EffectRow(this, tr("Position"));
|
||||
position = new Vec2Input(this, "pos", tr("Position"));
|
||||
|
||||
position_x = new DoubleField(position_row, "posx"); // position X
|
||||
position_y = new DoubleField(position_row, "posy"); // position Y
|
||||
scale = new Vec2Input(this, "scale", tr("Scale"));
|
||||
scale->SetMinimum(0);
|
||||
scale->SetDefault(100);
|
||||
|
||||
EffectRow* scale_row = new EffectRow(this, tr("Scale"));
|
||||
uniform_scale_field = new BoolInput(this, "uniformscale", tr("Uniform Scale"));
|
||||
connect(uniform_scale_field, SIGNAL(Toggled(bool)), scale, SLOT(SetSingleValueMode(bool)));
|
||||
uniform_scale_field->SetValueAt(0, true);
|
||||
|
||||
// scale X (and Y is uniform scale is selected)
|
||||
scale_x = new DoubleField(scale_row, "scalex");
|
||||
scale_x->SetMinimum(0);
|
||||
rotation = new DoubleInput(this, "rotation", tr("Rotation"));
|
||||
|
||||
// scale Y (disabled if uniform scale is selected)
|
||||
scale_y = new DoubleField(scale_row, "scaley");
|
||||
scale_y->SetMinimum(0);
|
||||
|
||||
EffectRow* uniform_scale_row = new EffectRow(this, tr("Uniform Scale"));
|
||||
|
||||
uniform_scale_field = new BoolField(uniform_scale_row, "uniformscale"); // uniform scale option
|
||||
|
||||
EffectRow* rotation_row = new EffectRow(this, tr("Rotation"));
|
||||
|
||||
rotation = new DoubleField(rotation_row, "rotation");
|
||||
|
||||
EffectRow* anchor_point_row = new EffectRow(this, tr("Anchor Point"));
|
||||
|
||||
anchor_x_box = new DoubleField(anchor_point_row, "anchorx"); // anchor point X
|
||||
anchor_y_box = new DoubleField(anchor_point_row, "anchory"); // anchor point Y
|
||||
|
||||
EffectRow* opacity_row = new EffectRow(this, tr("Opacity"));
|
||||
anchor_point = new Vec2Input(this, "anchor", tr("Anchor Point"));
|
||||
anchor_point->SetDefault(0);
|
||||
|
||||
// opacity
|
||||
opacity = new DoubleField(opacity_row, "opacity");
|
||||
opacity = new DoubleInput(this, "opacity", tr("Opacity"));
|
||||
opacity->SetMinimum(0);
|
||||
opacity->SetMaximum(100);
|
||||
opacity->SetDefault(100);
|
||||
|
||||
EffectRow* blend_mode_row = new EffectRow(this, tr("Blend Mode"));
|
||||
|
||||
// blend mode
|
||||
blend_mode_box = new ComboField(blend_mode_row, "blendmode");
|
||||
blend_mode_box->SetColumnSpan(2);
|
||||
blend_mode_box->AddItem(tr("Normal"), "");
|
||||
// TEMP - Create matrix output
|
||||
EffectRow* matrix_output = new EffectRow(this, "matrix", "Matrix", false, false);
|
||||
matrix_output->SetOutputDataType(olive::nodes::kMatrix);
|
||||
|
||||
// set up gizmos
|
||||
top_left_gizmo = add_gizmo(GIZMO_TYPE_DOT);
|
||||
top_left_gizmo->set_cursor(Qt::SizeFDiagCursor);
|
||||
top_left_gizmo->x_field1 = scale_x;
|
||||
top_left_gizmo->x_field1 = static_cast<DoubleField*>(scale->Field(0));
|
||||
|
||||
top_center_gizmo = add_gizmo(GIZMO_TYPE_DOT);
|
||||
top_center_gizmo->set_cursor(Qt::SizeVerCursor);
|
||||
top_center_gizmo->y_field1 = scale_x;
|
||||
top_center_gizmo->y_field1 = static_cast<DoubleField*>(scale->Field(0));
|
||||
|
||||
top_right_gizmo = add_gizmo(GIZMO_TYPE_DOT);
|
||||
top_right_gizmo->set_cursor(Qt::SizeBDiagCursor);
|
||||
top_right_gizmo->x_field1 = scale_x;
|
||||
top_right_gizmo->x_field1 = static_cast<DoubleField*>(scale->Field(0));
|
||||
|
||||
bottom_left_gizmo = add_gizmo(GIZMO_TYPE_DOT);
|
||||
bottom_left_gizmo->set_cursor(Qt::SizeBDiagCursor);
|
||||
bottom_left_gizmo->x_field1 = scale_x;
|
||||
bottom_left_gizmo->x_field1 = static_cast<DoubleField*>(scale->Field(0));
|
||||
|
||||
bottom_center_gizmo = add_gizmo(GIZMO_TYPE_DOT);
|
||||
bottom_center_gizmo->set_cursor(Qt::SizeVerCursor);
|
||||
bottom_center_gizmo->y_field1 = scale_x;
|
||||
bottom_center_gizmo->y_field1 = static_cast<DoubleField*>(scale->Field(0));
|
||||
|
||||
bottom_right_gizmo = add_gizmo(GIZMO_TYPE_DOT);
|
||||
bottom_right_gizmo->set_cursor(Qt::SizeFDiagCursor);
|
||||
bottom_right_gizmo->x_field1 = scale_x;
|
||||
bottom_right_gizmo->x_field1 = static_cast<DoubleField*>(scale->Field(0));
|
||||
|
||||
left_center_gizmo = add_gizmo(GIZMO_TYPE_DOT);
|
||||
left_center_gizmo->set_cursor(Qt::SizeHorCursor);
|
||||
left_center_gizmo->x_field1 = scale_x;
|
||||
left_center_gizmo->x_field1 = static_cast<DoubleField*>(scale->Field(0));
|
||||
|
||||
right_center_gizmo = add_gizmo(GIZMO_TYPE_DOT);
|
||||
right_center_gizmo->set_cursor(Qt::SizeHorCursor);
|
||||
right_center_gizmo->x_field1 = scale_x;
|
||||
right_center_gizmo->x_field1 = static_cast<DoubleField*>(scale->Field(0));
|
||||
|
||||
anchor_gizmo = add_gizmo(GIZMO_TYPE_TARGET);
|
||||
anchor_gizmo->set_cursor(Qt::SizeAllCursor);
|
||||
anchor_gizmo->x_field1 = anchor_x_box;
|
||||
anchor_gizmo->y_field1 = anchor_y_box;
|
||||
anchor_gizmo->x_field2 = position_x;
|
||||
anchor_gizmo->y_field2 = position_y;
|
||||
anchor_gizmo->x_field1 = static_cast<DoubleField*>(anchor_point->Field(0));
|
||||
anchor_gizmo->y_field1 = static_cast<DoubleField*>(anchor_point->Field(1));
|
||||
anchor_gizmo->x_field2 = static_cast<DoubleField*>(position->Field(0));
|
||||
anchor_gizmo->y_field2 = static_cast<DoubleField*>(position->Field(1));
|
||||
|
||||
rotate_gizmo = add_gizmo(GIZMO_TYPE_DOT);
|
||||
rotate_gizmo->color = Qt::green;
|
||||
rotate_gizmo->set_cursor(Qt::SizeAllCursor);
|
||||
rotate_gizmo->x_field1 = rotation;
|
||||
rotate_gizmo->x_field1 = static_cast<DoubleField*>(rotation->Field(0));
|
||||
|
||||
rect_gizmo = add_gizmo(GIZMO_TYPE_POLY);
|
||||
rect_gizmo->x_field1 = position_x;
|
||||
rect_gizmo->y_field1 = position_y;
|
||||
rect_gizmo->x_field1 = static_cast<DoubleField*>(position->Field(0));
|
||||
rect_gizmo->y_field1 = static_cast<DoubleField*>(position->Field(1));
|
||||
|
||||
connect(uniform_scale_field, SIGNAL(Toggled(bool)), this, SLOT(toggle_uniform_scale(bool)));
|
||||
|
||||
// set defaults
|
||||
uniform_scale_field->SetValueAt(0, true);
|
||||
blend_mode_box->SetValueAt(0, "");
|
||||
anchor_x_box->SetDefault(0);
|
||||
anchor_y_box->SetDefault(0);
|
||||
opacity->SetDefault(100);
|
||||
scale_x->SetDefault(100);
|
||||
scale_y->SetDefault(100);
|
||||
|
||||
refresh();
|
||||
}
|
||||
|
||||
QString TransformEffect::name()
|
||||
{
|
||||
return tr("Transform");
|
||||
}
|
||||
|
||||
QString TransformEffect::id()
|
||||
{
|
||||
return "org.olivevideoeditor.Olive.transform";
|
||||
}
|
||||
|
||||
QString TransformEffect::category()
|
||||
{
|
||||
return tr("Distort");
|
||||
}
|
||||
|
||||
QString TransformEffect::description()
|
||||
{
|
||||
return tr("Transform the position, scale, and rotation of this clip.");
|
||||
}
|
||||
|
||||
EffectType TransformEffect::type()
|
||||
{
|
||||
return EFFECT_TYPE_EFFECT;
|
||||
}
|
||||
|
||||
olive::TrackType TransformEffect::subtype()
|
||||
{
|
||||
return olive::kTypeVideo;
|
||||
}
|
||||
|
||||
NodePtr TransformEffect::Create(Clip *c)
|
||||
{
|
||||
return std::make_shared<TransformEffect>(c);
|
||||
}
|
||||
|
||||
void TransformEffect::refresh() {
|
||||
if (parent_clip != nullptr && parent_clip->sequence != nullptr) {
|
||||
if (parent_clip != nullptr && parent_clip->track()->sequence() != nullptr) {
|
||||
|
||||
position_x->SetDefault(parent_clip->sequence->width/2);
|
||||
position_y->SetDefault(parent_clip->sequence->height/2);
|
||||
position->SetDefault({parent_clip->track()->sequence()->width*0.5,
|
||||
parent_clip->track()->sequence()->height*0.5});
|
||||
|
||||
double x_percent_multipler = 200.0 / parent_clip->sequence->width;
|
||||
double y_percent_multipler = 200.0 / parent_clip->sequence->height;
|
||||
double x_percent_multipler = 200.0 / parent_clip->track()->sequence()->width;
|
||||
double y_percent_multipler = 200.0 / parent_clip->track()->sequence()->height;
|
||||
|
||||
top_left_gizmo->x_field_multi1 = -x_percent_multipler;
|
||||
top_left_gizmo->y_field_multi1 = -y_percent_multipler;
|
||||
@@ -178,7 +187,10 @@ void TransformEffect::refresh() {
|
||||
}
|
||||
|
||||
void TransformEffect::toggle_uniform_scale(bool enabled) {
|
||||
scale_y->SetEnabled(!enabled);
|
||||
scale->SetSingleValueMode(enabled);
|
||||
|
||||
DoubleField* scale_x = static_cast<DoubleField*>(scale->Field(0));
|
||||
DoubleField* scale_y = static_cast<DoubleField*>(scale->Field(1));
|
||||
|
||||
top_center_gizmo->y_field1 = enabled ? scale_x : scale_y;
|
||||
bottom_center_gizmo->y_field1 = enabled ? scale_x : scale_y;
|
||||
@@ -190,51 +202,55 @@ void TransformEffect::toggle_uniform_scale(bool enabled) {
|
||||
|
||||
void TransformEffect::process_coords(double timecode, GLTextureCoords& coords, int) {
|
||||
// position
|
||||
glTranslated(position_x->GetDoubleAt(timecode)-(parent_clip->sequence->width/2),
|
||||
position_y->GetDoubleAt(timecode)-(parent_clip->sequence->height/2),
|
||||
0);
|
||||
coords.matrix.translate(position->GetVector2DAt(timecode)
|
||||
- QVector2D(parent_clip->track()->sequence()->width*0.5f,
|
||||
parent_clip->track()->sequence()->height*0.5f));
|
||||
|
||||
// anchor point
|
||||
int anchor_x_offset = qRound(anchor_x_box->GetDoubleAt(timecode));
|
||||
int anchor_y_offset = qRound(anchor_y_box->GetDoubleAt(timecode));
|
||||
coords.vertexTopLeftX -= anchor_x_offset;
|
||||
coords.vertexTopRightX -= anchor_x_offset;
|
||||
coords.vertexBottomLeftX -= anchor_x_offset;
|
||||
coords.vertexBottomRightX -= anchor_x_offset;
|
||||
coords.vertexTopLeftY -= anchor_y_offset;
|
||||
coords.vertexTopRightY -= anchor_y_offset;
|
||||
coords.vertexBottomLeftY -= anchor_y_offset;
|
||||
coords.vertexBottomRightY -= anchor_y_offset;
|
||||
QVector2D anchor_val = anchor_point->GetVector2DAt(timecode);
|
||||
|
||||
coords.vertex_top_left -= anchor_val;
|
||||
coords.vertex_top_right -= anchor_val;
|
||||
coords.vertex_bottom_left -= anchor_val;
|
||||
coords.vertex_bottom_right -= anchor_val;
|
||||
|
||||
// rotation
|
||||
glRotated(rotation->GetDoubleAt(timecode), 0, 0, 1);
|
||||
coords.matrix.rotate(QQuaternion::fromEulerAngles(0, 0, float(rotation->GetDoubleAt(timecode))));
|
||||
|
||||
// scale
|
||||
double sx = scale_x->GetDoubleAt(timecode)*0.01;
|
||||
double sy = (uniform_scale_field->GetBoolAt(timecode)) ? sx : scale_y->GetDoubleAt(timecode)*0.01;
|
||||
glScaled(sx, sy, 1);
|
||||
|
||||
// blend mode
|
||||
coords.blendmode = blend_mode_box->GetValueAt(timecode).toInt();
|
||||
coords.matrix.scale(scale->GetVector2DAt(timecode)*0.01f);
|
||||
|
||||
// opacity
|
||||
coords.opacity *= float(opacity->GetDoubleAt(timecode)*0.01);
|
||||
}
|
||||
|
||||
QVector3D LerpVector3D(const QVector3D& a, const QVector3D& b, float t) {
|
||||
return QVector3D(
|
||||
float_lerp(a.x(), b.x(), t),
|
||||
float_lerp(a.y(), b.y(), t),
|
||||
float_lerp(a.z(), b.z(), t)
|
||||
);
|
||||
}
|
||||
|
||||
void TransformEffect::gizmo_draw(double, GLTextureCoords& coords) {
|
||||
top_left_gizmo->world_pos[0] = QPoint(coords.vertexTopLeftX, coords.vertexTopLeftY);
|
||||
top_center_gizmo->world_pos[0] = QPoint(lerp(coords.vertexTopLeftX, coords.vertexTopRightX, 0.5), lerp(coords.vertexTopLeftY, coords.vertexTopRightY, 0.5));
|
||||
top_right_gizmo->world_pos[0] = QPoint(coords.vertexTopRightX, coords.vertexTopRightY);
|
||||
right_center_gizmo->world_pos[0] = QPoint(lerp(coords.vertexTopRightX, coords.vertexBottomRightX, 0.5), lerp(coords.vertexTopRightY, coords.vertexBottomRightY, 0.5));
|
||||
bottom_right_gizmo->world_pos[0] = QPoint(coords.vertexBottomRightX, coords.vertexBottomRightY);
|
||||
bottom_center_gizmo->world_pos[0] = QPoint(lerp(coords.vertexBottomRightX, coords.vertexBottomLeftX, 0.5), lerp(coords.vertexBottomRightY, coords.vertexBottomLeftY, 0.5));
|
||||
bottom_left_gizmo->world_pos[0] = QPoint(coords.vertexBottomLeftX, coords.vertexBottomLeftY);
|
||||
left_center_gizmo->world_pos[0] = QPoint(lerp(coords.vertexBottomLeftX, coords.vertexTopLeftX, 0.5), lerp(coords.vertexBottomLeftY, coords.vertexTopLeftY, 0.5));
|
||||
top_left_gizmo->world_pos[0] = coords.vertex_top_left;
|
||||
top_right_gizmo->world_pos[0] = coords.vertex_top_right;
|
||||
bottom_right_gizmo->world_pos[0] = coords.vertex_bottom_right;
|
||||
bottom_left_gizmo->world_pos[0] = coords.vertex_bottom_left;
|
||||
|
||||
top_center_gizmo->world_pos[0] = LerpVector3D(coords.vertex_top_left, coords.vertex_top_right, 0.5);
|
||||
right_center_gizmo->world_pos[0] = LerpVector3D(coords.vertex_top_right, coords.vertex_bottom_right, 0.5);
|
||||
bottom_center_gizmo->world_pos[0] = LerpVector3D(coords.vertex_bottom_right, coords.vertex_bottom_left, 0.5);
|
||||
left_center_gizmo->world_pos[0] = LerpVector3D(coords.vertex_bottom_left, coords.vertex_top_left, 0.5);
|
||||
|
||||
rotate_gizmo->world_pos[0] = QPoint(lerp(top_center_gizmo->world_pos[0].x(), bottom_center_gizmo->world_pos[0].x(), -0.1), lerp(top_center_gizmo->world_pos[0].y(), bottom_center_gizmo->world_pos[0].y(), -0.1));
|
||||
rotate_gizmo->world_pos[0] = QVector3D(
|
||||
float_lerp(top_center_gizmo->world_pos[0].x(), bottom_center_gizmo->world_pos[0].x(), 0.5f),
|
||||
float_lerp(top_center_gizmo->world_pos[0].y(), bottom_center_gizmo->world_pos[0].y(), -0.1f),
|
||||
0.0f
|
||||
);
|
||||
|
||||
rect_gizmo->world_pos[0] = QPoint(coords.vertexTopLeftX, coords.vertexTopLeftY);
|
||||
rect_gizmo->world_pos[1] = QPoint(coords.vertexTopRightX, coords.vertexTopRightY);
|
||||
rect_gizmo->world_pos[2] = QPoint(coords.vertexBottomRightX, coords.vertexBottomRightY);
|
||||
rect_gizmo->world_pos[3] = QPoint(coords.vertexBottomLeftX, coords.vertexBottomLeftY);
|
||||
rect_gizmo->world_pos[0] = coords.vertex_top_left;
|
||||
rect_gizmo->world_pos[1] = coords.vertex_top_right;
|
||||
rect_gizmo->world_pos[2] = coords.vertex_bottom_right;
|
||||
rect_gizmo->world_pos[3] = coords.vertex_bottom_left;
|
||||
}
|
||||
|
||||
@@ -1,49 +1,56 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2019 Olive Team
|
||||
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 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.
|
||||
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/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#ifndef TRANSFORMEFFECT_H
|
||||
#define TRANSFORMEFFECT_H
|
||||
|
||||
#include "effects/effect.h"
|
||||
#include "nodes/node.h"
|
||||
|
||||
class TransformEffect : public Effect {
|
||||
class TransformEffect : public Node {
|
||||
Q_OBJECT
|
||||
public:
|
||||
TransformEffect(Clip* c, const EffectMeta* em);
|
||||
void refresh();
|
||||
void process_coords(double timecode, GLTextureCoords& coords, int data);
|
||||
TransformEffect(Clip* c);
|
||||
|
||||
virtual QString name() override;
|
||||
virtual QString id() override;
|
||||
virtual QString category() override;
|
||||
virtual QString description() override;
|
||||
virtual EffectType type() override;
|
||||
virtual olive::TrackType subtype() override;
|
||||
virtual NodePtr Create(Clip *c) override;
|
||||
|
||||
virtual void refresh() override;
|
||||
virtual void process_coords(double timecode, GLTextureCoords& coords, int data) override;
|
||||
|
||||
virtual void gizmo_draw(double timecode, GLTextureCoords& coords) override;
|
||||
|
||||
void gizmo_draw(double timecode, GLTextureCoords& coords);
|
||||
public slots:
|
||||
void toggle_uniform_scale(bool enabled);
|
||||
|
||||
private:
|
||||
DoubleField* position_x;
|
||||
DoubleField* position_y;
|
||||
DoubleField* scale_x;
|
||||
DoubleField* scale_y;
|
||||
BoolField* uniform_scale_field;
|
||||
DoubleField* rotation;
|
||||
DoubleField* anchor_x_box;
|
||||
DoubleField* anchor_y_box;
|
||||
DoubleField* opacity;
|
||||
ComboField* blend_mode_box;
|
||||
Vec2Input* position;
|
||||
Vec2Input* scale;
|
||||
BoolInput* uniform_scale_field;
|
||||
DoubleInput* rotation;
|
||||
Vec2Input* anchor_point;
|
||||
DoubleInput* opacity;
|
||||
|
||||
EffectGizmo* top_left_gizmo;
|
||||
EffectGizmo* top_center_gizmo;
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2019 Olive Team
|
||||
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 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.
|
||||
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/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
@@ -27,25 +27,55 @@
|
||||
#include "ui/collapsiblewidget.h"
|
||||
#include "global/debug.h"
|
||||
|
||||
VoidEffect::VoidEffect(Clip* c, const QString& n) : Effect(c, nullptr) {
|
||||
QString display_name;
|
||||
if (n.isEmpty()) {
|
||||
display_name = tr("(unknown)");
|
||||
} else {
|
||||
display_name = n;
|
||||
VoidEffect::VoidEffect(Clip* c, const QString& n, const QString& id) :
|
||||
Node(c),
|
||||
display_name_(n),
|
||||
id_(id)
|
||||
{
|
||||
if (display_name_.isEmpty()) {
|
||||
display_name_ = tr("(unknown)");
|
||||
}
|
||||
EffectRow* row = new EffectRow(this, tr("Missing Effect"), false, false);
|
||||
|
||||
new LabelField(row, display_name);
|
||||
|
||||
name = display_name;
|
||||
|
||||
void_meta.type = EFFECT_TYPE_EFFECT;
|
||||
meta = &void_meta;
|
||||
new LabelWidget(this, tr("Missing Effect"), display_name_);
|
||||
}
|
||||
|
||||
EffectPtr VoidEffect::copy(Clip* c) {
|
||||
EffectPtr copy = std::make_shared<VoidEffect>(c, name);
|
||||
QString VoidEffect::name()
|
||||
{
|
||||
return display_name_;
|
||||
}
|
||||
|
||||
QString VoidEffect::id()
|
||||
{
|
||||
return id_;
|
||||
}
|
||||
|
||||
QString VoidEffect::description()
|
||||
{
|
||||
return QString();
|
||||
}
|
||||
|
||||
EffectType VoidEffect::type()
|
||||
{
|
||||
return EFFECT_TYPE_EFFECT;
|
||||
}
|
||||
|
||||
olive::TrackType VoidEffect::subtype()
|
||||
{
|
||||
return olive::kTypeVideo;
|
||||
}
|
||||
|
||||
bool VoidEffect::IsCreatable()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
NodePtr VoidEffect::Create(Clip *)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
NodePtr VoidEffect::copy(Clip* c) {
|
||||
NodePtr copy = std::make_shared<VoidEffect>(c, display_name_, id_);
|
||||
copy->SetEnabled(IsEnabled());
|
||||
copy_field_keyframes(copy);
|
||||
return copy;
|
||||
@@ -54,7 +84,7 @@ EffectPtr VoidEffect::copy(Clip* c) {
|
||||
void VoidEffect::load(QXmlStreamReader &stream) {
|
||||
QString tag = stream.name().toString();
|
||||
|
||||
QXmlStreamWriter writer(&bytes);
|
||||
QXmlStreamWriter writer(&bytes_);
|
||||
|
||||
// copy XML from reader to writer
|
||||
while (!stream.atEnd() && !(stream.name() == tag && stream.isEndElement())) {
|
||||
@@ -76,18 +106,18 @@ void VoidEffect::load(QXmlStreamReader &stream) {
|
||||
}
|
||||
|
||||
void VoidEffect::save(QXmlStreamWriter &stream) {
|
||||
if (!name.isEmpty()) {
|
||||
stream.writeAttribute("name", name);
|
||||
if (!display_name_.isEmpty()) {
|
||||
stream.writeAttribute("name", display_name_);
|
||||
stream.writeAttribute("enabled", QString::number(IsEnabled()));
|
||||
|
||||
// force xml writer to expand <effect> tag, ignored when loading
|
||||
stream.writeStartElement("void");
|
||||
stream.writeEndElement();
|
||||
|
||||
if (!bytes.isEmpty()) {
|
||||
if (!bytes_.isEmpty()) {
|
||||
// write stored data
|
||||
QIODevice* device = stream.device();
|
||||
device->write(bytes);
|
||||
device->write(bytes_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2019 Olive Team
|
||||
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 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.
|
||||
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/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
@@ -27,19 +27,28 @@
|
||||
* isn't lost if the user saves over the project.
|
||||
*/
|
||||
|
||||
#include "effects/effect.h"
|
||||
#include "nodes/node.h"
|
||||
|
||||
class VoidEffect : public Effect {
|
||||
class VoidEffect : public Node {
|
||||
Q_OBJECT
|
||||
public:
|
||||
VoidEffect(Clip* c, const QString& n);
|
||||
VoidEffect(Clip* c, const QString& n, const QString &id);
|
||||
|
||||
virtual QString name() override;
|
||||
virtual QString id() override;
|
||||
virtual QString description() override;
|
||||
virtual EffectType type() override;
|
||||
virtual olive::TrackType subtype() override;
|
||||
virtual bool IsCreatable() override;
|
||||
virtual NodePtr Create(Clip *c) override;
|
||||
virtual NodePtr copy(Clip* c) override;
|
||||
|
||||
virtual EffectPtr copy(Clip* c) override;
|
||||
virtual void load(QXmlStreamReader &stream) override;
|
||||
virtual void save(QXmlStreamWriter &stream) override;
|
||||
private:
|
||||
QByteArray bytes;
|
||||
EffectMeta void_meta;
|
||||
QByteArray bytes_;
|
||||
QString display_name_;
|
||||
QString id_;
|
||||
};
|
||||
|
||||
#endif // VOIDEFFECT_H
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2019 Olive Team
|
||||
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 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.
|
||||
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/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
@@ -28,41 +28,63 @@
|
||||
#include "ui/labelslider.h"
|
||||
#include "ui/collapsiblewidget.h"
|
||||
|
||||
VolumeEffect::VolumeEffect(Clip* c, const EffectMeta *em) : Effect(c, em) {
|
||||
EffectRow* volume_row = new EffectRow(this, tr("Volume"));
|
||||
volume_val = new DoubleField(volume_row, "volume");
|
||||
VolumeEffect::VolumeEffect(Clip* c) : Node(c) {
|
||||
volume_val = new DoubleInput(this, "volume", tr("Volume"));
|
||||
|
||||
// set defaults
|
||||
volume_val->SetDefault(1);
|
||||
volume_val->SetDisplayType(LabelSlider::Decibel);
|
||||
}
|
||||
|
||||
void VolumeEffect::process_audio(double timecode_start, double timecode_end, quint8* samples, int nb_bytes, int) {
|
||||
double interval = (timecode_end-timecode_start)/nb_bytes;
|
||||
for (int i=0;i<nb_bytes;i+=4) {
|
||||
QString VolumeEffect::name()
|
||||
{
|
||||
return tr("Volume");
|
||||
}
|
||||
|
||||
QString VolumeEffect::id()
|
||||
{
|
||||
return "org.olivevideoeditor.Olive.volume";
|
||||
}
|
||||
|
||||
QString VolumeEffect::description()
|
||||
{
|
||||
return tr("Adjust the volume of this clip's audio");
|
||||
}
|
||||
|
||||
EffectType VolumeEffect::type()
|
||||
{
|
||||
return EFFECT_TYPE_EFFECT;
|
||||
}
|
||||
|
||||
olive::TrackType VolumeEffect::subtype()
|
||||
{
|
||||
return olive::kTypeAudio;
|
||||
}
|
||||
|
||||
NodePtr VolumeEffect::Create(Clip *c)
|
||||
{
|
||||
return std::make_shared<VolumeEffect>(c);
|
||||
}
|
||||
|
||||
void VolumeEffect::process_audio(double timecode_start,
|
||||
double timecode_end,
|
||||
float **samples,
|
||||
int nb_samples,
|
||||
int channel_count,
|
||||
int type) {
|
||||
|
||||
Q_UNUSED(type)
|
||||
|
||||
double interval = (timecode_end-timecode_start)/nb_samples;
|
||||
|
||||
for (int i=0;i<nb_samples;i++) {
|
||||
|
||||
double vol_val = volume_val->GetDoubleAt(timecode_start+(interval*i));
|
||||
|
||||
qint32 right_samp = qint16(((samples[i+3] & 0xFF) << 8) | (samples[i+2] & 0xFF));
|
||||
qint32 left_samp = qint16(((samples[i+1] & 0xFF) << 8) | (samples[i] & 0xFF));
|
||||
for (int j=0;j<channel_count;j++) {
|
||||
|
||||
left_samp *= vol_val;
|
||||
right_samp *= vol_val;
|
||||
samples[j][i] *= vol_val;
|
||||
|
||||
if (left_samp > INT16_MAX) {
|
||||
left_samp = INT16_MAX;
|
||||
} else if (left_samp < INT16_MIN) {
|
||||
left_samp = INT16_MIN;
|
||||
}
|
||||
|
||||
if (right_samp > INT16_MAX) {
|
||||
right_samp = INT16_MAX;
|
||||
} else if (right_samp < INT16_MIN) {
|
||||
right_samp = INT16_MIN;
|
||||
}
|
||||
|
||||
samples[i+3] = (quint8) (right_samp >> 8);
|
||||
samples[i+2] = (quint8) right_samp;
|
||||
samples[i+1] = (quint8) (left_samp >> 8);
|
||||
samples[i] = (quint8) left_samp;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,35 +1,49 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2019 Olive Team
|
||||
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 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.
|
||||
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/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
#ifndef VOLUMEEFFECT_H
|
||||
#define VOLUMEEFFECT_H
|
||||
|
||||
#include "effects/effect.h"
|
||||
#include "nodes/node.h"
|
||||
|
||||
class VolumeEffect : public Effect {
|
||||
class VolumeEffect : public Node {
|
||||
Q_OBJECT
|
||||
public:
|
||||
VolumeEffect(Clip* c, const EffectMeta* em);
|
||||
void process_audio(double timecode_start, double timecode_end, quint8* samples, int nb_bytes, int channel_count);
|
||||
VolumeEffect(Clip* c);
|
||||
|
||||
DoubleField* volume_val;
|
||||
virtual QString name() override;
|
||||
virtual QString id() override;
|
||||
virtual QString description() override;
|
||||
virtual EffectType type() override;
|
||||
virtual olive::TrackType subtype() override;
|
||||
virtual NodePtr Create(Clip *c) override;
|
||||
|
||||
virtual void process_audio(double timecode_start,
|
||||
double timecode_end,
|
||||
float **samples,
|
||||
int nb_samples,
|
||||
int channel_count,
|
||||
int type) override;
|
||||
|
||||
private:
|
||||
DoubleInput* volume_val;
|
||||
};
|
||||
|
||||
#endif // VOLUMEEFFECT_H
|
||||
|
||||
+120
-69
@@ -1,20 +1,20 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2019 Olive Team
|
||||
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 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.
|
||||
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/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
@@ -46,7 +46,6 @@ class NSWindow;
|
||||
#endif
|
||||
|
||||
#define BLOCK_SIZE 512
|
||||
#define CHANNEL_COUNT 2
|
||||
|
||||
struct VSTRect {
|
||||
int16_t top;
|
||||
@@ -212,15 +211,6 @@ bool VSTHost::canPluginDo(char *canDoString) {
|
||||
return (dispatcher(plugin, effCanDo, 0, 0, static_cast<void*>(canDoString), 0.0f) > 0);
|
||||
}
|
||||
|
||||
void VSTHost::processAudio(long numFrames) {
|
||||
// Always reset the output array before processing.
|
||||
for (int i=0;i<CHANNEL_COUNT;i++) {
|
||||
memset(outputs[i], 0, BLOCK_SIZE*sizeof(float));
|
||||
}
|
||||
|
||||
plugin->processReplacing(plugin, inputs, outputs, numFrames);
|
||||
}
|
||||
|
||||
void VSTHost::CreateDialogIfNull()
|
||||
{
|
||||
if (dialog == nullptr) {
|
||||
@@ -237,74 +227,84 @@ void VSTHost::send_data_cache_to_plugin()
|
||||
dispatcher(plugin, effSetChunk, 0, int32_t(data_cache.size()), static_cast<void*>(data_cache.data()), 0);
|
||||
}
|
||||
|
||||
VSTHost::VSTHost(Clip* c, const EffectMeta *em) :
|
||||
Effect(c, em),
|
||||
VSTHost::VSTHost(Clip* c) :
|
||||
Node(c),
|
||||
plugin(nullptr),
|
||||
dialog(nullptr)
|
||||
dialog(nullptr),
|
||||
input_cache(BLOCK_SIZE),
|
||||
output_cache(BLOCK_SIZE)
|
||||
{
|
||||
plugin = nullptr;
|
||||
|
||||
inputs = new float* [CHANNEL_COUNT];
|
||||
outputs = new float* [CHANNEL_COUNT];
|
||||
for(int channel = 0; channel < CHANNEL_COUNT; channel++) {
|
||||
inputs[channel] = new float[BLOCK_SIZE];
|
||||
outputs[channel] = new float[BLOCK_SIZE];
|
||||
}
|
||||
|
||||
EffectRow* file_row = new EffectRow(this, tr("Plugin"), true, false);
|
||||
file_field = new FileField(file_row, "filename");
|
||||
file_field = new FileInput(this, "filename", tr("Plugin"), true, false);
|
||||
connect(file_field, SIGNAL(Changed()), this, SLOT(change_plugin()), Qt::QueuedConnection);
|
||||
|
||||
EffectRow* interface_row = new EffectRow(this, tr("Interface"), false, false);
|
||||
|
||||
show_interface_btn = new ButtonField(interface_row, tr("Show"));
|
||||
show_interface_btn = new ButtonWidget(this, tr("Interface"), tr("Show"));
|
||||
show_interface_btn->SetCheckable(true);
|
||||
show_interface_btn->SetEnabled(false);
|
||||
connect(show_interface_btn, SIGNAL(Toggled(bool)), this, SLOT(show_interface(bool)));
|
||||
}
|
||||
|
||||
VSTHost::~VSTHost() {
|
||||
for(int channel = 0; channel < CHANNEL_COUNT; channel++) {
|
||||
delete [] inputs[channel];
|
||||
delete [] outputs[channel];
|
||||
}
|
||||
delete [] outputs;
|
||||
delete [] inputs;
|
||||
|
||||
freePlugin();
|
||||
}
|
||||
|
||||
void VSTHost::process_audio(double, double, quint8* samples, int nb_bytes, int) {
|
||||
QString VSTHost::name()
|
||||
{
|
||||
return tr("VST Plugin 2.x");
|
||||
}
|
||||
|
||||
QString VSTHost::id()
|
||||
{
|
||||
return "org.olivevideoeditor.Olive.vst2x";
|
||||
}
|
||||
|
||||
QString VSTHost::description()
|
||||
{
|
||||
return tr("Use a VST 2.x plugin on this clip's audio.");
|
||||
}
|
||||
|
||||
EffectType VSTHost::type()
|
||||
{
|
||||
return EFFECT_TYPE_EFFECT;
|
||||
}
|
||||
|
||||
olive::TrackType VSTHost::subtype()
|
||||
{
|
||||
return olive::kTypeAudio;
|
||||
}
|
||||
|
||||
NodePtr VSTHost::Create(Clip *c)
|
||||
{
|
||||
return std::make_shared<VSTHost>(c);
|
||||
}
|
||||
|
||||
void VSTHost::process_audio(double timecode_start,
|
||||
double timecode_end,
|
||||
float **samples,
|
||||
int nb_samples,
|
||||
int channel_count,
|
||||
int type) {
|
||||
if (plugin != nullptr) {
|
||||
int interval = BLOCK_SIZE*4;
|
||||
for (int i=0;i<nb_bytes;i+=interval) {
|
||||
int process_size = qMin(interval, nb_bytes - i);
|
||||
int lim = i + process_size;
|
||||
|
||||
// convert to float
|
||||
for (int j=i;j<lim;j+=4) {
|
||||
qint16 left_sample = qint16(((samples[j+1] & 0xFF) << 8) | (samples[j] & 0xFF));
|
||||
qint16 right_sample = qint16(((samples[j+3] & 0xFF) << 8) | (samples[j+2] & 0xFF));
|
||||
// Make copy of audio
|
||||
input_cache.Create(channel_count);
|
||||
output_cache.Create(channel_count);
|
||||
|
||||
int index = (j-i)>>2;
|
||||
inputs[0][index] = float(left_sample) / float(INT16_MAX);
|
||||
inputs[1][index] = float(right_sample) / float(INT16_MAX);
|
||||
for (int i=0;i<nb_samples;i+=BLOCK_SIZE) {
|
||||
int sample_size = qMin(BLOCK_SIZE, nb_samples - i);
|
||||
|
||||
// Copy samples to input cache
|
||||
for (int j=0;j<channel_count;j++) {
|
||||
memcpy(input_cache.data()[j], &samples[j][i], nb_samples * sizeof(float));
|
||||
}
|
||||
|
||||
// send to VST
|
||||
processAudio(process_size>>2);
|
||||
plugin->processReplacing(plugin, input_cache.data(), output_cache.data(), sample_size);
|
||||
|
||||
// convert back to int16
|
||||
for (int j=i;j<lim;j+=4) {
|
||||
int index = (j-i)>>2;
|
||||
|
||||
qint16 left_sample = qint16(qRound(outputs[0][index] * INT16_MAX));
|
||||
qint16 right_sample = qint16(qRound(outputs[1][index] * INT16_MAX));
|
||||
|
||||
samples[j+3] = quint8(right_sample >> 8);
|
||||
samples[j+2] = quint8(right_sample);
|
||||
samples[j+1] = quint8(left_sample >> 8);
|
||||
samples[j] = quint8(left_sample);
|
||||
// Copy output cache back to samples
|
||||
for (int j=0;j<channel_count;j++) {
|
||||
memcpy(&samples[j][i], output_cache.data()[j], nb_samples * sizeof(float));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -321,7 +321,7 @@ void VSTHost::custom_load(QXmlStreamReader &stream) {
|
||||
}
|
||||
|
||||
void VSTHost::save(QXmlStreamWriter &stream) {
|
||||
Effect::save(stream);
|
||||
Node::save(stream);
|
||||
if (plugin != nullptr) {
|
||||
char* p = nullptr;
|
||||
int32_t length = int32_t(dispatcher(plugin, effGetChunk, 0, 0, &p, 0));
|
||||
@@ -379,3 +379,54 @@ void VSTHost::change_plugin() {
|
||||
}
|
||||
show_interface_btn->SetEnabled(plugin != nullptr);
|
||||
}
|
||||
|
||||
SampleCache::SampleCache(int block_size) :
|
||||
block_size_(block_size),
|
||||
channel_count_(0),
|
||||
array_(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
SampleCache::~SampleCache()
|
||||
{
|
||||
destroy();
|
||||
}
|
||||
|
||||
void SampleCache::Create(int channels)
|
||||
{
|
||||
if (channel_count_ != channels) {
|
||||
|
||||
if (channel_count_ > 0) {
|
||||
destroy();
|
||||
}
|
||||
|
||||
channel_count_ = channels;
|
||||
|
||||
array_ = new float* [channel_count_];
|
||||
for (int i=0;i<channel_count_;i++) {
|
||||
array_[i] = new float[block_size_];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SampleCache::SetZero()
|
||||
{
|
||||
for (int i=0;i<channel_count_;i++) {
|
||||
memset(array_[i], 0, block_size_ * sizeof(float));
|
||||
}
|
||||
}
|
||||
|
||||
float **SampleCache::data()
|
||||
{
|
||||
return array_;
|
||||
}
|
||||
|
||||
void SampleCache::destroy()
|
||||
{
|
||||
for (int i=0;i<channel_count_;i++) {
|
||||
delete [] array_[i];
|
||||
}
|
||||
|
||||
delete [] array_;
|
||||
array_ = nullptr;
|
||||
}
|
||||
|
||||
+52
-24
@@ -1,20 +1,20 @@
|
||||
/***
|
||||
|
||||
Olive - Non-Linear Video Editor
|
||||
Copyright (C) 2019 Olive Team
|
||||
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 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.
|
||||
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/>.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
***/
|
||||
|
||||
@@ -24,28 +24,57 @@
|
||||
#include <QDialog>
|
||||
#include <QLibrary>
|
||||
|
||||
#include "effects/effect.h"
|
||||
#include "nodes/node.h"
|
||||
#include "include/vestige.h"
|
||||
|
||||
// Plugin's dispatcher function
|
||||
typedef intptr_t (*dispatcherFuncPtr)(AEffect *effect, int32_t opCode, int32_t index, int32_t value, void *ptr, float opt);
|
||||
|
||||
class VSTHost : public Effect {
|
||||
class SampleCache {
|
||||
public:
|
||||
SampleCache(int block_size);
|
||||
~SampleCache();
|
||||
|
||||
void Create(int channels);
|
||||
void SetZero();
|
||||
|
||||
float** data();
|
||||
private:
|
||||
int channel_count_;
|
||||
int block_size_;
|
||||
float** array_;
|
||||
void destroy();
|
||||
};
|
||||
|
||||
class VSTHost : public Node {
|
||||
Q_OBJECT
|
||||
public:
|
||||
VSTHost(Clip* c, const EffectMeta* em);
|
||||
~VSTHost();
|
||||
void process_audio(double timecode_start, double timecode_end, quint8* samples, int nb_bytes, int channel_count);
|
||||
VSTHost(Clip* c);
|
||||
virtual ~VSTHost() override;
|
||||
|
||||
void custom_load(QXmlStreamReader& stream);
|
||||
void save(QXmlStreamWriter& stream);
|
||||
virtual QString name() override;
|
||||
virtual QString id() override;
|
||||
virtual QString description() override;
|
||||
virtual EffectType type() override;
|
||||
virtual olive::TrackType subtype() override;
|
||||
virtual NodePtr Create(Clip *c) override;
|
||||
|
||||
virtual void process_audio(double timecode_start,
|
||||
double timecode_end,
|
||||
float **samples,
|
||||
int nb_samples,
|
||||
int channel_count,
|
||||
int type) override;
|
||||
|
||||
virtual void custom_load(QXmlStreamReader& stream) override;
|
||||
virtual void save(QXmlStreamWriter& stream) override;
|
||||
private slots:
|
||||
void show_interface(bool show);
|
||||
void uncheck_show_button();
|
||||
void change_plugin();
|
||||
private:
|
||||
FileField* file_field;
|
||||
ButtonField* show_interface_btn;
|
||||
FileInput* file_field;
|
||||
ButtonWidget* show_interface_btn;
|
||||
|
||||
void loadPlugin();
|
||||
void freePlugin();
|
||||
@@ -57,12 +86,11 @@ private:
|
||||
void resumePlugin();
|
||||
void suspendPlugin();
|
||||
bool canPluginDo(char *canDoString);
|
||||
void processAudio(long numFrames);
|
||||
void CreateDialogIfNull();
|
||||
float** inputs;
|
||||
float** outputs;
|
||||
QDialog* dialog;
|
||||
QByteArray data_cache;
|
||||
SampleCache input_cache;
|
||||
SampleCache output_cache;
|
||||
|
||||
void send_data_cache_to_plugin();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user