OpenShot Library | libopenshot
0.4.0
|
Go to the documentation of this file.
17 #include <AppConfig.h>
18 #include <juce_audio_basics/juce_audio_basics.h>
27 init_effect_details();
31 void Noise::init_effect_details()
39 info.
description =
"Random signal having equal intensity at different frequencies.";
46 std::shared_ptr<openshot::Frame>
Noise::GetFrame(std::shared_ptr<openshot::Frame> frame, int64_t frame_number)
52 for (
int channel = 0; channel < frame->audio->getNumChannels(); channel++)
54 auto *buffer = frame->audio->getWritePointer(channel);
56 for (
auto sample = 0; sample < frame->audio->getNumSamples(); ++sample)
58 buffer[sample] = buffer[sample]*(1 - (1+(float)noise)/100) + buffer[sample]*0.0001*(rand()%100+1)*noise;
96 catch (
const std::exception& e)
99 throw InvalidJSON(
"JSON is invalid (missing keys or invalid data types)");
110 if (!root[
"level"].isNull())
124 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)
std::string PropertiesJSON(int64_t requested_frame) const override
EffectInfoStruct info
Information about the current effect.
This namespace is the default namespace for all code in the openshot library.
Keyframe level
Noise level keyframe. The amount of noise inserted on the audio.
virtual Json::Value JsonValue() const
Generate Json::Value for this object.
void SetJsonValue(const Json::Value root)
Load Json::Value into this object.
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...
void SetJsonValue(const Json::Value root) override
Load Json::Value into this object.
Noise()
Default constructor.
Json::Value JsonValue() const
Generate Json::Value for this object.
Json::Value JsonValue() const override
Generate Json::Value for this object.
Json::Value BasePropertiesJSON(int64_t requested_frame) const
Generate JSON object of base properties (recommended to be used by all effects)
A Keyframe is a collection of Point instances, which is used to vary a number or property over time.
Exception for invalid JSON.
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.
bool has_video
Determines if this effect manipulates the image of a frame.
std::string name
The name of the effect.
std::string Json() const override
Generate JSON string of this object.
Header file for Noise audio effect class.
void SetJson(const std::string value) override
Load JSON string into this object.
This class adds a noise into the audio.
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.