diff --git a/effects/internal/vsthostwin.cpp b/effects/internal/vsthostwin.cpp index afa320352..593d63ab0 100644 --- a/effects/internal/vsthostwin.cpp +++ b/effects/internal/vsthostwin.cpp @@ -5,6 +5,7 @@ #include #include +#include #include "playback/audio.h" #include "mainwindow.h" @@ -23,6 +24,8 @@ extern "C" { case audioMasterIdle: effect->dispatcher(effect, effEditIdle, 0, 0, 0, 0); break; + case 6: // audioMasterWantMidi + return 0; case audioMasterGetCurrentProcessLevel: return 0; // Handle other opcodes here... there will be lots of them @@ -47,7 +50,7 @@ typedef void (*processFuncPtr)(AEffect *effect, float **inputs, float **outputs, void VSTHostWin::loadPlugin() { plugin = NULL; - const char* vst_path = "C:\\Users\\Matt\\Downloads\\ToneGenerator_Win\\ToneGenerator_64b.dll"; + const char* vst_path = "C:\\Program Files\\VSTPlugins\\ReaPlugs\\reaeq-standalone.dll"; wchar_t win_char[200]; mbstowcs(win_char, vst_path, 200); @@ -136,50 +139,79 @@ void VSTHostWin::silenceChannel(float **channelData, int numChannels, long numFr } VSTHostWin::VSTHostWin(Clip* c, const EffectMeta *em) : Effect(c, em) { - EffectRow* interface_row = add_row("Open Interface"); - QPushButton* show_interface_btn = new QPushButton(); + EffectRow* interface_row = add_row("Interface"); + show_interface_btn = new QPushButton("Show"); + show_interface_btn->setCheckable(true); + connect(show_interface_btn, SIGNAL(toggled(bool)), this, SLOT(show_interface(bool))); interface_row->add_widget(show_interface_btn); loadPlugin(); if (plugin != NULL) { initializeIO(); configurePluginCallbacks(); startPlugin(); + dialog = new QDialog(mainWindow); + dialog->setWindowTitle("VST Plugin"); + dialog->setAttribute(Qt::WA_NativeWindow, true); + dialog->setWindowFlags(dialog->windowFlags() | Qt::MSWindowsFixedSizeDialogHint); + connect(dialog, SIGNAL(finished(int)), this, SLOT(uncheck_show_button())); + dispatcher(plugin, effEditOpen, 0, 0, reinterpret_cast(dialog->winId()), 0); + + ERect* eRect = NULL; + plugin->dispatcher(plugin, effEditGetRect, 0, 0, &eRect, 0); + dialog->setFixedWidth(eRect->right); + dialog->setFixedHeight(eRect->bottom); } } void VSTHostWin::process_audio(double timecode_start, double timecode_end, quint8* samples, int nb_bytes, int) { if (plugin != NULL) { - // convert to floats - int nb_frames = qMin(nb_bytes >> 2, BLOCK_SIZE); - int lim = qMin(nb_bytes, BLOCK_SIZE << 2); - for (int i=0;i> 2; - inputs[0][index] = float(left_sample) / float(INT16_MAX); - inputs[1][index] = float(right_sample) / float(INT16_MAX); + // convert to float + for (int j=i;j> 8); + samples[j+2] = (quint8) right_sample; + samples[j+1] = (quint8) (left_sample >> 8); + samples[j] = (quint8) left_sample;*/ + + int index = (j-i)>>2; + inputs[0][index] = float(left_sample) / float(INT16_MAX); + inputs[1][index] = float(right_sample) / float(INT16_MAX); + } + + // send to VST + processAudio(process_size>>2); + + // convert back to int16 + for (int j=i;j>2; + + qint16 left_sample = qRound(outputs[0][index] * INT16_MAX); + qint16 right_sample = qRound(outputs[1][index] * INT16_MAX); + + samples[j+3] = (quint8) (right_sample >> 8); + samples[j+2] = (quint8) right_sample; + samples[j+1] = (quint8) (left_sample >> 8); + samples[j] = (quint8) left_sample; + } } - // send to VST - processAudio(nb_frames); - - // convert back to int16 - for (int i=0;i> 8); - samples[index+2] = (quint8) right_sample; - samples[index+1] = (quint8) (left_sample >> 8); - samples[index] = (quint8) left_sample; - } } } -void VSTHostWin::show_interface() { -// dispatcher(plugin, effEditOpen, 0, 1, NULL, 0.0f); -// dispatcher(plugin, effEditOpen, 0, 0, mainWindow->winId()); +void VSTHostWin::show_interface(bool show) { + dialog->setVisible(show); +} + +void VSTHostWin::uncheck_show_button() { + show_interface_btn->setChecked(false); } diff --git a/effects/internal/vsthostwin.h b/effects/internal/vsthostwin.h index 762d1c2a0..c5dc606a1 100644 --- a/effects/internal/vsthostwin.h +++ b/effects/internal/vsthostwin.h @@ -9,6 +9,7 @@ typedef VstIntPtr (*dispatcherFuncPtr)(AEffect *effect, VstInt32 opCode, VstInt32 index, VstInt32 value, void *ptr, float opt); struct AEffect; +class QDialog; class VSTHostWin : public Effect { Q_OBJECT @@ -16,7 +17,8 @@ public: VSTHostWin(Clip* c, const EffectMeta* em); void process_audio(double timecode_start, double timecode_end, quint8* samples, int nb_bytes, int channel_count); private slots: - void show_interface(); + void show_interface(bool show); + void uncheck_show_button(); private: void loadPlugin(); dispatcherFuncPtr dispatcher; @@ -31,6 +33,8 @@ private: void silenceChannel(float **channelData, int numChannels, long numFrames); float** inputs; float** outputs; + QDialog* dialog; + QPushButton* show_interface_btn; }; #endif // VSTHOSTWIN_H diff --git a/olive.pro b/olive.pro index b7f0d3108..03aea3757 100644 --- a/olive.pro +++ b/olive.pro @@ -212,7 +212,7 @@ FORMS += win32 { RC_FILE = packaging/windows/resources.rc - LIBS += -lavutil -lavformat -lavcodec -lavfilter -lswscale -lswresample -lopengl32 + LIBS += -lavutil -lavformat -lavcodec -lavfilter -lswscale -lswresample -lopengl32 -luser32 } mac {