40 init_effect_details();
48 init_effect_details();
52 void Robotization::init_effect_details()
60 info.
description =
"Transform the voice present in an audio track into a robotic voice effect.";
67 std::shared_ptr<openshot::Frame>
Robotization::GetFrame(std::shared_ptr<openshot::Frame> frame, int64_t frame_number)
69 const ScopedLock sl (
lock);
70 ScopedNoDenormals noDenormals;
72 const int num_input_channels = frame->audio->getNumChannels();
73 const int num_output_channels = frame->audio->getNumChannels();
74 const int num_samples = frame->audio->getNumSamples();
75 const int hop_size_value = 1 << ((int)
hop_size + 1);
76 const int fft_size_value = 1 << ((int)
fft_size + 5);
89 void Robotization::RobotizationEffect::modification(
const int channel)
91 fft->perform(time_domain_buffer, frequency_domain_buffer,
false);
93 for (
int index = 0; index <
fft_size; ++index) {
94 float magnitude = abs(frequency_domain_buffer[index]);
95 frequency_domain_buffer[index].real(magnitude);
96 frequency_domain_buffer[index].imag(0.0f);
99 fft->perform(frequency_domain_buffer, time_domain_buffer,
true);
133 catch (
const std::exception& e)
136 throw InvalidJSON(
"JSON is invalid (missing keys or invalid data types)");
146 if (!root[
"fft_size"].isNull())
149 if (!root[
"hop_size"].isNull())
152 if (!root[
"window_type"].isNull())
161 root[
"id"] =
add_property_json(
"ID", 0.0,
"string",
Id(), NULL, -1, -1,
true, requested_frame);
163 root[
"start"] =
add_property_json(
"Start",
Start(),
"float",
"", NULL, 0, 1000 * 60 * 30,
false, requested_frame);
164 root[
"end"] =
add_property_json(
"End",
End(),
"float",
"", NULL, 0, 1000 * 60 * 30,
false, requested_frame);
165 root[
"duration"] =
add_property_json(
"Duration",
Duration(),
"float",
"", NULL, 0, 1000 * 60 * 30,
true, requested_frame);
191 return root.toStyledString();
Json::Value JsonValue() const override
Generate Json::Value for this object.
std::string Id() const
Get the Id of this clip object.
void updateParameters(const int new_fft_size, const int new_overlap, const int new_window_type)
float Start() const
Get start position (in seconds) of clip (trim start of video)
virtual void SetJsonValue(const Json::Value root)
Load Json::Value into this object.
void SetJson(const std::string value) override
Load JSON string into this object.
FFTSize
This enumeration determines the FFT size.
const Json::Value stringToJson(const std::string value)
std::string Json() const override
Generate JSON string of this object.
virtual Json::Value JsonValue() const
Generate Json::Value for this object.
void setup(const int num_input_channels)
juce::CriticalSection lock
openshot::WindowType window_type
void SetJsonValue(const Json::Value root) override
Load Json::Value into this object.
bool has_audio
Determines if this effect manipulates the audio of a frame.
Header file for all Exception classes.
openshot::HopSize hop_size
void process(juce::AudioSampleBuffer &block)
Json::Value add_property_choice_json(std::string name, int value, int selected_value) const
Generate JSON choice for a property (dropdown properties)
std::string class_name
The class name of the effect.
std::string name
The name of the effect.
float Duration() const
Get the length of this clip (in seconds)
HopSize
This enumeration determines the hop size.
This namespace is the default namespace for all code in the openshot library.
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.
Exception for invalid JSON.
WindowType
This enumeration determines the window type.
Robotization()
Blank constructor, useful when using Json to load the effect properties.
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...
float End() const
Get end position (in seconds) of clip (trim end of video)
openshot::FFTSize fft_size
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.
std::string PropertiesJSON(int64_t requested_frame) const override
int Layer() const
Get layer of clip on timeline (lower number is covered by higher numbers)
std::unique_ptr< juce::dsp::FFT > fft
EffectInfoStruct info
Information about the current effect.
Header file for Robotization audio effect class.