OpenShot Library | libopenshot
0.3.3
|
Go to the documentation of this file.
22 echo_time(echo_time), feedback(feedback), mix(mix)
25 init_effect_details();
29 void Echo::init_effect_details()
37 info.
description =
"Reflection of sound with a delay after the direct sound.";
47 const float max_echo_time = 5;
63 std::shared_ptr<openshot::Frame>
Echo::GetFrame(std::shared_ptr<openshot::Frame> frame, int64_t frame_number)
65 const float echo_time_value = (float)
echo_time.
GetValue(frame_number)*(float)frame->SampleRate();
68 int local_write_position;
72 for (
int channel = 0; channel < frame->audio->getNumChannels(); channel++)
74 float *channel_data = frame->audio->getWritePointer(channel);
75 float *echo_data =
echo_buffer.getWritePointer(channel);
78 for (
auto sample = 0; sample < frame->audio->getNumSamples(); ++sample)
80 const float in = (float)(channel_data[sample]);
84 int local_read_position = floorf(read_position);
86 if (local_read_position != local_write_position)
88 float fraction = read_position - (float)local_read_position;
89 float echoed1 = echo_data[(local_read_position + 0)];
91 out = (float)(echoed1 + fraction * (echoed2 - echoed1));
92 channel_data[sample] = in + mix_value*(out - in);
93 echo_data[local_write_position] = in + out*feedback_value;
138 catch (
const std::exception& e)
141 throw InvalidJSON(
"JSON is invalid (missing keys or invalid data types)");
152 if (!root[
"echo_time"].isNull())
154 if (!root[
"feedback"].isNull())
156 if (!root[
"mix"].isNull())
172 return root.toStyledString();
Json::Value add_property_json(std::string name, float value, std::string type, std::string memo, const Keyframe *keyframe, float min_value, float max_value, bool readonly, int64_t requested_frame) const
Generate JSON for a property.
const Json::Value stringToJson(const std::string value)
EffectInfoStruct info
Information about the current effect.
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...
This namespace is the default namespace for all code in the openshot library.
virtual Json::Value JsonValue() const
Generate Json::Value for this object.
void SetJsonValue(const Json::Value root)
Load Json::Value into this object.
void SetJsonValue(const Json::Value root) override
Load Json::Value into this object.
void setup(std::shared_ptr< openshot::Frame > frame)
Json::Value JsonValue() const
Generate Json::Value for this object.
Echo()
Default constructor.
Json::Value BasePropertiesJSON(int64_t requested_frame) const
Generate JSON object of base properties (recommended to be used by all effects)
Json::Value JsonValue() const override
Generate Json::Value for this object.
A Keyframe is a collection of Point instances, which is used to vary a number or property over time.
Exception for invalid JSON.
void SetJson(const std::string value) override
Load JSON string into this object.
Header file for Echo audio effect class.
bool has_audio
Determines if this effect manipulates the audio of a frame.
Header file for Frame class.
std::string class_name
The class name of the effect.
std::string description
The description of this effect and what it does.
std::string Json() const override
Generate JSON string of this object.
bool has_video
Determines if this effect manipulates the image of a frame.
std::string name
The name of the effect.
This class adds a echo into the audio.
juce::AudioBuffer< float > echo_buffer
Header file for all Exception classes.
virtual void SetJsonValue(const Json::Value root)
Load Json::Value into this object.
double GetValue(int64_t index) const
Get the value at a specific index.
std::string PropertiesJSON(int64_t requested_frame) const override