OpenShot Library | libopenshot 0.2.7
Expander.h
Go to the documentation of this file.
1/**
2 * @file
3 * @brief Header file for Expander audio effect class
4 * @author
5 *
6 * @ref License
7 */
8
9/* LICENSE
10 *
11 * Copyright (c) 2008-2019 OpenShot Studios, LLC
12 * <http://www.openshotstudios.com/>. This file is part of
13 * OpenShot Library (libopenshot), an open-source project dedicated to
14 * delivering high quality video editing and animation solutions to the
15 * world. For more information visit <http://www.openshot.org/>.
16 *
17 * OpenShot Library (libopenshot) is free software: you can redistribute it
18 * and/or modify it under the terms of the GNU Lesser General Public License
19 * as published by the Free Software Foundation, either version 3 of the
20 * License, or (at your option) any later version.
21 *
22 * OpenShot Library (libopenshot) is distributed in the hope that it will be
23 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU Lesser General Public License for more details.
26 *
27 * You should have received a copy of the GNU Lesser General Public License
28 * along with OpenShot Library. If not, see <http://www.gnu.org/licenses/>.
29 */
30
31#ifndef OPENSHOT_EXPANDER_AUDIO_EFFECT_H
32#define OPENSHOT_EXPANDER_AUDIO_EFFECT_H
33
34#include "../EffectBase.h"
35
36#include "../Frame.h"
37#include "../Json.h"
38#include "../KeyFrame.h"
39#include "../Enums.h"
40
41#include <memory>
42#include <string>
43#include <math.h>
44
45
46namespace openshot
47{
48
49 /**
50 * @brief This class adds a expander (or noise gate) into the audio
51 *
52 */
53 class Expander : public EffectBase
54 {
55 private:
56 /// Init effect settings
57 void init_effect_details();
58
59
60 public:
67
68 juce::AudioSampleBuffer mixed_down_input;
69 float xl;
70 float yl;
71 float xg;
72 float yg;
73 float control;
74
76 float yl_prev;
77
79 float inverseE;
80
81 /// Blank constructor, useful when using Json to load the effect properties
82 Expander();
83
84 /// Default constructor
85 ///
86 /// @param new_level The audio default Expander level (between 1 and 100)
87 Expander(Keyframe new_threshold, Keyframe new_ratio, Keyframe new_attack, Keyframe new_release, Keyframe new_makeup_gain, Keyframe new_bypass);
88
89 float calculateAttackOrRelease(float value);
90
91 /// @brief This method is required for all derived classes of ClipBase, and returns a
92 /// new openshot::Frame object. All Clip keyframes and effects are resolved into
93 /// pixels.
94 ///
95 /// @returns A new openshot::Frame object
96 /// @param frame_number The frame number (starting at 1) of the clip or effect on the timeline.
97 std::shared_ptr<openshot::Frame> GetFrame(int64_t frame_number) override {
98 return GetFrame(std::make_shared<openshot::Frame>(), frame_number);
99 }
100
101 /// @brief This method is required for all derived classes of ClipBase, and returns a
102 /// modified openshot::Frame object
103 ///
104 /// The frame object is passed into this method and used as a starting point (pixels and audio).
105 /// All Clip keyframes and effects are resolved into pixels.
106 ///
107 /// @returns The modified openshot::Frame object
108 /// @param frame The frame object that needs the clip or effect applied to it
109 /// @param frame_number The frame number (starting at 1) of the clip or effect on the timeline.
110 std::shared_ptr<openshot::Frame> GetFrame(std::shared_ptr<openshot::Frame> frame, int64_t frame_number) override;
111
112 // Get and Set JSON methods
113 std::string Json() const override; ///< Generate JSON string of this object
114 void SetJson(const std::string value) override; ///< Load JSON string into this object
115 Json::Value JsonValue() const override; ///< Generate Json::Value for this object
116 void SetJsonValue(const Json::Value root) override; ///< Load Json::Value into this object
117
118 /// Get all properties for a specific frame (perfect for a UI to display the current state
119 /// of all properties at any time)
120 std::string PropertiesJSON(int64_t requested_frame) const override;
121 };
122
123}
124
125#endif
This abstract class is the base class, used by all effects in libopenshot.
Definition: EffectBase.h:71
This class adds a expander (or noise gate) into the audio.
Definition: Expander.h:54
Expander()
Blank constructor, useful when using Json to load the effect properties.
Definition: Expander.cpp:37
float inverse_sample_rate
Definition: Expander.h:78
std::string PropertiesJSON(int64_t requested_frame) const override
Definition: Expander.cpp:208
void SetJsonValue(const Json::Value root) override
Load Json::Value into this object.
Definition: Expander.cpp:182
Keyframe makeup_gain
Definition: Expander.h:65
Keyframe ratio
Definition: Expander.h:62
Keyframe release
Definition: Expander.h:64
float calculateAttackOrRelease(float value)
Definition: Expander.cpp:132
void SetJson(const std::string value) override
Load JSON string into this object.
Definition: Expander.cpp:165
Keyframe threshold
Definition: Expander.h:61
Keyframe bypass
Definition: Expander.h:66
juce::AudioSampleBuffer mixed_down_input
Definition: Expander.h:68
Keyframe attack
Definition: Expander.h:63
Json::Value JsonValue() const override
Generate Json::Value for this object.
Definition: Expander.cpp:148
std::string Json() const override
Generate JSON string of this object.
Definition: Expander.cpp:141
std::shared_ptr< openshot::Frame > GetFrame(int64_t frame_number) override
This method is required for all derived classes of ClipBase, and returns a new openshot::Frame object...
Definition: Expander.h:97
A Keyframe is a collection of Point instances, which is used to vary a number or property over time.
Definition: KeyFrame.h:72
This namespace is the default namespace for all code in the openshot library.
Definition: Compressor.h:47