Skip to content

Commit

Permalink
Adding description on the audio effects and cleaning the code
Browse files Browse the repository at this point in the history
  • Loading branch information
BrennoCaldato committed Jul 10, 2021
1 parent 8c03424 commit 5018c8d
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 34 deletions.
4 changes: 1 addition & 3 deletions src/audio_effects/Compressor.cpp
Expand Up @@ -56,14 +56,12 @@ void Compressor::init_effect_details()
/// Set the effect info
info.class_name = "Compressor";
info.name = "Compressor";
info.description = "Add Compressor on the frame's sound.";
info.description = "Add compressor effect on the frame's audio. This effect reduces the volume of loud sounds or amplify quiet sounds.";
info.has_audio = true;
info.has_video = false;

input_level = 0.0f;
yl_prev = 0.0f;


}

// This method is required for all derived classes of EffectBase, and returns a
Expand Down
20 changes: 18 additions & 2 deletions src/audio_effects/Distortion.cpp
Expand Up @@ -56,11 +56,12 @@ void Distortion::init_effect_details()
/// Set the effect info
info.class_name = "Distortion";
info.name = "Distortion";
info.description = "Add distortion on the frame's sound.";
info.description = "Add distortion on the frame's audio. This effect alters the audio by clipping the signal.";
info.has_audio = true;
info.has_video = false;
}


// This method is required for all derived classes of EffectBase, and returns a
// modified openshot::Frame object
std::shared_ptr<openshot::Frame> Distortion::GetFrame(std::shared_ptr<openshot::Frame> frame, int64_t frame_number)
Expand All @@ -77,7 +78,6 @@ std::shared_ptr<openshot::Frame> Distortion::GetFrame(std::shared_ptr<openshot::
// Add distortion
for (int channel = 0; channel < frame->audio->getNumChannels(); channel++)
{
//auto *inBuffer = frame->audio->getReadPointer(channel);
auto *channel_data = frame->audio->getWritePointer(channel);
float out;

Expand Down Expand Up @@ -166,6 +166,22 @@ std::string Distortion::Json() const {
return JsonValue().toStyledString();
}

void Distortion::Filter::updateCoefficients(const double discrete_frequency, const double gain)
{
jassert(discrete_frequency > 0);

double tan_half_wc = tan(discrete_frequency / 2.0);
double sqrt_gain = sqrt(gain);

coefficients = juce::IIRCoefficients(/* b0 */ sqrt_gain * tan_half_wc + gain,
/* b1 */ sqrt_gain * tan_half_wc - gain,
/* b2 */ 0.0,
/* a0 */ sqrt_gain * tan_half_wc + 1.0,
/* a1 */ sqrt_gain * tan_half_wc - 1.0,
/* a2 */ 0.0);
setCoefficients(coefficients);
}

// Generate Json::Value for this object
Json::Value Distortion::JsonValue() const {

Expand Down
18 changes: 1 addition & 17 deletions src/audio_effects/Distortion.h
Expand Up @@ -106,23 +106,7 @@ namespace openshot
class Filter : public juce::IIRFilter
{
public:
void updateCoefficients (const double discreteFrequency,
const double gain) noexcept
{
jassert (discreteFrequency > 0);

double tan_half_wc = tan (discreteFrequency / 2.0);
double sqrt_gain = sqrt (gain);

coefficients = juce::IIRCoefficients (/* b0 */ sqrt_gain * tan_half_wc + gain,
/* b1 */ sqrt_gain * tan_half_wc - gain,
/* b2 */ 0.0,
/* a0 */ sqrt_gain * tan_half_wc + 1.0,
/* a1 */ sqrt_gain * tan_half_wc - 1.0,
/* a2 */ 0.0);

setCoefficients (coefficients);
}
void updateCoefficients(const double discrete_frequency, const double gain) noexcept;
};

juce::OwnedArray<Filter> filters;
Expand Down
2 changes: 1 addition & 1 deletion src/audio_effects/Expander.cpp
Expand Up @@ -56,7 +56,7 @@ void Expander::init_effect_details()
/// Set the effect info
info.class_name = "Expander";
info.name = "Expander";
info.description = "Add Expander on the frame's sound.";
info.description = "Add Expander on the frame's audio track. Louder parts of the audio becomes relatively louder and quieter parts becomes quieter.";
info.has_audio = true;
info.has_video = false;

Expand Down
2 changes: 1 addition & 1 deletion src/audio_effects/ParametricEQ.cpp
Expand Up @@ -57,7 +57,7 @@ void ParametricEQ::init_effect_details()
/// Set the effect info
info.class_name = "ParametricEQ";
info.name = "Parametric EQ";
info.description = "Add equalization on the frame's sound.";
info.description = "Add equalization on the frame's sound. This effect is a filter that allows you to adjust the volume level of a frequency within an audio.";
info.has_audio = true;
info.has_video = false;
}
Expand Down
14 changes: 7 additions & 7 deletions src/audio_effects/ParametricEQ.h
Expand Up @@ -121,7 +121,7 @@ namespace openshot
double sqrt_gain = sqrt (gain);

switch (filter_type) {
case 0 /*filterTypeLowPass*/: {
case 0 /* LOW_PASS */: {
coefficients = IIRCoefficients (/* b0 */ tan_half_wc,
/* b1 */ tan_half_wc,
/* b2 */ 0.0,
Expand All @@ -130,7 +130,7 @@ namespace openshot
/* a2 */ 0.0);
break;
}
case 1 /*filterTypeHighPass*/: {
case 1 /* HIGH_PASS */: {
coefficients = IIRCoefficients (/* b0 */ 1.0,
/* b1 */ -1.0,
/* b2 */ 0.0,
Expand All @@ -139,7 +139,7 @@ namespace openshot
/* a2 */ 0.0);
break;
}
case 2 /*filterTypeLowShelf*/: {
case 2 /* LOW_SHELF */: {
coefficients = IIRCoefficients (/* b0 */ gain * tan_half_wc + sqrt_gain,
/* b1 */ gain * tan_half_wc - sqrt_gain,
/* b2 */ 0.0,
Expand All @@ -148,7 +148,7 @@ namespace openshot
/* a2 */ 0.0);
break;
}
case 3 /*filterTypeHighShelf*/: {
case 3 /* HIGH_SHELF */: {
coefficients = IIRCoefficients (/* b0 */ sqrt_gain * tan_half_wc + gain,
/* b1 */ sqrt_gain * tan_half_wc - gain,
/* b2 */ 0.0,
Expand All @@ -157,7 +157,7 @@ namespace openshot
/* a2 */ 0.0);
break;
}
case 4 /*filterTypeBandPass*/: {
case 4 /* BAND_PASS */: {
coefficients = IIRCoefficients (/* b0 */ tan_half_bw,
/* b1 */ 0.0,
/* b2 */ -tan_half_bw,
Expand All @@ -166,7 +166,7 @@ namespace openshot
/* a2 */ 1.0 - tan_half_bw);
break;
}
case 5 /*filterTypeBandStop*/: {
case 5 /* BAND_STOP */: {
coefficients = IIRCoefficients (/* b0 */ 1.0,
/* b1 */ two_cos_wc,
/* b2 */ 1.0,
Expand All @@ -175,7 +175,7 @@ namespace openshot
/* a2 */ 1.0 - tan_half_bw);
break;
}
case 6 /*filterTypePeakingNotch*/: {
case 6 /* PEAKING_NOTCH */: {
coefficients = IIRCoefficients (/* b0 */ sqrt_gain + gain * tan_half_bw,
/* b1 */ sqrt_gain * two_cos_wc,
/* b2 */ sqrt_gain - gain * tan_half_bw,
Expand Down
2 changes: 1 addition & 1 deletion src/audio_effects/Robotization.cpp
Expand Up @@ -57,7 +57,7 @@ void Robotization::init_effect_details()
/// Set the effect info
info.class_name = "Robotization";
info.name = "Robotization";
info.description = "Robotization effect on the frame's sound.";
info.description = "Add robotization effect on the frame's audio track. This effect transforms the voice present in an audio into a robotic voice effect.";
info.has_audio = true;
info.has_video = false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/audio_effects/Whisperization.cpp
Expand Up @@ -56,7 +56,7 @@ void Whisperization::init_effect_details()
/// Set the effect info
info.class_name = "Whisperization";
info.name = "Whisperization";
info.description = "Whisperization effect on the frame's sound.";
info.description = "Add whisperization effect on the frame's audio track. This effect transforms the voice present in an audio into a whispering voice effect.";
info.has_audio = true;
info.has_video = false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/audio_effects/Whisperization.h
Expand Up @@ -107,7 +107,7 @@ namespace openshot
class WhisperizationEffect : public STFT
{
public:
WhisperizationEffect (Whisperization& p) : parent (p) { }
WhisperizationEffect(Whisperization& p) : parent (p) { }

private:
void modification(const int channel) override;
Expand Down

0 comments on commit 5018c8d

Please sign in to comment.