merged with master

This commit is contained in:
itsmattkc
2019-01-09 10:39:23 +11:00
18 changed files with 210 additions and 127 deletions
+24
View File
@@ -0,0 +1,24 @@
#include "fillleftrighteffect.h"
#define FILL_TYPE_LEFT 0
#define FILL_TYPE_RIGHT 1
FillLeftRightEffect::FillLeftRightEffect(Clip* c, const EffectMeta *em) : Effect(c, em) {
EffectRow* type_row = add_row("Type");
fill_type = type_row->add_field(EFFECT_FIELD_COMBO, "type");
fill_type->add_combo_item("Fill Left with Right", FILL_TYPE_LEFT);
fill_type->add_combo_item("Fill Right with Left", FILL_TYPE_RIGHT);
}
void FillLeftRightEffect::process_audio(double timecode_start, double timecode_end, quint8* samples, int nb_bytes, int) {
double interval = (timecode_end-timecode_start)/nb_bytes;
for (int i=0;i<nb_bytes;i+=4) {
if (fill_type->get_combo_data(timecode_start+(interval*i)) == FILL_TYPE_LEFT) {
samples[i+1] = samples[i+3];
samples[i] = samples[i+2];
} else {
samples[i+3] = samples[i+1];
samples[i+2] = samples[i];
}
}
}
+14
View File
@@ -0,0 +1,14 @@
#ifndef FILLLEFTRIGHTEFFECT_H
#define FILLLEFTRIGHTEFFECT_H
#include "project/effect.h"
class FillLeftRightEffect : public Effect {
public:
FillLeftRightEffect(Clip* c, const EffectMeta* em);
void process_audio(double timecode_start, double timecode_end, quint8* samples, int nb_bytes, int channel_count);
private:
EffectField* fill_type;
};
#endif // FILLLEFTRIGHTEFFECT_H
+22 -9
View File
@@ -19,17 +19,30 @@ VolumeEffect::VolumeEffect(Clip* c, const EffectMeta *em) : Effect(c, em) {
void VolumeEffect::process_audio(double timecode_start, double timecode_end, quint8* samples, int nb_bytes, int) {
double interval = (timecode_end-timecode_start)/nb_bytes;
for (int i=0;i<nb_bytes;i+=2) {
for (int i=0;i<nb_bytes;i+=4) {
double vol_val = log_volume(volume_val->get_double_value(timecode_start+(interval*i), true)*0.01);
qint32 samp = (qint16) (((samples[i+1] & 0xFF) << 8) | (samples[i] & 0xFF));
samp *= vol_val;
if (samp > INT16_MAX) {
samp = INT16_MAX;
} else if (samp < INT16_MIN) {
samp = INT16_MIN;
qint32 right_samp = (qint16) (((samples[i+3] & 0xFF) << 8) | (samples[i+2] & 0xFF));
qint32 left_samp = (qint16) (((samples[i+1] & 0xFF) << 8) | (samples[i] & 0xFF));
left_samp *= vol_val;
right_samp *= vol_val;
if (left_samp > INT16_MAX) {
left_samp = INT16_MAX;
} else if (left_samp < INT16_MIN) {
left_samp = INT16_MIN;
}
samples[i+1] = (quint8) (samp >> 8);
samples[i] = (quint8) samp;
if (right_samp > INT16_MAX) {
right_samp = INT16_MAX;
} else if (right_samp < INT16_MIN) {
right_samp = INT16_MIN;
}
samples[i+3] = (quint8) (right_samp >> 8);
samples[i+2] = (quint8) right_samp;
samples[i+1] = (quint8) (left_samp >> 8);
samples[i] = (quint8) left_samp;
}
}
+13 -5
View File
@@ -74,6 +74,14 @@ void VSTHostWin::loadPlugin() {
plugin = mainEntryPoint(hostCallback);
}
void VSTHostWin::freePlugin() {
if (plugin != NULL) {
stopPlugin();
FreeLibrary(modulePtr);
plugin = NULL;
}
}
bool VSTHostWin::configurePluginCallbacks() {
// Check plugin's magic number
// If incorrect, then the file either was not loaded properly, is not a
@@ -166,6 +174,10 @@ VSTHostWin::VSTHostWin(Clip* c, const EffectMeta *em) : Effect(c, em) {
connect(dialog, SIGNAL(finished(int)), this, SLOT(uncheck_show_button()));
}
VSTHostWin::~VSTHostWin() {
freePlugin();
}
void VSTHostWin::process_audio(double timecode_start, double timecode_end, quint8* samples, int nb_bytes, int) {
if (plugin != NULL) {
int interval = BLOCK_SIZE*4;
@@ -220,11 +232,7 @@ void VSTHostWin::uncheck_show_button() {
}
void VSTHostWin::change_plugin() {
if (plugin != NULL) {
stopPlugin();
FreeLibrary(modulePtr);
plugin = NULL;
}
freePlugin();
loadPlugin();
if (plugin != NULL) {
if (configurePluginCallbacks()) {
+2
View File
@@ -15,6 +15,7 @@ class VSTHostWin : public Effect {
Q_OBJECT
public:
VSTHostWin(Clip* c, const EffectMeta* em);
~VSTHostWin();
void process_audio(double timecode_start, double timecode_end, quint8* samples, int nb_bytes, int channel_count);
private slots:
void show_interface(bool show);
@@ -24,6 +25,7 @@ private:
EffectField* file_field;
void loadPlugin();
void freePlugin();
dispatcherFuncPtr dispatcher;
AEffect* plugin;
bool configurePluginCallbacks();