aboutsummaryrefslogtreecommitdiff
path: root/externals/grill/vst/src
diff options
context:
space:
mode:
authorThomas Grill <xovo@users.sourceforge.net>2009-04-01 21:13:09 +0000
committerThomas Grill <xovo@users.sourceforge.net>2009-04-01 21:13:09 +0000
commit0ed7a8b68dd73e2b0473b8127aeca99f3bac9061 (patch)
tree5c67818b38a5cc2f9caa5ca7f8640ca356adf02b /externals/grill/vst/src
parentbb4c7f6a245394d09dac9adfb2efb093d3d98452 (diff)
cleaned up grill externals - replaced with svn:externals to svn.grrrr.org/ext/trunk/
svn path=/trunk/; revision=10951
Diffstat (limited to 'externals/grill/vst/src')
-rw-r--r--externals/grill/vst/src/editor.cpp27
-rw-r--r--externals/grill/vst/src/editor.h26
-rw-r--r--externals/grill/vst/src/editormac.hpp58
-rw-r--r--externals/grill/vst/src/editorwin.hpp361
-rw-r--r--externals/grill/vst/src/main.cpp980
-rw-r--r--externals/grill/vst/src/main.h28
-rw-r--r--externals/grill/vst/src/vst.rc135
-rw-r--r--externals/grill/vst/src/vstedit.cpp82
-rw-r--r--externals/grill/vst/src/vsthost.cpp461
-rw-r--r--externals/grill/vst/src/vsthost.h357
-rw-r--r--externals/grill/vst/src/vstmaster.cpp282
-rw-r--r--externals/grill/vst/src/vstmidi.cpp52
-rw-r--r--externals/grill/vst/src/vstparam.cpp106
13 files changed, 0 insertions, 2955 deletions
diff --git a/externals/grill/vst/src/editor.cpp b/externals/grill/vst/src/editor.cpp
deleted file mode 100644
index be412b00..00000000
--- a/externals/grill/vst/src/editor.cpp
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
-vst~ - VST plugin object for PD
-based on the work of Jarno Seppänen and Mark Williamson
-
-Copyright (c)2003-2004 Thomas Grill (xovo@gmx.net)
-For information on usage and redistribution, and for a DISCLAIMER OF ALL
-WARRANTIES, see the file, "license.txt," in this distribution.
-*/
-
-#include "editor.h"
-#include "vsthost.h"
-#include <flext.h>
-
-#if FLEXT_OS == FLEXT_OS_WIN
-// only Windows code is situated in this file
-
-#include "editorwin.hpp"
-
-#elif FLEXT_OS == FLEXT_OS_MAC
-
-#include "editormac.hpp"
-
-#else
-
-#error Platform not supported
-
-#endif
diff --git a/externals/grill/vst/src/editor.h b/externals/grill/vst/src/editor.h
deleted file mode 100644
index 7c5831e7..00000000
--- a/externals/grill/vst/src/editor.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
-vst~ - VST plugin object for PD
-based on the work of Jarno Seppänen and Mark Williamson
-
-Copyright (c)2003-2005 Thomas Grill (gr@grrrr.org)
-For information on usage and redistribution, and for a DISCLAIMER OF ALL
-WARRANTIES, see the file, "license.txt," in this distribution.
-*/
-
-#ifndef __EDITOR_H
-#define __EDITOR_H
-
-class VSTPlugin;
-
-void SetupEditor();
-void StartEditor(VSTPlugin *p);
-void StopEditor(VSTPlugin *p);
-void ShowEditor(VSTPlugin *p,bool show);
-void MoveEditor(VSTPlugin *p,int x,int y);
-void SizeEditor(VSTPlugin *p,int x,int y);
-void TitleEditor(VSTPlugin *p,const char *t);
-void CaptionEditor(VSTPlugin *p,bool c);
-void HandleEditor(VSTPlugin *p,bool h);
-void FrontEditor(VSTPlugin *p);
-
-#endif // __EDITOR_H
diff --git a/externals/grill/vst/src/editormac.hpp b/externals/grill/vst/src/editormac.hpp
deleted file mode 100644
index b519aa06..00000000
--- a/externals/grill/vst/src/editormac.hpp
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
-vst~ - VST plugin object for PD
-based on the work of Jarno Seppänen and Mark Williamson
-
-Copyright (c)2003-2004 Thomas Grill (xovo@gmx.net)
-For information on usage and redistribution, and for a DISCLAIMER OF ALL
-WARRANTIES, see the file, "license.txt," in this distribution.
-*/
-
-#include "Editor.h"
-#include "VstHost.h"
-#include <flext.h>
-
-
-#if FLEXT_OS == FLEXT_OS_MAC
-// only Mac OSX code is situated in this file
-
-void SetupEditor()
-{
-}
-
-void StartEditor(VSTPlugin *p)
-{
-}
-
-void StopEditor(VSTPlugin *p)
-{
-}
-
-void ShowEditor(VSTPlugin *p,bool show)
-{
-}
-
-void MoveEditor(VSTPlugin *p,int x,int y)
-{
-}
-
-void SizeEditor(VSTPlugin *p,int x,int y)
-{
-}
-
-void CaptionEditor(VSTPlugin *plug,bool c)
-{
-}
-
-void TitleEditor(VSTPlugin *p,const char *t)
-{
-}
-
-void HandleEditor(VSTPlugin *p,bool h)
-{
-}
-
-void FrontEditor(VSTPlugin *p)
-{
-}
-
-#endif // FLEXT_OS_MAC
diff --git a/externals/grill/vst/src/editorwin.hpp b/externals/grill/vst/src/editorwin.hpp
deleted file mode 100644
index 558301bc..00000000
--- a/externals/grill/vst/src/editorwin.hpp
+++ /dev/null
@@ -1,361 +0,0 @@
-/*
-vst~ - VST plugin object for PD
-based on the work of Jarno Seppänen and Mark Williamson
-
-Copyright (c)2003-2005 Thomas Grill (gr@grrrr.org)
-For information on usage and redistribution, and for a DISCLAIMER OF ALL
-WARRANTIES, see the file, "license.txt," in this distribution.
-*/
-
-#if FLEXT_OS != FLEXT_OS_WIN
-// only Windows code is situated in this file
-#error Wrong implementation
-#endif
-
-#include <map>
-#include <windows.h>
-
-class ThrCmp
-{
-public:
- inline bool operator()(const flext::thrid_t &a,const flext::thrid_t &b) const
- {
- if(sizeof(a) == sizeof(size_t))
- return *(size_t *)&a < *(size_t *)&b;
- else
- return memcmp(&a,&b,sizeof(a)) < 0;
- }
-};
-
-typedef std::map<flext::thrid_t,VSTPlugin *,ThrCmp> WndMap;
-static WndMap wndmap;
-static flext::ThrMutex mapmutex;
-
-#define TIMER_INTERVAL 25
-#define WCLNAME "vst~-class"
-
-
-static LRESULT CALLBACK wndproc(HWND hwnd,UINT msg,WPARAM wp,LPARAM lp)
-{
- mapmutex.Lock();
- VSTPlugin *plug = wndmap[flext::GetThreadId()];
- mapmutex.Unlock();
- FLEXT_ASSERT(plug != NULL);
-
- LRESULT res = 0;
-
- switch(msg) {
- case WM_CREATE:
- // Initialize the window.
- plug->StartEditing(hwnd);
- break;
-
- case WM_CLOSE:
-#ifdef FLEXT_LOGGING
- flext::post("WM_CLOSE");
-#endif
- plug->StopEditing();
-
- DestroyWindow(hwnd);
- break;
- case WM_DESTROY:
-#ifdef FLEXT_LOGGING
- flext::post("WM_DESTROY");
-#endif
- // stop editor thread
- PostQuitMessage(0);
- break;
-
- case WM_TIMER: // fall through
- case WM_ENTERIDLE:
- plug->EditorIdle();
- break;
-#if 0
- case WM_WINDOWPOSCHANGED: {
- // ignore after WM_CLOSE so that x,y positions are preserved
- if(!plug->IsEdited()) break;
-
- WINDOWPOS *w = (WINDOWPOS *)lp;
-
- WINDOWINFO winfo;
- winfo.cbSize = sizeof(winfo);
- GetWindowInfo(hwnd,&winfo);
- int cpx = winfo.rcWindow.left-winfo.rcClient.left;
- int cpy = winfo.rcWindow.top-winfo.rcClient.top;
- int csx = winfo.rcWindow.right-winfo.rcClient.right-cpx;
- int csy = winfo.rcWindow.bottom-winfo.rcClient.bottom-cpy;
- // send normalized coordinates to plugin
- plug->SetPos(w->x+cpx,w->y+cpy,false);
- plug->SetSize(w->cx+csx,w->cy+csy,false);
- return 0;
- }
-#else
- case WM_MOVE: {
- // ignore after WM_CLOSE so that x,y positions are preserved
- if(!plug->IsEdited()) break;
-
- WORD wx = LOWORD(lp),wy = HIWORD(lp);
- short x = reinterpret_cast<short &>(wx),y = reinterpret_cast<short &>(wy);
- // x and y are the coordinates of the client rect (= actual VST interface)
-
- WINDOWINFO winfo;
- winfo.cbSize = sizeof(winfo);
- GetWindowInfo(hwnd,&winfo);
- int px = winfo.rcWindow.left-winfo.rcClient.left;
- int py = winfo.rcWindow.top-winfo.rcClient.top;
- // send normalized coordinates to plugin
- plug->SetPos(x+px,y+py,false);
- break;
- }
-
- case WM_SIZE: {
- if(!plug->IsEdited()) break;
-
- WORD wx = LOWORD(lp),wy = HIWORD(lp);
- short x = reinterpret_cast<short &>(wx),y = reinterpret_cast<short &>(wy);
- // x and y are the coordinates of the client rect (= actual VST interface)
-
- WINDOWINFO winfo;
- winfo.cbSize = sizeof(winfo);
- GetWindowInfo(hwnd,&winfo);
- int px = winfo.rcWindow.left-winfo.rcClient.left;
- int py = winfo.rcWindow.top-winfo.rcClient.top;
- int sx = winfo.rcWindow.right-winfo.rcClient.right-px;
- int sy = winfo.rcWindow.bottom-winfo.rcClient.bottom-py;
- // send normalized coordinates to plugin
- plug->SetSize(x+sx,y+sy,false);
- break;
- }
-#endif
-
-#if 0 // NOT needed for Windows
- case WM_PAINT: {
- // Paint the window's client area.
- RECT rect;
- GetUpdateRect(hwnd,&rect,FALSE);
- ERect erect;
- erect.left = rect.left;
- erect.top = rect.top;
- erect.right = rect.right;
- erect.bottom = rect.bottom;
- plug->Paint(erect);
- break;
- }
-#endif
- case WM_SHOWWINDOW:
- plug->Visible(wp != FALSE,false);
- break;
-
- default:
- #ifdef FLEXT_LOGGING
-// flext::post("WND MSG %i, WP=%i, lp=%i",msg,wp,lp);
- #endif
-
- res = DefWindowProc(hwnd,msg,wp,lp);
- }
- return res;
-}
-
-static void windowsize(HWND wnd,int x,int y,int w,int h)
-{
- // pre correction
- WINDOWINFO winfo;
- winfo.cbSize = sizeof(winfo);
- GetWindowInfo(wnd,&winfo);
- int sx1 = (winfo.rcWindow.right-winfo.rcClient.right)-(winfo.rcWindow.left-winfo.rcClient.left);
- int sy1 = (winfo.rcWindow.bottom-winfo.rcClient.bottom)-(winfo.rcWindow.top-winfo.rcClient.top);
-
- // First reflect new state in flags
- SetWindowPos(wnd,NULL,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE|SWP_NOZORDER|SWP_FRAMECHANGED);
-
- // post correction
- GetWindowInfo(wnd,&winfo);
- int sx2 = (winfo.rcWindow.right-winfo.rcClient.right)-(winfo.rcWindow.left-winfo.rcClient.left);
- int sy2 = (winfo.rcWindow.bottom-winfo.rcClient.bottom)-(winfo.rcWindow.top-winfo.rcClient.top);
-
- // set pos, size and flags
- SetWindowPos(wnd,NULL,x,y,w+sx2-sx1,h+sy2-sy1,SWP_NOZORDER);
-}
-
-static void threadfun(flext::thr_params *p)
-{
- flext::RelPriority(-2);
-
- VSTPlugin *plug = (VSTPlugin *)p;
- HINSTANCE hinstance = (HINSTANCE)GetModuleHandle(NULL);
- flext::thrid_t thrid = flext::GetThreadId();
-
- mapmutex.Lock();
- wndmap[thrid] = plug;
- mapmutex.Unlock();
-
- char tmp[256];
- sprintf(tmp,"vst~ - %s",plug->GetName());
-
- // Get size from plugin
- ERect r;
- plug->GetEditorRect(r);
-
- HWND wnd = CreateWindowEx(
- plug->GetHandle()?WS_EX_APPWINDOW:WS_EX_TOOLWINDOW,
- WCLNAME,tmp,
- WS_POPUP|WS_SYSMENU|WS_MINIMIZEBOX, // no border for the beginning to set proper coordinates
- plug->GetX(),plug->GetY(),r.right-r.left,r.bottom-r.top,
- NULL,NULL,
- hinstance,NULL
- );
-
- if(!wnd)
- FLEXT_LOG1("wnd == NULL: %i",GetLastError());
- else {
- // idle timer
- SetTimer(wnd,0,TIMER_INTERVAL,NULL);
-
- // set caption style
- CaptionEditor(plug,plug->GetCaption());
-
- if(plug->IsVisible()) {
- SetForegroundWindow(wnd);
- ShowWindow(wnd,1);
-
- // notify plugin
- // plug->Dispatch(effEditTop,0,0,0,0);
- }
- else
- ShowWindow(wnd,0);
-
- try
- {
-
- // Message loop
- MSG msg;
- BOOL bRet;
- while( (bRet = GetMessage( &msg, NULL, 0, 0 )) != 0) {
- if(bRet == -1) {
- // handle the error and possibly exit
- FLEXT_LOG1("GetMessage error: %i",GetLastError());
- }
- else {
- TranslateMessage(&msg);
-// double tm1 = flext::GetOSTime();
- DispatchMessage(&msg);
-// double tm2 = flext::GetOSTime();
-// if(tm2-tm1 > 0.01) FLEXT_LOG1("halt %lf",(tm2-tm1)*1000);
- }
- }
-
- }
-
- catch(exception &e) {
- flext::post("vst~ - exception caught, exiting: %s",e.what());
- }
- catch(...) {
- flext::post("vst~ - exception caught, exiting");
- }
-
- if(plug) plug->EditingEnded();
- }
-
- mapmutex.Lock();
- wndmap.erase(thrid);
- mapmutex.Unlock();
-}
-
-void SetupEditor()
-{
- HINSTANCE hinstance = (HINSTANCE)GetModuleHandle(NULL);
-
- // Fill in the window class structure with parameters that describe the main window.
- WNDCLASS wcx;
- wcx.style = CS_DBLCLKS; // | CS_HREDRAW | CS_VREDRAW; // redraw if size changes
- wcx.lpfnWndProc = wndproc; // points to window procedure
- wcx.cbClsExtra = 0; // no extra class memory
- wcx.cbWndExtra = 0; // no extra window memory
- wcx.hInstance = hinstance; // handle to instance
- wcx.hIcon = NULL; //LoadIcon(NULL, IDI_APPLICATION); // predefined app. icon
- wcx.hCursor = LoadCursor(NULL, IDC_ARROW); // predefined arrow
- wcx.hbrBackground = NULL; //GetStockObject(WHITE_BRUSH); // white background brush
- wcx.lpszMenuName = NULL; // name of menu resource
- wcx.lpszClassName = WCLNAME; // name of window class
-
- ATOM at = RegisterClass(&wcx);
- FLEXT_ASSERT(at);
-}
-
-void StartEditor(VSTPlugin *p)
-{
-#ifdef FLEXT_LOGGING
- flext::post("Start editor 1");
-#endif
- flext::LaunchThread(threadfun,reinterpret_cast<flext::thr_params *>(p));
-#ifdef FLEXT_LOGGING
- flext::post("Start editor 2");
-#endif
-}
-
-void StopEditor(VSTPlugin *p)
-{
-#ifdef FLEXT_LOGGING
- flext::post("Stop editor 1");
-#endif
- PostMessage(p->EditorHandle(),WM_CLOSE,0,0);
-// flext::StopThread(threadfun,reinterpret_cast<flext::thr_params *>(p));
-#ifdef FLEXT_LOGGING
- flext::post("Stop editor 2");
-#endif
-}
-
-void ShowEditor(VSTPlugin *p,bool show)
-{
- ShowWindow(p->EditorHandle(),show);
-}
-
-void MoveEditor(VSTPlugin *p,int x,int y)
-{
- HWND wnd = p->EditorHandle();
- SetWindowPos(wnd,NULL,x,y,0,0,SWP_NOSIZE|SWP_NOZORDER);
-}
-
-void SizeEditor(VSTPlugin *p,int x,int y)
-{
- HWND wnd = p->EditorHandle();
- SetWindowPos(wnd,NULL,0,0,x,y,SWP_NOMOVE|SWP_NOZORDER);
-}
-
-void FrontEditor(VSTPlugin *p)
-{
- SetForegroundWindow(p->EditorHandle());
-}
-
-void CaptionEditor(VSTPlugin *plug,bool c)
-{
- HWND wnd = plug->EditorHandle();
- LONG ns,style = GetWindowLong(wnd,GWL_STYLE);
- if(c) ns = style|WS_BORDER|WS_CAPTION;
- else ns = style&~(WS_BORDER|WS_CAPTION);
- if(ns != style) {
- SetWindowLong(wnd,GWL_STYLE,ns);
- windowsize(wnd,plug->GetX(),plug->GetY(),plug->GetW(),plug->GetH());
- }
-}
-
-void HandleEditor(VSTPlugin *plug,bool h)
-{
- HWND wnd = plug->EditorHandle();
- bool v = plug->IsVisible();
- if(v) ShowWindow(wnd,FALSE);
- SetWindowLong(wnd,GWL_EXSTYLE,h?WS_EX_APPWINDOW:WS_EX_TOOLWINDOW);
- if(v) ShowWindow(wnd,TRUE);
-}
-
-void TitleEditor(VSTPlugin *p,const char *t)
-{
- SetWindowText(p->EditorHandle(),t);
-}
-
-/*
-bool IsEditorShown(const VSTPlugin *p)
-{
- return IsWindowVisible(p->EditorHandle()) != FALSE;
-}
-*/ \ No newline at end of file
diff --git a/externals/grill/vst/src/main.cpp b/externals/grill/vst/src/main.cpp
deleted file mode 100644
index d0e5a6c0..00000000
--- a/externals/grill/vst/src/main.cpp
+++ /dev/null
@@ -1,980 +0,0 @@
-/*
-vst~ - VST plugin object for PD
-based on the work of Jarno Seppänen and Mark Williamson
-
-Copyright (c)2003-2005 Thomas Grill (gr@grrrr.org)
-For information on usage and redistribution, and for a DISCLAIMER OF ALL
-WARRANTIES, see the file, "license.txt," in this distribution.
-*/
-
-// needed for CoInitializeEx
-#define _WIN32_DCOM
-
-#include "main.h"
-
-#include "editor.h"
-#include "vsthost.h"
-
-#include <stdlib.h>
-#include <string.h>
-#include <string>
-
-#if FLEXT_OS == FLEXT_OS_WIN
-#include <direct.h>
-#include <io.h>
-#include <objbase.h>
-#endif
-
-
-#define VST_VERSION "0.1.0pre26"
-
-
-class vst
- : public flext_dsp
- , public Responder
-{
- FLEXT_HEADER_S(vst,flext_dsp,Setup)
-
-public:
- vst(int argc,const t_atom *argv);
- ~vst();
-
-protected:
- virtual bool CbDsp();
- virtual void CbSignal();
-
- virtual void CbClick() { ms_edit(true); }
-
- bool ms_plug(int argc,const t_atom *argv);
- bool ms_plug(const AtomList &args) { return ms_plug(args.Count(),args.Atoms()); }
- void mg_plug(AtomList &sym) const { sym(1); SetString(sym[0],plugname.c_str()); }
-
- void ms_subplug(int argc,const t_atom *argv);
- void ms_subplug(const AtomList &args) { ms_subplug(args.Count(),args.Atoms()); }
- void mg_subplug(AtomList &sym) const { sym(1); SetString(sym[0],subplug.c_str()); }
-
- void m_pluglist() { if(plug) plug->ListPlugs(sym_pluglist); }
-
- void mg_editor(bool &ed) { ed = plug && plug->HasEditor(); }
-
- void ms_edit(bool on) { if(plug) plug->Edit(on); }
- void mg_edit(bool &ed) { ed = plug && plug->IsEdited(); }
- void ms_vis(bool vis) { if(plug) plug->Visible(vis); }
- void mg_vis(bool &vis) { vis = plug && plug->IsVisible(); }
-
- void mg_winx(int &x) const { x = plug?plug->GetX():0; }
- void mg_winy(int &y) const { y = plug?plug->GetY():0; }
- void mg_winw(int &x) const { x = plug?plug->GetW():0; }
- void mg_winh(int &y) const { y = plug?plug->GetH():0; }
- void ms_winx(int x) { if(plug) plug->SetX(x); }
- void ms_winy(int y) { if(plug) plug->SetY(y); }
- void ms_winw(int x) { if(plug) plug->SetW(x); }
- void ms_winh(int y) { if(plug) plug->SetH(y); }
- void ms_wincaption(bool c) { if(plug) plug->SetCaption(c); }
- void mg_wincaption(bool &c) const { c = plug && plug->GetCaption(); }
- void ms_winhandle(bool c) { if(plug) plug->SetHandle(c); }
- void mg_winhandle(bool &c) const { c = plug && plug->GetHandle(); }
- void ms_wintitle(const AtomList &t);
- void mg_wintitle(AtomList &t) const { if(plug) { t(1); SetString(t[0],plug->GetTitle()); } }
- void m_winfront() const { if(plug) plug->ToFront(); }
-
- void mg_chnsin(int &c) const { c = plug?plug->GetNumInputs():0; }
- void mg_chnsout(int &c) const { c = plug?plug->GetNumOutputs():0; }
- void mg_params(int &p) const { p = plug?plug->GetNumParams():0; }
- void mg_programs(int &p) const { p = plug?plug->GetNumPrograms():0; }
- void mg_progcats(int &p) const { p = plug?plug->GetNumCategories():0; }
- void mg_plugname(const t_symbol *&s) const { s = plug?MakeSymbol(plug->GetName()):sym__; }
- void mg_plugvendor(const t_symbol *&s) const { s = plug?MakeSymbol(plug->GetVendorName()):sym__; }
- void mg_plugdll(const t_symbol *&s) const { s = plug?MakeSymbol(plug->GetDllName()):sym__; }
- void mg_plugversion(int &v) const { v = plug?plug->GetVersion():0; }
- void mg_issynth(bool &s) const { s = plug && plug->IsSynth(); }
-
- void m_print(int ac,const t_atom *av);
-
- void ms_program(int p) { if(plug && p >= 0) plug->SetCurrentProgram(p); }
- void mg_program(int &p) const { p = plug?plug->GetCurrentProgram():0; }
- void mg_progname(int argc,const t_atom *argv) const;
-
- void m_pname(int pnum);
- void ms_paramnames(int cnt) { paramnames = cnt; if(plug) plug->ScanParams(cnt); }
-
- void ms_param(int pnum,float val);
- void ms_params(int argc,const t_atom *argv);
- void mg_param(int pnum);
- void mg_params(int argc,const t_atom *argv);
- void m_ptext(int pnum);
- void m_ptexts(int argc,const t_atom *argv);
-
- void mg_channel(int &chn) const { chn = plug?plug->GetChannel():0; }
- void ms_channel(int chn) { if(plug) plug->SetChannel(chn); }
-
- void m_note(int note,int vel);
- void m_noteoff(int note) { m_note(note,0); }
- void m_programchange(int ctrl_value) { if(plug) plug->AddProgramChange(ctrl_value); }
- void m_ctrlchange(int control,int ctrl_value) { if(plug) plug->AddControlChange(control,ctrl_value); }
- void m_aftertouch(int ctrl_value) { if(plug) plug->AddAftertouch(ctrl_value); }
- void m_polyaftertouch(int note,int ctrl_value) { if(plug) plug->AddPolyAftertouch(note,ctrl_value); }
- void m_pitchbend(int ctrl_value) { if(plug) plug->AddPitchBend(ctrl_value); }
-
- void mg_dumpevents(bool &ev) const { ev = plug?plug->GetEvents():false; }
- void ms_dumpevents(bool ev) { if(plug) plug->SetEvents(ev); }
-
- void mg_playing(bool &p) { p = plug && plug->GetPlaying(); }
- void ms_playing(bool p) { if(plug) plug->SetPlaying(p); }
- void mg_looping(bool &p) { p = plug && plug->GetLooping(); }
- void ms_looping(bool p) { if(plug) plug->SetLooping(p); }
- void mg_feedback(bool &p) { p = plug && plug->GetFeedback(); }
- void ms_feedback(bool p) { if(plug) plug->SetFeedback(p); }
- void mg_samplepos(float &p) { p = plug?(float)plug->GetSamplePos():0; }
- void ms_samplepos(float p) { if(plug) plug->SetSamplePos(p); }
- void mg_ppqpos(float &p) { p = plug?(float)plug->GetPPQPos():0; }
- void ms_ppqpos(float p) { if(plug) plug->SetPPQPos(p); }
- void mg_tempo(float &p) { p = plug?(float)plug->GetTempo():0; }
- void ms_tempo(float p) { if(plug) plug->SetTempo(p); }
- void mg_barstart(float &p) { p = plug?(float)plug->GetBarStart():0; }
- void ms_barstart(float p) { if(plug) plug->SetBarStart(p); }
- void mg_cyclestart(float &p) { p = plug?(float)plug->GetCycleStart():0; }
- void ms_cyclestart(float p) { if(plug) plug->SetCycleStart(p); }
- void mg_cycleend(float &p) { p = plug?(float)plug->GetCycleEnd():0; }
- void ms_cycleend(float p) { if(plug) plug->SetCycleEnd(p); }
- void mg_cyclelength(float &p) { p = plug?(float)(plug->GetCycleEnd()-plug->GetCycleStart()):0; }
- void ms_cyclelength(float p) { if(p) plug->SetCycleEnd(plug->GetCycleStart()+p); }
- void mg_timesignom(int &p) { p = plug?plug->GetTimesigNom():0; }
- void ms_timesignom(int p) { if(plug) plug->SetTimesigNom(p); }
- void mg_timesigden(int &p) { p = plug?plug->GetTimesigDen():0; }
- void ms_timesigden(int p) { if(plug) plug->SetTimesigDen(p); }
- void mg_smpteoffset(int &p) { p = plug?plug->GetSmpteOffset():0; }
- void ms_smpteoffset(int p) { if(plug) plug->SetSmpteOffset(p); }
- void mg_smpterate(int &p) { p = plug?plug->GetSmpteRate():0; }
- void ms_smpterate(int p) { if(plug) plug->SetSmpteRate(p); }
-
-private:
- void display_parameter(int param,bool showparams);
-
- VSTPlugin *plug;
- std::string plugname,subplug;
- bool visible,bypass,mute;
- int paramnames;
-
- int blsz;
- bool (VSTPlugin::*vstfun)(t_sample **insigs,t_sample **outsigs,long n);
- bool sigmatch;
- t_sample **vstin,**vstout,**tmpin,**tmpout;
-
- void InitPlug();
- void ClearPlug();
- bool LoadPlug();
- void InitPlugDSP();
- void InitBuf();
- void ClearBuf();
-
- static void Setup(t_classid);
-
- virtual void Respond(const t_symbol *sym,int argc = 0,const t_atom *argv = NULL);
-
- FLEXT_CALLBACK_V(m_print)
-
- FLEXT_CALLVAR_V(mg_plug,ms_plug)
- FLEXT_CALLVAR_V(mg_subplug,ms_subplug)
- FLEXT_CALLBACK(m_pluglist)
-
- FLEXT_CALLVAR_B(mg_edit,ms_edit)
- FLEXT_CALLGET_B(mg_editor)
- FLEXT_CALLVAR_B(mg_vis,ms_vis)
- FLEXT_ATTRVAR_B(bypass)
- FLEXT_ATTRVAR_B(mute)
-
- FLEXT_CALLVAR_I(mg_channel,ms_channel)
- FLEXT_CALLBACK_II(m_note)
- FLEXT_CALLBACK_I(m_noteoff)
- FLEXT_CALLBACK_II(m_ctrlchange)
- FLEXT_CALLBACK_I(m_aftertouch)
- FLEXT_CALLBACK_II(m_polyaftertouch)
- FLEXT_CALLBACK_I(m_pitchbend)
-
- FLEXT_CALLVAR_B(mg_dumpevents,ms_dumpevents)
-
- FLEXT_CALLBACK_I(m_programchange)
- FLEXT_CALLVAR_I(mg_program,ms_program)
- FLEXT_CALLBACK_V(mg_progname)
-
- FLEXT_CALLBACK_I(m_pname)
- FLEXT_ATTRGET_I(paramnames)
- FLEXT_CALLSET_I(ms_paramnames)
- FLEXT_CALLBACK_2(ms_param,int,float)
- FLEXT_CALLBACK_V(ms_params)
- FLEXT_CALLBACK_I(mg_param)
- FLEXT_CALLBACK_V(mg_params)
- FLEXT_CALLBACK_I(m_ptext)
- FLEXT_CALLBACK_V(m_ptexts)
-
- FLEXT_CALLVAR_I(mg_winx,ms_winx)
- FLEXT_CALLVAR_I(mg_winy,ms_winy)
- FLEXT_CALLVAR_I(mg_winw,ms_winw)
- FLEXT_CALLVAR_I(mg_winh,ms_winh)
- FLEXT_CALLVAR_B(mg_wincaption,ms_wincaption)
- FLEXT_CALLVAR_B(mg_winhandle,ms_winhandle)
- FLEXT_CALLVAR_V(mg_wintitle,ms_wintitle)
- FLEXT_CALLBACK(m_winfront)
-
- FLEXT_CALLGET_I(mg_chnsin)
- FLEXT_CALLGET_I(mg_chnsout)
- FLEXT_CALLGET_I(mg_params)
- FLEXT_CALLGET_I(mg_programs)
- FLEXT_CALLGET_I(mg_progcats)
- FLEXT_CALLGET_S(mg_plugname)
- FLEXT_CALLGET_S(mg_plugvendor)
- FLEXT_CALLGET_S(mg_plugdll)
- FLEXT_CALLGET_I(mg_plugversion)
- FLEXT_CALLGET_B(mg_issynth)
-
- FLEXT_CALLVAR_B(mg_playing,ms_playing)
- FLEXT_CALLVAR_B(mg_looping,ms_looping)
- FLEXT_CALLVAR_B(mg_feedback,ms_feedback)
- FLEXT_CALLVAR_F(mg_samplepos,ms_samplepos)
- FLEXT_CALLVAR_F(mg_ppqpos,ms_ppqpos)
- FLEXT_CALLVAR_F(mg_tempo,ms_tempo)
- FLEXT_CALLVAR_F(mg_barstart,ms_barstart)
- FLEXT_CALLVAR_F(mg_cyclestart,ms_cyclestart)
- FLEXT_CALLVAR_F(mg_cycleend,ms_cycleend)
- FLEXT_CALLVAR_F(mg_cyclelength,ms_cyclelength)
- FLEXT_CALLVAR_I(mg_timesignom,ms_timesignom)
- FLEXT_CALLVAR_I(mg_timesigden,ms_timesigden)
- FLEXT_CALLVAR_I(mg_smpteoffset,ms_smpteoffset)
- FLEXT_CALLVAR_I(mg_smpterate,ms_smpterate)
-
- static const t_symbol *sym_progname,*sym_pname,*sym_param,*sym_ptext,*sym_pluglist;
-};
-
-FLEXT_NEW_DSP_V("vst~",vst);
-
-
-const t_symbol *vst::sym_progname,*vst::sym_pname,*vst::sym_param,*vst::sym_ptext,*vst::sym_pluglist;
-
-void vst::Setup(t_classid c)
-{
- post("");
- post("vst~ %s - VST plugin object, (C)2003-05 Thomas Grill",VST_VERSION);
- post("based on the work of Jarno Seppänen and Mark Williamson");
- post("");
-
- FLEXT_CADDATTR_VAR(c,"plug",mg_plug,ms_plug);
- FLEXT_CADDATTR_VAR(c,"subplug",mg_subplug,ms_subplug);
- FLEXT_CADDMETHOD_(c,0,"getpluglist",m_pluglist);
- FLEXT_CADDATTR_VAR(c,"edit",mg_edit,ms_edit);
- FLEXT_CADDATTR_GET(c,"editor",mg_editor);
- FLEXT_CADDATTR_VAR(c,"vis",mg_vis,ms_vis);
- FLEXT_CADDATTR_VAR1(c,"bypass",bypass);
- FLEXT_CADDATTR_VAR1(c,"mute",mute);
- FLEXT_CADDMETHOD_(c,0,"print",m_print);
-
- FLEXT_CADDATTR_VAR(c,"channel",mg_channel,ms_channel);
- FLEXT_CADDMETHOD_I(c,0,"noteoff",m_noteoff);
- FLEXT_CADDMETHOD_II(c,0,"note",m_note);
- FLEXT_CADDMETHOD_II(c,0,"patouch",m_polyaftertouch);
- FLEXT_CADDMETHOD_II(c,0,"ctlchg",m_ctrlchange);
- FLEXT_CADDMETHOD_(c,0,"atouch",m_aftertouch);
- FLEXT_CADDMETHOD_(c,0,"pbend",m_pitchbend);
-
- FLEXT_CADDATTR_VAR(c,"events",mg_dumpevents,ms_dumpevents);
-
- FLEXT_CADDMETHOD_(c,0,"progchg",m_programchange);
- FLEXT_CADDATTR_VAR(c,"program",mg_program,ms_program);
- FLEXT_CADDMETHOD_(c,0,"getprogname",mg_progname);
-
- FLEXT_CADDMETHOD_I(c,0,"getpname",m_pname);
- FLEXT_CADDATTR_VAR(c,"pnames",paramnames,ms_paramnames);
- FLEXT_CADDMETHOD_2(c,0,"param",ms_param,int,float);
- FLEXT_CADDMETHOD_(c,0,"param",ms_params);
- FLEXT_CADDMETHOD_(c,0,"getparam",mg_param);
- FLEXT_CADDMETHOD_(c,0,"getparam",mg_params);
- FLEXT_CADDMETHOD_(c,0,"getptext",m_ptext);
- FLEXT_CADDMETHOD_(c,0,"getptext",m_ptexts);
-
- FLEXT_CADDATTR_VAR(c,"x",mg_winx,ms_winx);
- FLEXT_CADDATTR_VAR(c,"y",mg_winy,ms_winy);
- FLEXT_CADDATTR_VAR(c,"w",mg_winw,ms_winw);
- FLEXT_CADDATTR_VAR(c,"h",mg_winh,ms_winh);
- FLEXT_CADDATTR_VAR(c,"title",mg_wintitle,ms_wintitle);
- FLEXT_CADDATTR_VAR(c,"caption",mg_wincaption,ms_wincaption);
- FLEXT_CADDATTR_VAR(c,"handle",mg_winhandle,ms_winhandle);
- FLEXT_CADDMETHOD_(c,0,"front",m_winfront);
-
- FLEXT_CADDATTR_GET(c,"ins",mg_chnsin);
- FLEXT_CADDATTR_GET(c,"outs",mg_chnsout);
- FLEXT_CADDATTR_GET(c,"params",mg_params);
- FLEXT_CADDATTR_GET(c,"programs",mg_programs);
- FLEXT_CADDATTR_GET(c,"progcats",mg_progcats);
- FLEXT_CADDATTR_GET(c,"name",mg_plugname);
- FLEXT_CADDATTR_GET(c,"vendor",mg_plugvendor);
- FLEXT_CADDATTR_GET(c,"dll",mg_plugdll);
- FLEXT_CADDATTR_GET(c,"version",mg_plugversion);
- FLEXT_CADDATTR_GET(c,"synth",mg_issynth);
-
- FLEXT_CADDATTR_VAR(c,"playing",mg_playing,ms_playing);
- FLEXT_CADDATTR_VAR(c,"looping",mg_looping,ms_looping);
- FLEXT_CADDATTR_VAR(c,"feedback",mg_feedback,ms_feedback);
- FLEXT_CADDATTR_VAR(c,"samplepos",mg_samplepos,ms_samplepos);
- FLEXT_CADDATTR_VAR(c,"ppqpos",mg_ppqpos,ms_ppqpos);
- FLEXT_CADDATTR_VAR(c,"tempo",mg_tempo,ms_tempo);
- FLEXT_CADDATTR_VAR(c,"barstart",mg_barstart,ms_barstart);
- FLEXT_CADDATTR_VAR(c,"loopstart",mg_cyclestart,ms_cyclestart);
- FLEXT_CADDATTR_VAR(c,"loopend",mg_cycleend,ms_cycleend);
- FLEXT_CADDATTR_VAR(c,"looplength",mg_cyclelength,ms_cyclelength);
- FLEXT_CADDATTR_VAR(c,"timenom",mg_timesignom,ms_timesignom);
- FLEXT_CADDATTR_VAR(c,"timeden",mg_timesigden,ms_timesigden);
- FLEXT_CADDATTR_VAR(c,"smpteoffset",mg_smpteoffset,ms_smpteoffset);
- FLEXT_CADDATTR_VAR(c,"smpterate",mg_smpterate,ms_smpterate);
-
- sym_progname = MakeSymbol("progname");
- sym_pname = MakeSymbol("pname");
- sym_param = MakeSymbol("param");
- sym_ptext = MakeSymbol("ptext");
- sym_pluglist = MakeSymbol("pluglist");
-
- VSTPlugin::Setup();
- SetupEditor();
-}
-
-static int corefs = 0;
-
-vst::vst(int argc,const t_atom *argv):
- plug(NULL),visible(false),
- blsz(0),
- vstfun(NULL),vstin(NULL),vstout(NULL),tmpin(NULL),tmpout(NULL),
- bypass(false),mute(false),paramnames(0)
-{
-#if FLEXT_OS == FLEXT_OS_WIN
- // this is necessary for Waveshell
- if(!corefs++) CoInitializeEx(NULL,COINIT_MULTITHREADED+COINIT_SPEED_OVER_MEMORY);
-#endif
-
- int ins = 1,outs = 1;
- if(argc >= 1 && CanbeInt(argv[0])) { ins = GetAInt(argv[0]); argc--,argv++; }
- if(argc >= 1 && CanbeInt(argv[0])) { outs = GetAInt(argv[0]); argc--,argv++; }
-
- AddInSignal(ins);
- AddOutSignal(outs);
-
- if(argc >= 1 && !ms_plug(argc,argv)) InitProblem();
-}
-
-vst::~vst()
-{
- ClearPlug();
-#if FLEXT_OS == FLEXT_OS_WIN
- if(!--corefs) CoUninitialize();
-#endif
-}
-
-void vst::ClearPlug()
-{
- if(plug) {
- ClearBuf(); // needs valid plug
- VSTPlugin::Delete(plug);
- plug = NULL;
- }
-}
-
-void vst::InitPlug()
-{
- FLEXT_ASSERT(plug);
-
- vstfun = plug->IsReplacing()?&VSTPlugin::processReplacing:&VSTPlugin::process;
- sigmatch = plug->GetNumInputs() == CntInSig() && plug->GetNumOutputs() == CntOutSig();
- InitPlugDSP();
-
- InitBuf();
-
- plug->ScanParams(paramnames);
-}
-
-void vst::InitPlugDSP()
-{
- FLEXT_ASSERT(plug);
- // this might be invalid if DSP is switched off,
- // but the plug will get updated settings with m_dsp later
- plug->DspInit(Samplerate(),Blocksize());
-}
-
-void vst::ClearBuf()
-{
- if(!plug) return;
-
- if(vstin) {
- for(int i = 0; i < plug->GetNumInputs(); ++i) FreeAligned(vstin[i]);
- delete[] vstin; vstin = NULL;
- delete[] tmpin; tmpin = NULL;
- }
- if(vstout) {
- for(int i = 0; i < plug->GetNumOutputs(); ++i) FreeAligned(vstout[i]);
- delete[] vstout; vstout = NULL;
- delete[] tmpout; tmpout = NULL;
- }
-}
-
-void vst::InitBuf()
-{
- FLEXT_ASSERT(!vstin && !tmpin && !vstout && !tmpout);
- const int inputs = plug->GetNumInputs(),outputs = plug->GetNumOutputs();
-
- int i;
-
- vstin = new t_sample *[inputs];
- tmpin = new t_sample *[inputs];
- for(i = 0; i < inputs; ++i) vstin[i] = (t_sample *)NewAligned(Blocksize()*sizeof(t_sample));
-
- vstout = new t_sample *[outputs];
- tmpout = new t_sample *[outputs];
- for(i = 0; i < outputs; ++i) vstout[i] = (t_sample *)NewAligned(Blocksize()*sizeof(t_sample));
-}
-
-static std::string findFilePath(const std::string &path,const std::string &dllname)
-{
-#if FLEXT_OS == FLEXT_OS_WIN
- _chdir( path.c_str() );
- WIN32_FIND_DATA data;
- HANDLE fh = FindFirstFile(dllname.c_str(),&data);
- if(fh != INVALID_HANDLE_VALUE) {
- FindClose(fh);
- return path;
- }
-#endif
-/*
- CFileFind finder;
- if(finder.FindFile( dllname ))
- return path;
- else {
- finder.FindFile();
- while(finder.FindNextFile()) {
- if(finder.IsDirectory()) {
- if(!finder.IsDots()) {
- CString *npath = new CString( finder.GetFilePath());
- const C *ret = findFilePath( *npath , dllname );
- if(ret) {
- CString *retstr = new CString(ret);
- return *retstr;
- }
- }
- }
- }
- }
-*/
-
- return std::string();
-}
-
-// \todo this should be in the background, because it can take some time
-// ideally vst would get a response from VSTPlugin when readily loaded and
-// vst would dump out a respective signal to the patcher
-bool vst::LoadPlug()
-{
- if(plug) ClearPlug();
-
- VSTPlugin *p = VSTPlugin::New(this);
-
- // try loading the dll from the raw filename
- bool ok = p->Instance(plugname.c_str(),subplug.c_str());
- if(ok)
- FLEXT_LOG("raw filename loaded fine");
- else {
-#if FLEXT_SYS == FLEXT_SYS_PD
- // try finding it on the PD path
- char *name,dir[1024];
- int fd = open_via_path("",plugname.c_str(),".dll",dir,&name,sizeof(dir)-1,0);
- if(fd > 0) close(fd);
- else name = NULL;
-
- if(name) {
- FLEXT_LOG("found VST dll on the PD path");
- // if dir is current working directory... name points to dir
- if(dir == name) strcpy(dir,".");
-
- std::string dllname(dir);
- dllname += "\\";
- dllname += name;
-
- ok = p->Instance(dllname.c_str());
- }
-#endif
- }
-
- if(!ok) {
- // try finding it on the VST path
- char *vst_path = getenv("VST_PATH");
-
- std::string dllname(plugname);
- if(dllname.find(".dll") == -1) dllname += ".dll";
-
- if(vst_path) {
- FLEXT_LOG("found VST_PATH env variable");
- char* tok_path = new char[strlen( vst_path)+1];
- strcpy( tok_path , vst_path);
- char *tok = strtok( tok_path , ";" );
- while( tok != NULL ) {
- std::string abpath( tok );
- if( abpath[abpath.length()-1] != '\\' ) abpath += "\\";
-
- FLEXT_LOG1("trying VST_PATH %s",(const char *)abpath.c_str());
-
- std::string realpath = findFilePath( abpath , dllname );
- //post( "findFilePath( %s , %s ) = %s\n" , abpath , dllname , realpath );
- if ( realpath.length() ) {
- realpath += plugname;
- FLEXT_LOG1("trying %s",(const char *)realpath.c_str());
-
- ok = p->Instance(realpath.c_str());
- if(ok) {
- FLEXT_LOG("plugin loaded via VST_PATH");
- break;
- }
- }
-
- tok = strtok( NULL , ";" );
-// if(!tok) post("%s - couldn't find plugin",thisName());
- }
-
- delete[] tok_path;
- }
- }
-
- if(!ok) {
- post("%s - unable to load plugin '%s'",thisName(),plugname.c_str());
- VSTPlugin::Delete(p);
- }
- else {
- plug = p;
- InitPlug();
- }
-
- return ok;
-}
-
-static char *stripesc(char *buf)
-{
-#if FLEXT_SYS == FLEXT_SYS_PD
- // strip char escapes (only in newer/devel PD version)
- char *cs = buf,*cd = cs;
- while(*cs) {
- if(*cs != '\\') *(cd++) = *cs;
- ++cs;
- }
- *cd = 0;
-#endif
- return buf;
-}
-
-bool vst::ms_plug(int argc,const t_atom *argv)
-{
- ClearPlug();
-
- plugname.clear();
- char buf[255];
- for(int i = 0; i < argc; i++) {
- if(i > 0) plugname += ' ';
- GetAString(argv[i],buf,sizeof buf);
-#if FLEXT_OS == FLEXT_OS_WIN
- strlwr(buf);
-#endif
- plugname += stripesc(buf);
- }
-
- if(!plugname.length())
- return false;
- else
- return LoadPlug();
-}
-
-void vst::ms_subplug(int argc,const t_atom *argv)
-{
- subplug.clear();
- char buf[255];
- for(int i = 0; i < argc; i++) {
- if(i > 0) subplug += ' ';
- GetAString(argv[i],buf,sizeof buf);
- subplug += stripesc(buf);
- }
-
- LoadPlug();
-}
-
-bool vst::CbDsp()
-{
- if(plug) {
- FLEXT_ASSERT(vstfun);
-
- InitPlugDSP();
-
- if(blsz != Blocksize()) {
- blsz = Blocksize();
- ClearBuf();
- InitBuf();
- }
- }
- return true;
-}
-
-void vst::CbSignal()
-{
- if(!plug || !plug->UniqueID() || mute)
- flext_dsp::CbSignal();
- else if(bypass) {
- const int n = Blocksize();
- t_sample *const *insigs = InSig();
- t_sample *const *outsigs = OutSig();
-
- // copy as many channels as possible and zero dangling ones
-
- int i,mx = CntInSig();
- if(mx > CntOutSig()) mx = CntOutSig();
- if(mx == 1) {
- CopySamples(outsigs[0],insigs[0],n);
- i = 1;
- }
- else if(mx == 2) {
- t_sample *o1 = outsigs[0],*o2 = outsigs[1];
- const t_sample *i1 = insigs[0],*i2 = insigs[1];
- for(int s = 0; s < n; ++s) {
- const t_sample f = *(i1++);
- *(o2++) = *(i2++);
- *(o1++) = f;
- }
- i = 2;
- }
- else
- for(i = 0; i < mx; ++i) {
- // must copy via temporary buffer as ordering of output signals can collide with input signals
- CopySamples(tmpin[i],insigs[i],n);
- CopySamples(outsigs[i],tmpin[i],n);
- }
-
- for(; i < CntOutSig(); ++i)
- ZeroSamples(outsigs[i],n);
- }
- else if(sigmatch) {
- if(!(plug->*vstfun)(const_cast<t_sample **>(InSig()),const_cast<t_sample **>(OutSig()),Blocksize())) {
- for(int i = 0; i < CntOutSig(); ++i)
- ZeroSamples(OutSig()[i],Blocksize());
- }
- }
- else {
- const int inputs = plug->GetNumInputs(),outputs = plug->GetNumOutputs();
- const int cntin = CntInSig(),cntout = CntOutSig();
- const int n = Blocksize();
- t_sample *const *insigs = InSig();
- t_sample *const *outsigs = OutSig();
- t_sample **inv,**outv;
-
- if(inputs <= cntin)
- inv = const_cast<t_sample **>(insigs);
- else { // more plug inputs than inlets
- int i;
- for(i = 0; i < cntin; ++i) tmpin[i] = const_cast<t_sample *>(insigs[i]);
-
- // set dangling inputs to zero
- // according to mode... (e.g. set zero)
- for(; i < inputs; ++i) ZeroSamples(tmpin[i] = vstin[i],n);
-
- inv = tmpin;
- }
-
- const bool more = outputs <= cntout;
- if(more) // more outlets than plug outputs
- outv = const_cast<t_sample **>(outsigs);
- else {
- int i;
- for(i = 0; i < cntout; ++i) tmpout[i] = outsigs[i];
- for(; i < outputs; ++i) tmpout[i] = vstout[i];
-
- outv = tmpout;
- }
-
- // call plugin DSP function
- if(!(plug->*vstfun)(inv,outv,n)) {
- for(int i = 0; i < outputs; ++i)
- ZeroSamples(outsigs[i],n);
- }
-
- if(more) {
- // according to mode set dangling output vectors
-
- // currently simply clear them....
- for(int i = outputs; i < cntout; ++i)
- ZeroSamples(outsigs[i],n);
- }
- }
-}
-
-void vst::mg_progname(int argc,const t_atom *argv) const
-{
- if(plug) {
- int cat,pnum;
- if(argc == 1 && CanbeInt(argv[0])) {
- cat = -1,pnum = GetAInt(argv[0]);
- }
- else if(argc == 2 && CanbeInt(argv[0]) && CanbeInt(argv[1])) {
- cat = GetAInt(argv[0]),pnum = GetAInt(argv[1]);
- }
- else pnum = -1;
-
- if(pnum >= 0) {
- char str[256];
- plug->GetProgramName(cat,pnum,str);
-
- t_atom at[3];
- SetInt(at[0],cat);
- SetInt(at[1],pnum);
- SetString(at[2],str);
- ToOutAnything(GetOutAttr(),sym_progname,3,at);
- }
- else
- post("%s - Syntax: %s [category] program",thisName(),GetString(thisTag()));
- }
-}
-
-void vst::ms_wintitle(const AtomList &t)
-{
- if(plug) {
- char txt[256];
- t.Print(txt,sizeof txt);
- plug->SetTitle(txt);
- }
-}
-
- /**
- * display the parameters names and values and some other bits and pieces that
- * may be of use
- */
-
-void vst::m_print(int ac,const t_atom *av)
-{
- if(!plug) return;
-
- int i;
- bool params = false;
- bool header = true;
- bool programs = false;
- bool parameters = true;
- int specific = -1;
- if( ac > 0 ) {
- for( i = 0 ; i < ac ; i++) {
- if(IsString(av[i])) {
- const char *buf = GetString(av[i]);
- if ( strcmp( buf , "-params" ) == 0 ) {
- params = true;
- }
- else if ( strcmp( buf , "-noheader" ) == 0 ) {
- header = false;
- }
- else if ( strcmp( buf , "-programs" ) == 0 ) {
- programs = true;
- parameters = false;
- }
- else if ( strcmp( buf , "-parameters" ) == 0 ) {
- parameters = false;
- }
- else if ( strcmp( buf , "-help" ) == 0 ) {
- post("print options:");
- post("-help \t\tprint this");
- post("-programs \tshow the programs");
- post("-parameters \tshow the parameters");
- post("-params \tshow the parameter display values");
- post("-noheader \tdo not display the header");
- return;
- }
- }
- else if(CanbeInt(av[i])) {
- int p = GetAInt(av[i]);
- if (( p > 0 ) && ( p <= plug->GetNumParams())) {
- specific = p - 1;
- }
- }
- }
- }
-
- if ( header ) {
- post("VST~ plugin: %s ", plug->GetName() );
- post("made by: %s ", plug->GetVendorName() );
- post("parameters %d\naudio: %d in(s)/%d out(s) \nLoaded from library \"%s\".\n",
- plug->GetNumParams(),
- CntInSig(),
- CntOutSig(),
- plug->GetDllName());
-
- post("Flags");
- if ( plug->HasEditor() ) post("Has editor");
- if ( plug->IsReplacing() ) post("Can do replacing");
- }
-
- if ( parameters ) {
- if ( specific == -1) {
- for (i = 0; i < plug->GetNumParams(); i++)
- display_parameter( i , params );
- }
- else
- display_parameter( specific , params);
- }
-
- if( programs ) {
- for( int j = 0; j < plug->GetNumCategories() ; j++ ) {
- for( i = 0 ; i < plug->GetNumParams() ; i++ ) {
- char buf[64];
- plug->GetProgramName( j , i , buf );
- post("Program %d: %s ", i , buf );
- }
- }
- }
-}
-
-
-void vst::display_parameter(int param,bool showparams)
-{
- int j = param;
- /* the Steinberg(tm) way... */
- char name[109];
- char display[164];
- float val;
-
-// if(j == 0) post ("Control input/output(s):");
-
- memset (name, 0, sizeof(name));
- memset( display, 0 ,sizeof(display));
- plug->GetParamName( j , name );
-
- if(*name) {
- if (showparams) {
-// plug->DescribeValue( j , display );
- plug->GetParamValue(j,display);
- val = plug->GetParamValue( j );
- post ("parameter[#%d], \"%s\" value=%f (%s) ", j, name, val,display);
- }
- else {
- val = plug->GetParamValue( j );
- post ("parameter[#%d], \"%s\" value=%f ", j, name, val);
- }
- }
-}
-
-void vst::m_pname(int pnum)
-{
- if(!plug || pnum < 0 || pnum >= plug->GetNumParams()) return;
-
- char name[256]; // how many chars needed?
- plug->GetParamName(pnum,name);
-
- t_atom at[2];
- SetInt(at[0],pnum);
- SetString(at[1],name);
- ToOutAnything(GetOutAttr(),sym_pname,2,at);
-}
-
-// set the value of a parameter
-void vst::ms_param(int pnum,float val)
-{
- if(!plug || pnum < 0 || pnum >= plug->GetNumParams()) return;
-
-// float xval = plug->GetParamValue( pnum );
-// if(xval <= 1.0f) // What's that????
- if(true)
- {
- plug->SetParamFloat( pnum, val );
-// if(echoparam) display_parameter(pnum , true );
- }
- else
- FLEXT_ASSERT(false);
-}
-
-void vst::ms_params(int argc,const t_atom *argv)
-{
- if(plug) {
- char str[255]; *str = 0;
- if(argc && CanbeFloat(argv[argc-1]))
- PrintList(argc-1,argv,str,sizeof str);
-
- if(*str) {
- int ix = plug->GetParamIx(str);
- if(ix >= 0)
- ms_param(ix,GetAFloat(argv[argc-1]));
- else
- post("%s %s - Parameter not found",thisName(),GetString(thisTag()),str);
- }
- else
- post("%s - Syntax: %s name value",thisName(),GetString(thisTag()));
- }
-}
-
-void vst::mg_param(int pnum)
-{
- if(!plug || pnum < 0 || pnum >= plug->GetNumParams()) return;
-
- t_atom at[2];
- SetInt(at[0],pnum);
- SetFloat(at[1],plug->GetParamValue(pnum));
- ToOutAnything(GetOutAttr(),sym_param,2,at);
-}
-
-void vst::mg_params(int argc,const t_atom *argv)
-{
- if(plug) {
- char str[255];
- PrintList(argc,argv,str,sizeof str);
-
- if(*str) {
- int ix = plug->GetParamIx(str);
- if(ix >= 0)
- mg_param(ix);
- else
- post("%s %s - Parameter not found",thisName(),GetString(thisTag()),str);
- }
- else
- post("%s - Syntax: %s name value",thisName(),GetString(thisTag()));
- }
-}
-
-void vst::m_ptext(int pnum)
-{
- if(!plug || pnum < 0 || pnum >= plug->GetNumParams()) return;
-
- char display[256]; // how many chars needed?
- memset(display,0,sizeof(display));
- plug->GetParamValue(pnum,display);
-
- t_atom at[2];
- SetInt(at[0],pnum);
- SetString(at[1],display);
- ToOutAnything(GetOutAttr(),sym_ptext,2,at);
-}
-
-void vst::m_ptexts(int argc,const t_atom *argv)
-{
- if(plug) {
- char str[255];
- PrintList(argc,argv,str,sizeof str);
-
- if(*str) {
- int ix = plug->GetParamIx(str);
- if(ix >= 0)
- m_ptext(ix);
- else
- post("%s %s - Parameter not found",thisName(),GetString(thisTag()),str);
- }
- else
- post("%s - Syntax: %s name value",thisName(),GetString(thisTag()));
- }
-}
-
-void vst::m_note(int note,int velocity)
-{
- if(!plug) return;
-
- if(velocity > 0)
- plug->AddNoteOn(note,velocity);
- else
- plug->AddNoteOff(note);
-}
-
-void vst::Respond(const t_symbol *sym,int argc,const t_atom *argv)
-{
- FLEXT_ASSERT(sym);
- ToOutAnything(GetOutAttr(),sym,argc,argv);
-}
diff --git a/externals/grill/vst/src/main.h b/externals/grill/vst/src/main.h
deleted file mode 100644
index c395b63b..00000000
--- a/externals/grill/vst/src/main.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
-vst~ - VST plugin object for PD
-based on the work of Jarno Seppänen and Mark Williamson
-
-Copyright (c)2003-2005 Thomas Grill (gr@grrrr.org)
-For information on usage and redistribution, and for a DISCLAIMER OF ALL
-WARRANTIES, see the file, "license.txt," in this distribution.
-*/
-
-#ifndef __VST_H
-#define __VST_H
-
-#define FLEXT_ATTRIBUTES 1
-
-#include <flext.h>
-
-#if !defined(FLEXT_VERSION) || (FLEXT_VERSION < 500)
-#error You need at least flext version 0.5.0
-#endif
-
-#if FLEXT_OS == FLEXT_OS_WIN || FLEXT_OS == FLEXT_OS_MAC
-//
-#else
-#error Platform not supported!
-#endif
-
-#endif
-
diff --git a/externals/grill/vst/src/vst.rc b/externals/grill/vst/src/vst.rc
deleted file mode 100644
index 8f8e368b..00000000
--- a/externals/grill/vst/src/vst.rc
+++ /dev/null
@@ -1,135 +0,0 @@
-// Microsoft Visual C++ generated resource script.
-//
-#include "resource.h"
-
-#define APSTUDIO_READONLY_SYMBOLS
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 2 resource.
-//
-#include "afxres.h"
-
-/////////////////////////////////////////////////////////////////////////////
-#undef APSTUDIO_READONLY_SYMBOLS
-
-/////////////////////////////////////////////////////////////////////////////
-// Englisch (USA) resources
-
-#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
-#ifdef _WIN32
-LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
-#pragma code_page(1252)
-#endif //_WIN32
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Version
-//
-
-VS_VERSION_INFO VERSIONINFO
- FILEVERSION 1,0,0,1
- PRODUCTVERSION 1,0,0,1
- FILEFLAGSMASK 0x3fL
-#ifdef _DEBUG
- FILEFLAGS 0x1L
-#else
- FILEFLAGS 0x0L
-#endif
- FILEOS 0x4L
- FILETYPE 0x2L
- FILESUBTYPE 0x0L
-BEGIN
- BLOCK "StringFileInfo"
- BEGIN
- BLOCK "040904b0"
- BEGIN
- VALUE "FileDescription", "vst~ external"
- VALUE "FileVersion", "0,1, 0, 8"
- VALUE "InternalName", "vst~"
- VALUE "LegalCopyright", "Copyright (C) 2003-2005 Thomas Grill"
- VALUE "OriginalFilename", "vst~.DLL"
- VALUE "ProductName", "VST plugin object"
- VALUE "ProductVersion", "0, 1, 0, 8"
- END
- END
- BLOCK "VarFileInfo"
- BEGIN
- VALUE "Translation", 0x409, 1200
- END
-END
-
-#endif // Englisch (USA) resources
-/////////////////////////////////////////////////////////////////////////////
-
-
-/////////////////////////////////////////////////////////////////////////////
-// Deutsch (Österreich) resources
-
-#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEA)
-#ifdef _WIN32
-LANGUAGE LANG_GERMAN, SUBLANG_GERMAN_AUSTRIAN
-#pragma code_page(1252)
-#endif //_WIN32
-
-#ifdef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// TEXTINCLUDE
-//
-
-1 TEXTINCLUDE
-BEGIN
- "resource.h\0"
-END
-
-2 TEXTINCLUDE
-BEGIN
- "#include ""afxres.h""\r\n"
- "\0"
-END
-
-3 TEXTINCLUDE
-BEGIN
- "#define _AFX_NO_SPLITTER_RESOURCES\r\n"
- "#define _AFX_NO_OLE_RESOURCES\r\n"
- "#define _AFX_NO_TRACKER_RESOURCES\r\n"
- "#define _AFX_NO_PROPERTY_RESOURCES\r\n"
- "\r\n"
- "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n"
- "#ifdef _WIN32\r\n"
- "LANGUAGE 9, 1\r\n"
- "#pragma code_page(1252)\r\n"
- "#endif //_WIN32\r\n"
- "#include ""afxres.rc"" // Standard components\r\n"
- "#endif\r\n"
- "\0"
-END
-
-#endif // APSTUDIO_INVOKED
-
-#endif // Deutsch (Österreich) resources
-/////////////////////////////////////////////////////////////////////////////
-
-
-
-#ifndef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 3 resource.
-//
-#define _AFX_NO_SPLITTER_RESOURCES
-#define _AFX_NO_OLE_RESOURCES
-#define _AFX_NO_TRACKER_RESOURCES
-#define _AFX_NO_PROPERTY_RESOURCES
-
-#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
-#ifdef _WIN32
-LANGUAGE 9, 1
-#pragma code_page(1252)
-#endif //_WIN32
-#include "afxres.rc" // Standard components
-#endif
-
-/////////////////////////////////////////////////////////////////////////////
-#endif // not APSTUDIO_INVOKED
-
diff --git a/externals/grill/vst/src/vstedit.cpp b/externals/grill/vst/src/vstedit.cpp
deleted file mode 100644
index 1536b9d3..00000000
--- a/externals/grill/vst/src/vstedit.cpp
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
-vst~ - VST plugin object for PD
-based on the work of Jarno Seppänen and Mark Williamson
-
-Copyright (c)2003-2005 Thomas Grill (gr@grrrr.org)
-For information on usage and redistribution, and for a DISCLAIMER OF ALL
-WARRANTIES, see the file, "license.txt," in this distribution.
-*/
-
-#include "vsthost.h"
-#include "editor.h"
-
-
-void VSTPlugin::Edit(bool open)
-{
- if(Is()) {
- if(open) {
- if(HasEditor() && !IsEdited())
- StartEditor(this);
- }
- else if(IsEdited())
- StopEditor(this);
- }
-}
-
-void VSTPlugin::StartEditing(WHandle h)
-{
- FLEXT_ASSERT(h != NULL);
- Dispatch(effEditOpen,0,0,hwnd = h);
-
- TitleEditor(this,title.c_str());
-}
-
-void VSTPlugin::StopEditing()
-{
- if(Is() && IsEdited())
- Dispatch(effEditClose);
-}
-
-void VSTPlugin::Visible(bool vis,bool upd)
-{
- visible = vis;
- if(upd && Is() && IsEdited()) ShowEditor(this,vis);
-}
-
-void VSTPlugin::SetPos(int x,int y,bool upd)
-{
- posx = x; posy = y;
- if(upd && Is() && IsEdited()) MoveEditor(this,posx,posy);
-}
-
-void VSTPlugin::SetSize(int x,int y,bool upd)
-{
- sizex = x; sizey = y;
- if(upd && Is() && IsEdited()) SizeEditor(this,sizex,sizey);
-}
-
-void VSTPlugin::SetCaption(bool c)
-{
- caption = c;
- if(Is() && IsEdited()) CaptionEditor(this,c);
-}
-
-void VSTPlugin::SetHandle(bool h)
-{
- handle = h;
- if(Is() && IsEdited()) HandleEditor(this,h);
-}
-
-void VSTPlugin::SetTitle(const char *t)
-{
- title = t;
- if(Is() && IsEdited()) TitleEditor(this,t);
-}
-
-void VSTPlugin::ToFront()
-{
- if(Is() && IsEdited()) {
- FrontEditor(this);
- Dispatch(effEditTop,0,0,vendorname);
- }
-}
diff --git a/externals/grill/vst/src/vsthost.cpp b/externals/grill/vst/src/vsthost.cpp
deleted file mode 100644
index 3fd1a935..00000000
--- a/externals/grill/vst/src/vsthost.cpp
+++ /dev/null
@@ -1,461 +0,0 @@
-/*
-vst~ - VST plugin object for PD
-based on the work of Jarno Seppänen and Mark Williamson
-
-Copyright (c)2003-2005 Thomas Grill (gr@grrrr.org)
-For information on usage and redistribution, and for a DISCLAIMER OF ALL
-WARRANTIES, see the file, "license.txt," in this distribution.
-*/
-
-#include "vsthost.h"
-#include "editor.h"
-#include <exception>
-#include "flcontainers.h"
-
-const t_symbol
- *VSTPlugin::sym_param,
- *VSTPlugin::sym_event,
- *VSTPlugin::sym_evmidi,
- *VSTPlugin::sym_evaudio,
- *VSTPlugin::sym_evvideo,
- *VSTPlugin::sym_evparam,
- *VSTPlugin::sym_evtrigger,
- *VSTPlugin::sym_evsysex,
- *VSTPlugin::sym_ev_,
- *VSTPlugin::sym_midi[8];
-
-
-class DelPlugin
- : public Fifo::Cell
-{
-public:
- DelPlugin(VSTPlugin *p): plug(p) {}
- VSTPlugin *plug;
-};
-
-static TypedLifo<DelPlugin> todel;
-flext::ThrCond VSTPlugin::thrcond;
-
-void VSTPlugin::Setup()
-{
- LaunchThread(worker);
-
- sym_param = flext::MakeSymbol("param");
- sym_event = flext::MakeSymbol("event");
- sym_evmidi = flext::MakeSymbol("midi");
- sym_evaudio = flext::MakeSymbol("audio");
- sym_evvideo = flext::MakeSymbol("video");
- sym_evparam = flext::MakeSymbol("param");
- sym_evtrigger = flext::MakeSymbol("trigger");
- sym_evsysex = flext::MakeSymbol("sysex");
- sym_ev_ = flext::MakeSymbol("???");
-
- sym_midi[0] = flext::MakeSymbol("noteoff");
- sym_midi[1] = flext::MakeSymbol("note");
- sym_midi[2] = flext::MakeSymbol("atouch");
- sym_midi[3] = flext::MakeSymbol("ctlchg");
- sym_midi[4] = flext::MakeSymbol("progchg");
- sym_midi[5] = flext::MakeSymbol("atouch");
- sym_midi[6] = flext::MakeSymbol("pbend");
- sym_midi[7] = flext::MakeSymbol("sysex");
-}
-
-VSTPlugin::VSTPlugin(Responder *resp)
- : effect(NULL),pluginmain(NULL),audiomaster(NULL)
-#if FLEXT_OS == FLEXT_OS_WIN
- , hdll(NULL)
-#endif
- , hwnd(NULL)
- , responder(resp)
- , posx(0),posy(0),sizex(0),sizey(0)
- , visible(true),caption(true),handle(false)
- , midichannel(0),eventqusz(0),dumpevents(false)
- , paramnamecnt(0)
- , transchg(true)
- , playing(false),looping(false),feedback(false)
- , samplerate(0)
- , samplepos(0),ppqpos(0)
- , tempo(120)
- , timesignom(4),timesigden(4)
- , barstartpos(0)
- , cyclestartpos(0),cycleendpos(0)
- , smpteoffset(0),smpterate(0)
-{}
-
-VSTPlugin::~VSTPlugin()
-{
- Free();
-}
-
-VSTPlugin *VSTPlugin::New(Responder *resp)
-{
- FLEXT_ASSERT(resp);
- return new VSTPlugin(resp);
-}
-
-void VSTPlugin::Delete(VSTPlugin *p)
-{
- FLEXT_ASSERT(p);
-
- // tell plugin to close editor!
- StopEditor(p);
- // transfer to deletion thread
- todel.Push(new DelPlugin(p));
- thrcond.Signal();
-}
-
-void VSTPlugin::worker(thr_params *)
-{
- TypedLifo<DelPlugin> tmp;
- bool again = false;
- for(;;) {
- // wait for signal
- if(again) {
- thrcond.TimedWait(0.01);
- again = false;
- }
- else
- thrcond.Wait();
-
- DelPlugin *p;
- while((p = todel.Pop()) != NULL) {
- // see if editing has stopped
- if(p && p->plug->hwnd == NULL) {
- // yes, it is now safe to delete the plug
- post("DELETE %s",p->plug->dllname.c_str());
- delete p->plug;
- delete p;
- }
- else {
- tmp.Push(p);
- again = true;
- }
- }
-
- // put back remaining entries
- while((p = tmp.Pop()) != NULL) todel.Push(p);
- }
-}
-
-#if FLEXT_OS == FLEXT_OS_MAC
-OSStatus FSPathMakeFSSpec(const UInt8 *path,FSSpec *spec,Boolean *isDirectory) /* can be NULL */
-{
- OSStatus result;
- FSRef ref;
-
- /* check parameters */
- require_action(NULL != spec, BadParameter, result = paramErr);
-
- /* convert the POSIX path to an FSRef */
- result = FSPathMakeRef(path, &ref, isDirectory);
- require_noerr(result, FSPathMakeRef);
-
- /* and then convert the FSRef to an FSSpec */
- result = FSGetCatalogInfo(&ref, kFSCatInfoNone, NULL, NULL, spec, NULL);
- require_noerr(result, FSGetCatalogInfo);
-
-FSGetCatalogInfo:
-FSPathMakeRef:
-BadParameter:
- return result;
-}
-#endif
-
-// hdll, pluginmain and audiomaster are set here
-// must be NULL beforehand!
-bool VSTPlugin::NewPlugin(const char *plugname)
-{
- FLEXT_ASSERT(!pluginmain && !audiomaster);
-
- dllname = plugname;
-
-#if FLEXT_OS == FLEXT_OS_WIN
- hdll = LoadLibraryEx(dllname.c_str(),NULL,0 /*DONT_RESOLVE_DLL_REFERENCES*/);
-/*
- char buf[255],*c;
- strcpy(buf,dllname.c_str());
- for(c = buf; *c; ++c)
- if(*c == '/')
- *c = '\\';
- char *sl = strrchr(buf,'\\');
- if(sl) *sl = 0;
- SetCurrentDirectory(buf);
- hdll = LoadLibrary(dllname.c_str());
-*/
- if(hdll) pluginmain = (PVSTMAIN)GetProcAddress(hdll,"main");
- audiomaster = Master;
-
-#elif FLEXT_OS == FLEXT_OS_MAC
- short resFileID;
- FSSpec spec;
- OSErr err;
-
- err = FSPathMakeFSSpec(dllname.c_str(),&spec,NULL);
- resFileID = FSpOpenResFile(&spec, fsRdPerm);
- short cResCB = Count1Resources('aEff');
-
- for(int i = 0; i < cResCB; i++) {
- Handle codeH;
- CFragConnectionID connID;
- Ptr mainAddr;
- Str255 errName;
- Str255 fragName;
- char fragNameCStr[256];
- short resID;
- OSType resType;
-
- codeH = Get1IndResource('aEff', short(i+1));
- if(!codeH) continue;
-
- GetResInfo(codeH, &resID, &resType, fragName);
- DetachResource(codeH);
- HLock(codeH);
-
- err = GetMemFragment(*codeH,
- GetHandleSize(codeH),
- fragName,
- kPrivateCFragCopy,
- &connID, (Ptr *) & mainAddr, errName);
-
- if(!err) {
- #ifdef __CFM__
- pluginmain = (PVSTMAIN)NewMachOFromCFM(mainAddr);
- #else
- pluginmain = (PVSTMAIN)mainAddr;
- #endif
- }
- }
- CloseResFile(resFileID);
-
- audiomaster =
-#ifdef __CFM__
- NewCFMFromMachO(Master);
-#else
- Master;
-#endif
-
-#else
-#error Platform not supported
-#endif
-
- if(pluginmain && audiomaster)
- return true;
- else {
- FreePlugin();
- return false;
- }
-}
-
-void VSTPlugin::FreePlugin()
-{
-#if FLEXT_OS == FLEXT_OS_WIN
- if(hdll) { FreeLibrary(hdll); hdll = NULL; }
-#elif FLEXT_OS == FLEXT_OS_MAC
-
-#ifdef __MACOSX__
-#ifdef __CFM__
- if(audiomaster) DisposeCFMFromMachO(audiomaster);
- if(pluginmain) DisposeMachOFromCFM(pluginmain);
-#endif
-#endif
-
-#else
-#error Platform not supported
-#endif
-
- effect = NULL;
- audiomaster = NULL;
- pluginmain = NULL;
-}
-
-/*
-This is static to be able to communicate between the plugin methods
-and the static Audiomaster function
-the this (plugin->user) pointer has not been initialized at the point it is needed
-static should not be a problem, as we are single-threaded and it is immediately
-queried in a called function
-*/
-long VSTPlugin::uniqueid = 0;
-
-std::string VSTPlugin::dllloading;
-
-bool VSTPlugin::InstPlugin(long plugid)
-{
- uniqueid = plugid;
- dllloading = dllname;
-
- FLEXT_ASSERT(pluginmain && audiomaster);
-
- //This calls the "main" function and receives the pointer to the AEffect structure.
- try { effect = pluginmain(audiomaster); }
- catch(std::exception &e) {
- flext::post("vst~ - caught exception while instantiating plugin: %s",e.what());
- }
- catch(...) {
- flext::post("vst~ - caught exception while instantiating plugin");
- }
-
- if(!effect)
- return false;
- else if(effect->magic != kEffectMagic) {
- effect = NULL;
- return false;
- }
- return true;
-}
-
-bool VSTPlugin::Instance(const char *name,const char *subname)
-{
- bool ok = false;
- FLEXT_ASSERT(effect == NULL);
-
- try {
-
-/*
- if(!ok && dllname != name) {
- FreePlugin();
- // freshly load plugin
- ok = NewPlugin(name) && InstPlugin();
- }
-*/
- ok = NewPlugin(name) && InstPlugin();
-
- if(ok && subname && *subname && Dispatch(effGetPlugCategory) == kPlugCategShell) {
- // sub plugin-name given -> scan plugs
-
- long plugid;
- char tmp[64];
-
- // Waves5 continues with the next plug after the last loaded
- // that's not what we want - workaround: swallow all remaining
- while((plugid = Dispatch(effShellGetNextPlugin,0,0,tmp))) {}
-
- // restart from the beginning
- while((plugid = Dispatch(effShellGetNextPlugin,0,0,tmp))) {
- // subplug needs a name
- FLEXT_LOG1("subplug %s",tmp);
- if(!strcmp(subname,tmp))
- // found
- break;
- }
-
- // re-init with plugid set
- if(plugid) ok = InstPlugin(plugid);
- }
-
- if(ok) {
- //init plugin
- effect->user = this;
- ok = Dispatch(effOpen) == 0;
- }
-
- if(ok) {
- ok = Dispatch(effIdentify) == 'NvEf';
- }
-
- if(ok) {
- *productname = 0;
- long ret = Dispatch(effGetProductString,0,0,productname);
-
- if(!*productname) {
- // no product name given by plugin -> extract it from the filename
-
- std::string str1(dllname);
- std::string::size_type slpos = str1.rfind('\\');
- if(slpos == std::string::npos) {
- slpos = str1.rfind('/');
- if(slpos == std::string::npos)
- slpos = 0;
- else
- ++slpos;
- }
- else
- ++slpos;
- std::string str2 = str1.substr(slpos);
- int snip = str2.find('.');
- if( snip != std::string::npos )
- str1 = str2.substr(0,snip);
- else
- str1 = str2;
- strcpy(productname,str1.c_str());
- }
-
- if(*productname) {
- char tmp[512];
- sprintf(tmp,"vst~ - %s",productname);
- title = tmp;
- }
- else
- title = "vst~";
-
- *vendorname = 0;
- Dispatch(effGetVendorString,0,0,vendorname);
- }
-
- }
- catch(std::exception &e) {
- flext::post("vst~ - caught exception while loading plugin: %s",e.what());
- ok = false;
- }
- catch(...) {
- flext::post("vst~ - Caught exception while loading plugin");
- ok = false;
- }
-
- if(!ok) Free();
- return ok;
-}
-
-void VSTPlugin::Free()
-{
- // This should only also in destruction
-
- try {
- if(effect) {
- FLEXT_ASSERT(!IsEdited());
-
- // shut down plugin
- Dispatch(effMainsChanged, 0, 0);
- Dispatch(effClose);
- }
- }
- catch(...) {}
-
- FreePlugin();
-}
-
-void VSTPlugin::DspInit(float sr,int blsz)
-{
- try {
- // sample rate and block size must _first_ be set
- Dispatch(effSetSampleRate,0,0,NULL,samplerate = sr);
- Dispatch(effSetBlockSize, 0,blsz);
- // then signal that mains have changed!
- Dispatch(effMainsChanged,0,1);
- }
- catch(std::exception &e) {
- flext::post("vst~ - caught exception while initializing dsp: %s",e.what());
- }
- catch(...) {
- flext::post("vst~ - caught exception while initializing dsp");
- }
-}
-
-void VSTPlugin::ListPlugs(const t_symbol *sym) const
-{
- if(responder) {
- if(Is() && Dispatch(effGetPlugCategory) == kPlugCategShell) {
- t_atom at;
- // sub plugin-name given -> scan plugs
- char tmp[64];
- // scan shell for subplugins
- while(Dispatch(effShellGetNextPlugin,0,0,tmp)) {
- SetString(at,tmp);
- responder->Respond(sym,1,&at);
- }
- }
-
- // bang
- responder->Respond(sym);
- }
-}
diff --git a/externals/grill/vst/src/vsthost.h b/externals/grill/vst/src/vsthost.h
deleted file mode 100644
index 00225b62..00000000
--- a/externals/grill/vst/src/vsthost.h
+++ /dev/null
@@ -1,357 +0,0 @@
-/*
-vst~ - VST plugin object for PD
-based on the work of Jarno Seppänen and Mark Williamson
-
-Copyright (c)2003-2005 Thomas Grill (gr@grrrr.org)
-For information on usage and redistribution, and for a DISCLAIMER OF ALL
-WARRANTIES, see the file, "license.txt," in this distribution.
-*/
-
-#ifndef __VSTHOST_H
-#define __VSTHOST_H
-
-#include <flext.h>
-#include <string>
-#include <map>
-#include <math.h>
-
-#include "AEffectx.h"
-#include "AEffEditor.hpp"
-
-
-#if FLEXT_OS == FLEXT_OS_WIN
-#include <windows.h>
-typedef HWND WHandle;
-typedef HMODULE MHandle;
-#elif FLEXT_OS == FLEXT_OS_MAC
-#include <CoreServices/CoreServices.h>
-typedef Handle WHandle;
-typedef void *MHandle;
-#else
-#error Platform not supported!
-#endif
-
-
-#define MIDI_MAX_EVENTS 64
-
-class Responder
-{
-public:
- virtual void Respond(const t_symbol *sym,int argc = 0,const t_atom *argv = NULL) = 0;
-};
-
-
-class VSTPlugin:
- public flext
-{
-public:
- static VSTPlugin *New(Responder *resp);
- static void Delete(VSTPlugin *p);
-
- static void Setup();
-
- bool Instance(const char *plug,const char *subplug = NULL);
- void DspInit(float samplerate,int blocksize);
-
-private:
- VSTPlugin(Responder *resp);
- ~VSTPlugin();
-
- static ThrCond thrcond;
- static void worker(thr_params *p);
-
- void Free();
-
- //////////////////////////////////////////////////////////////////////////////
-
-public:
- bool Is() const { return effect != NULL; }
-
- long GetVersion() const { return effect->version; }
-
- bool IsSynth() const { return HasFlags(effFlagsIsSynth); }
- bool IsReplacing() const { return HasFlags(effFlagsCanReplacing); }
- bool HasEditor() const { return HasFlags(effFlagsHasEditor); }
-
- const char *GetName() const { return productname; }
- const char *GetVendorName() const { return vendorname; }
- const char *GetDllName() const { return dllname.c_str(); }
-
- long UniqueID() const { return effect->uniqueID; }
-
- int GetNumInputs() const { return effect->numInputs; }
- int GetNumOutputs() const { return effect->numOutputs; }
-
- void ListPlugs(const t_symbol *sym) const;
-
-private:
- char productname[300];
- char vendorname[300];
- std::string dllname; // Contains dll name
-
- //////////////////////////////////////////////////////////////////////////////
-
-public:
- int GetNumParams() const { return effect?effect->numParams:0; }
- void GetParamName(int numparam,char *name) const;
- void GetParamValue(int numparam,char *parval) const;
- float GetParamValue(int numparam) const;
-
- // scan plugin names (can take a _long_ time!!)
- void ScanParams(int i = -1);
- // get number of scanned parameters
- int ScannedParams() const { return paramnamecnt; }
- // get index of named (scanned) parameter... -1 if not found
- int GetParamIx(const char *p) const;
-
- bool SetParamFloat(int parameter, float value);
- bool SetParamInt(int parameter, int value) { return SetParamFloat(parameter,value/65535.0f); }
-
- void SetCurrentProgram(int prg) { Dispatch(effSetProgram,0,prg); }
- int GetCurrentProgram() const { return Dispatch(effGetProgram); }
- int GetNumPrograms() const { return effect->numPrograms; }
-
- int GetNumCategories() const { return Dispatch(effGetNumProgramCategories); }
- bool GetProgramName(int cat,int p,char* buf) const;
-
-private:
- struct NameCmp:
- std::less<std::string>
- {
- bool operator()(const std::string &a,const std::string &b) const { return a.compare(b) < 0; }
- };
-
- typedef std::map<std::string,int,NameCmp> NameMap;
- int paramnamecnt;
- NameMap paramnames;
-
- //////////////////////////////////////////////////////////////////////////////
-
-public:
- void SetPos(int x,int y,bool upd = true);
- void SetSize(int x,int y,bool upd = true);
- void SetX(int x,bool upd = true) { SetPos(x,posy,upd); }
- void SetY(int y,bool upd = true) { SetPos(posx,y,upd); }
- void SetW(int x,bool upd = true) { SetSize(x,sizey,upd); }
- void SetH(int y,bool upd = true) { SetSize(sizex,y,upd); }
- int GetX() const { return posx; }
- int GetY() const { return posy; }
- int GetW() const { return sizex; }
- int GetH() const { return sizey; }
- void SetCaption(bool b);
- bool GetCaption() const { return caption; }
- void SetHandle(bool h);
- bool GetHandle() const { return handle; }
- void SetTitle(const char *t);
- const char *GetTitle() const { return title.c_str(); }
-
- void ToFront();
-
- void Edit(bool open);
-
- void StartEditing(WHandle h);
- void StopEditing();
- bool IsEdited() const { return hwnd != NULL; }
- WHandle EditorHandle() const { return hwnd; }
- void EditingEnded() { hwnd = NULL; thrcond.Signal(); }
-
- void GetEditorRect(ERect &er) const { ERect *r; Dispatch(effEditGetRect,0,0,&r); er = *r; }
- void EditorIdle() { Dispatch(effEditIdle); }
-
- void Visible(bool vis,bool upd = true);
- bool IsVisible() const { return visible; }
-
- void Paint(ERect &r) const { Dispatch(effEditDraw,0,0,&r); }
-
-private:
- bool visible;
- int posx,posy,sizex,sizey; // Window position
- bool caption; // Window border
- bool handle; // Window handle (like taskbar button)
- std::string title; // Window title
-
- //////////////////////////////////////////////////////////////////////////////
-
-public:
- enum {
- MIDI_NOTEOFF = 0x80,
- MIDI_NOTEON = 0x90,
- MIDI_POLYAFTERTOUCH = 0xa0,
- MIDI_CONTROLCHANGE = 0xb0,
- MIDI_PROGRAMCHANGE = 0xc0,
- MIDI_AFTERTOUCH = 0xd0,
- MIDI_PITCHBEND = 0xe0,
- MIDI_SYSEX = 0xf0,
- };
-
- void SetEvents(bool ev) { dumpevents = ev; }
- bool GetEvents() const { return dumpevents; }
-
- bool AddMIDI(unsigned char data0,unsigned char data1 = 0,unsigned char data2 = 0);
-
- static int range(int value,int mn = 0,int mx = 127) { return value < mn?mn:(value > mx?mx:value); }
-
- void SetChannel(int channel) { midichannel = range(channel,0,0xf); }
- int GetChannel() const { return midichannel; }
-
- bool AddNoteOn(unsigned char note,unsigned char speed /*,unsigned char midichannel = 0*/)
- {
- return AddMIDI(MIDI_NOTEON+midichannel,note,speed);
- }
-
- bool AddNoteOff(unsigned char note /*,unsigned char midichannel = 0*/)
- {
- return AddMIDI(MIDI_NOTEOFF+midichannel,note,0);
- }
-
- void AddControlChange(int control,int value)
- {
- AddMIDI(MIDI_CONTROLCHANGE+midichannel,range(control),range(value));
- }
-
- void AddProgramChange(int value)
- {
- AddMIDI(MIDI_PROGRAMCHANGE+midichannel,range(value),0);
- }
-
- void AddPitchBend(int value)
- {
- AddMIDI(MIDI_PITCHBEND+midichannel,(value&127),((value>>7)&127));
- }
-
- void AddAftertouch(int value)
- {
- AddMIDI(MIDI_AFTERTOUCH+midichannel,range(value));
- }
-
- void AddPolyAftertouch(unsigned char note,int value)
- {
- AddMIDI(MIDI_POLYAFTERTOUCH+midichannel,note,range(value));
- }
-
-private:
- void SendMidi();
-
- // static VstTimeInfo _timeInfo;
- VstMidiEvent midievent[MIDI_MAX_EVENTS];
- VstEvents events;
- int eventqusz;
-
- char midichannel;
- bool dumpevents;
-
- //////////////////////////////////////////////////////////////////////////////
-
-public:
-
- void SetPlaying(bool p) { if(playing != p) transchg = true,playing = p; }
- bool GetPlaying() const { return playing; }
- void SetLooping(bool p) { if(looping != p) transchg = true,looping = p; }
- bool GetLooping() const { return looping; }
- void SetFeedback(bool p) { feedback = p; }
- bool GetFeedback() const { return feedback; }
-
- void SetSamplePos(double p) { if(samplepos != p) transchg = true,samplepos = p; }
- double GetSamplePos() const { return samplepos; }
- void SetTempo(double p) { if(tempo != p) transchg = true,tempo = p; }
- double GetTempo() const { return tempo; }
- void SetPPQPos(double p) { if(ppqpos != p) transchg = true,ppqpos = p; }
- double GetPPQPos() const { return ppqpos; }
-
- void SetTimesigNom(int p) { if(timesignom != p) transchg = true,timesignom = p; }
- int GetTimesigNom() const { return timesignom; }
- void SetTimesigDen(int p) { if(timesigden != p) transchg = true,timesigden = p; }
- int GetTimesigDen() const { return timesigden; }
- void SetBarStart(double p) { if(barstartpos != p) transchg = true,barstartpos = p; }
- double GetBarStart() const { return barstartpos; }
- void SetCycleStart(double p) { if(cyclestartpos != p) transchg = true,cyclestartpos = p; }
- double GetCycleStart() const { return cyclestartpos; }
- void SetCycleEnd(double p) { if(cycleendpos != p) transchg = true,cycleendpos = p; }
- double GetCycleEnd() const { return cycleendpos; }
-
- void SetSmpteOffset(int p) { if(smpteoffset != p) transchg = true,smpteoffset = p; }
- int GetSmpteOffset() const { return smpteoffset; }
- void SetSmpteRate(int p) { if(smpterate != p) transchg = true,smpterate = p; }
- int GetSmpteRate() const { return smpterate; }
-
-private:
-
- bool playing,looping,feedback;
- float samplerate;
- bool transchg;
-
- double samplepos,tempo;
- double ppqpos;
-
- int timesignom,timesigden;
- double barstartpos;
- double cyclestartpos,cycleendpos;
- int smpteoffset,smpterate;
-
- //////////////////////////////////////////////////////////////////////////////
-
-public:
- bool processReplacing(float **inputs,float **outputs,long sampleframes )
- {
- FLEXT_ASSERT(effect);
- effect->processReplacing(effect,inputs,outputs,sampleframes);
- if(playing) updatepos(sampleframes);
- return true;
- }
-
- bool process(float **inputs,float **outputs,long sampleframes )
- {
- FLEXT_ASSERT(effect);
- effect->process(effect,inputs,outputs,sampleframes);
- return true;
- }
-
-private:
-
- void updatepos(long frames);
-
- //////////////////////////////////////////////////////////////////////////////
-
-private:
- Responder *responder;
-
- bool NewPlugin(const char *plugname);
- void FreePlugin();
- bool InstPlugin(long plugid = 0);
-
- static long uniqueid;
- static std::string dllloading;
-
- inline long GetFlags() const { return effect?effect->flags:0; }
- inline bool HasFlags(long msk) const { return effect && (effect->flags&msk); }
-
-
-#if FLEXT_OS == FLEXT_OS_WIN
- // the handle to the shared library
- MHandle hdll;
-#endif
- // the handle to the plugin editor window
- WHandle hwnd;
- // the VST plugin instance
- AEffect *effect;
-
- typedef AEffect *(VSTCALLBACK *PVSTMAIN)(audioMasterCallback audioMaster);
- PVSTMAIN pluginmain;
- audioMasterCallback audiomaster;
-
- long Dispatch(long opCode,long index = 0,long value = 0,void *ptr = NULL,float opt = 0) const
- {
- FLEXT_ASSERT(effect);
- return effect->dispatcher(effect,opCode,index,value,ptr,opt);
- }
-
- static long VSTCALLBACK Master(AEffect *effect, long opcode, long index, long value, void *ptr, float opt);
-
- static const t_symbol *sym_param;
- static const t_symbol *sym_event,*sym_evmidi,*sym_evaudio,*sym_evvideo,*sym_evparam,*sym_evtrigger,*sym_evsysex,*sym_ev_;
- static const t_symbol *sym_midi[8];
-
- void ProcessEvent(const VstEvent &ev);
-};
-
-#endif
diff --git a/externals/grill/vst/src/vstmaster.cpp b/externals/grill/vst/src/vstmaster.cpp
deleted file mode 100644
index 6730a647..00000000
--- a/externals/grill/vst/src/vstmaster.cpp
+++ /dev/null
@@ -1,282 +0,0 @@
-/*
-vst~ - VST plugin object for PD
-based on the work of Jarno Seppänen and Mark Williamson
-
-Copyright (c)2003-2005 Thomas Grill (gr@grrrr.org)
-For information on usage and redistribution, and for a DISCLAIMER OF ALL
-WARRANTIES, see the file, "license.txt," in this distribution.
-*/
-
-#include "vsthost.h"
-
-static const int VST_VERSION = 100;
-static const char *vendor = "grrrr.org";
-static const char *product = "vst~";
-
-
-void VSTPlugin::ProcessEvent(const VstEvent &ev)
-{
- if(!responder && dumpevents) return;
-
- if(ev.type == kVstMidiType) {
- const VstMidiEvent &mev = (const VstMidiEvent &)ev;
- t_atom lst[10];
- SetSymbol(lst[0],sym_evmidi);
- int midi = ((unsigned char)mev.midiData[0]>>4)-8;
- FLEXT_ASSERT(midi >= 0 && midi < 8);
- SetSymbol(lst[1],sym_midi[midi]);
- SetInt(lst[2],(unsigned char)mev.midiData[0]&0x0f);
- SetInt(lst[3],(unsigned char)mev.midiData[1]);
- SetInt(lst[4],(unsigned char)mev.midiData[2]);
- // what about running status? (obviously not possible)
- SetInt(lst[5],mev.deltaFrames);
- SetInt(lst[6],mev.noteLength);
- SetInt(lst[7],mev.noteOffset);
- SetInt(lst[8],(int)mev.detune);
- SetInt(lst[9],(int)mev.noteOffVelocity);
- responder->Respond(sym_event,9,lst);
- }
- else {
- const t_symbol *sym;
- if(ev.type == kVstAudioType)
- sym = sym_evaudio;
- else if(ev.type == kVstVideoType)
- sym = sym_evvideo;
- else if(ev.type == kVstParameterType)
- sym = sym_evparam;
- else if(ev.type == kVstTriggerType)
- sym = sym_evtrigger;
- else if(ev.type == kVstSysExType)
- sym = sym_evsysex;
- else
- sym = sym_ev_;
-
- int data = ev.byteSize-sizeof(ev.deltaFrames)-sizeof(ev.flags);
- const int stsize = 16;
- t_atom stlst[stsize];
- t_atom *lst = data+3 > stsize?new t_atom[data+3]:stlst;
-
- SetSymbol(lst[0],sym);
- SetInt(lst[1],ev.deltaFrames);
- SetInt(lst[2],ev.flags);
- for(int i = 0; i < data; ++i) SetInt(lst[3],(unsigned char)ev.data[i]);
-
- responder->Respond(sym_event,data+3,lst);
-
- if(lst != stlst) delete[] lst;
- }
-}
-
-// Host callback dispatcher
-long VSTPlugin::Master(AEffect *effect, long opcode, long index, long value, void *ptr, float opt)
-{
- if(opcode != audioMasterGetTime)
- FLEXT_LOG6("VST -> host: Eff = 0x%.8X, Opcode = %d, Index = %d, Value = %d, PTR = %.8X, OPT = %.3f\n",(int)effect, opcode,index,value,(int)ptr,opt);
-
- VSTPlugin *th = effect?(VSTPlugin *)effect->user:NULL;
-
- switch (opcode) {
- case audioMasterAutomate: // 0
- if(th && th->feedback && th->responder) {
- t_atom lst[2];
- SetInt(lst[0],index);
- SetFloat(lst[1],opt);
- th->responder->Respond(sym_param,2,lst);
- }
- return 0;
-
- case audioMasterVersion: // 1
- // support VST 2.3
- return 2300;
-
- case audioMasterCurrentId: // 2
- // set to subplugin id (default 0)
- return uniqueid;
-
- case audioMasterIdle: // 3
- effect->dispatcher(effect, effEditIdle, 0, 0, NULL, 0.0f);
- return 0;
-
- case audioMasterPinConnected: // 4
- //! \todo set connection state correctly (if possible..)
- // index=pin, value=0..input, else..output
- FLEXT_LOG2("Pin connected pin=%li conn=%li",index,value);
- return 0; // 0 means connected
-
- case audioMasterWantMidi: // 6
- FLEXT_LOG1("Want MIDI = %li",value);
- return 0; // VST header says: "currently ignored"
-
- case audioMasterGetTime: { // 7
- if(!th) return 0;
-
- static VstTimeInfo time;
- memset(&time,0,sizeof(time));
-
- // flags
- time.flags = kVstTempoValid|kVstBarsValid|kVstCyclePosValid|kVstPpqPosValid|kVstSmpteValid|kVstTimeSigValid;
-
- if(th->transchg) { time.flags |= kVstTransportChanged; th->transchg = false; }
- if(th->playing) time.flags |= kVstTransportPlaying;
- if(th->looping) time.flags |= kVstTransportCycleActive;
-// if(th->feedback) time.flags |= kVstAutomationWriting;
-
- time.sampleRate = th->samplerate;
- time.samplePos = th->samplepos;
- time.ppqPos = th->ppqpos;
-
- time.tempo = th->tempo;
- time.barStartPos = th->barstartpos;
- time.cycleStartPos = th->cyclestartpos;
- time.cycleEndPos = th->cycleendpos;
-
- time.timeSigNumerator = th->timesignom;
- time.timeSigDenominator = th->timesigden;
-
- // SMPTE data
- time.smpteOffset = th->smpteoffset;
- time.smpteFrameRate = th->smpterate;
-
-// time.samplesToNextClock = 0;
-
- if(value&kVstNanosValid) {
- time.nanoSeconds = flext::GetOSTime()*1.e9;
- time.flags |= kVstNanosValid;
- }
-
- return (long)&time;
- }
-
- case audioMasterProcessEvents: { // 8
- // VST event data from plugin
- VstEvents *evs = static_cast<VstEvents *>(ptr);
- if(th) {
- for(int i = 0; i < evs->numEvents; ++i)
- th->ProcessEvent(*evs->events[i]);
- return 1;
- }
- else
- return 0;
- }
-
- case audioMasterSetTime: { // 9
- VstTimeInfo *tminfo = static_cast<VstTimeInfo *>(ptr);
- FLEXT_LOG3("TimeInfo pos=%lf rate=%lf filter=%li",tminfo->samplePos,tminfo->sampleRate,value);
- return 0; // not supported
- }
-
- case audioMasterTempoAt: // 10
- return 0; // not supported
-
- case audioMasterGetNumAutomatableParameters: // 11
- return 0; // not supported
-
- case audioMasterSizeWindow: // 15
- return 0;
-
- case audioMasterGetSampleRate: // 16
- return 0; // not supported
- case audioMasterGetBlockSize: // 17
- return 0; // not supported
-
- case audioMasterGetCurrentProcessLevel: // 23
- // return thread state
- return flext::IsSystemThread()?2:1;
-
- case audioMasterGetAutomationState: // 24
-// return th?(th->feedback?2:1):0;
- return 0;
-
- case audioMasterGetVendorString: // 32
- strcpy((char*)ptr,vendor);
- return 0;
-
- case audioMasterGetProductString: // 33
- strcpy((char *)ptr,product);
- return 0;
-
- case audioMasterGetVendorVersion: // 34
- return VST_VERSION;
-
- case audioMasterCanDo: // 37
- FLEXT_LOG1("\taudioMasterCanDo PTR = %s",ptr);
- if(!strcmp((char *)ptr,"sendVstEvents"))
- return 1;
- else if(!strcmp((char *)ptr,"sendVstMidiEvent"))
- return 1;
- else if(!strcmp((char *)ptr,"sendVstTimeInfo"))
- return 1; // NOT YET
- else if(!strcmp((char *)ptr,"receiveVstEvents"))
- return 1;
- else if(!strcmp((char *)ptr,"receiveVstMidiEvent"))
- return 1;
- else if(!strcmp((char *)ptr,"receiveVstTimeInfo"))
- return 1; // NOT YET
- else if(!strcmp((char *)ptr,"reportConnectionChanges"))
- return 0; // \TODO PD has hard times supporting that...
- else if(!strcmp((char *)ptr,"acceptIOChanges"))
- return 0; // \TODO what does this means exactly?
- else if(!strcmp((char *)ptr,"supplyIdle"))
- return 1;
- else if(!strcmp((char *)ptr,"sizeWindow"))
- return 1;
- else if(!strcmp((char *)ptr,"supportShell"))
- return 0; // deprecated - new one is shellCategory
- else if(!strcmp((char *)ptr,"offline"))
- return 0; // not supported
- else if(!strcmp((char *)ptr,"asyncProcessing"))
- return 0; // not supported
- else if(!strcmp((char *)ptr,"shellCategory"))
- return 1; // supported!
- else if(!strcmp((char *)ptr,"editFile"))
- return 0; // not supported
- else if(!strcmp((char *)ptr,"openFileSelector"))
- return 0; // not supported
- else if(!strcmp((char *)ptr,"closeFileSelector"))
- return 0; // not supported
- else if(!strcmp((char *)ptr,"startStopProcess"))
- return 0; // not supported
-#ifdef FLEXT_DEBUG
- else
- post("Unknown audioMasterCanDo PTR = %s",ptr);
-#endif
-
- return 0; // not supported
-
- case audioMasterGetLanguage: // 38
- return kVstLangEnglish;
-
- case audioMasterGetDirectory: // 41
- return (long)(th?th->dllname.c_str():dllloading.c_str());
-
- case audioMasterUpdateDisplay: // 42
- FLEXT_LOG("UPDATE DISPLAY");
- return 0;
-
- default:
- FLEXT_LOG1("Unknown opcode %li",opcode);
- return 0;
- }
-}
-
-void VSTPlugin::updatepos(long frames)
-{
- bool inloop = ppqpos < cycleendpos;
-
- // \todo should the sample position also jump back when cycling?
- // and if, how?
- samplepos += frames;
-
- // \todo this factor should be cached
- ppqpos += frames*tempo/(samplerate*60);
-
- if(looping) {
- double cyclelen = cycleendpos-cyclestartpos;
- if(cyclelen > 0) {
- if(inloop && ppqpos >= cycleendpos)
- ppqpos = cyclestartpos+fmod(ppqpos-cyclestartpos,cyclelen);
- }
- else
- ppqpos = cyclestartpos;
- }
-}
diff --git a/externals/grill/vst/src/vstmidi.cpp b/externals/grill/vst/src/vstmidi.cpp
deleted file mode 100644
index 8bddba98..00000000
--- a/externals/grill/vst/src/vstmidi.cpp
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
-vst~ - VST plugin object for PD
-based on the work of Jarno Seppänen and Mark Williamson
-
-Copyright (c)2003-2005 Thomas Grill (gr@grrrr.org)
-For information on usage and redistribution, and for a DISCLAIMER OF ALL
-WARRANTIES, see the file, "license.txt," in this distribution.
-*/
-
-#include "vsthost.h"
-
-bool VSTPlugin::AddMIDI(unsigned char data0,unsigned char data1,unsigned char data2)
-{
- if(Is()) {
- VstMidiEvent *pevent = &midievent[eventqusz];
-
- pevent->type = kVstMidiType;
- pevent->byteSize = 24;
- pevent->deltaFrames = 0;
- pevent->flags = 0;
- pevent->detune = 0;
- pevent->noteLength = 0;
- pevent->noteOffset = 0;
- pevent->reserved1 = 0;
- pevent->reserved2 = 0;
- pevent->noteOffVelocity = 0;
- pevent->midiData[0] = data0;
- pevent->midiData[1] = data1;
- pevent->midiData[2] = data2;
- pevent->midiData[3] = 0;
-
- if(eventqusz < MIDI_MAX_EVENTS) ++eventqusz;
- SendMidi();
- return true;
- }
- else return false;
-}
-
-
-void VSTPlugin::SendMidi()
-{
- if(Is() && eventqusz > 0) {
- // Prepare MIDI events and free queue dispatching all events
- events.numEvents = eventqusz;
- events.reserved = 0;
- for(int q = 0; q < eventqusz; q++)
- events.events[q] = (VstEvent*)&midievent[q];
-
- Dispatch(effProcessEvents, 0, 0, &events, 0.0f);
- eventqusz = 0;
- }
-}
diff --git a/externals/grill/vst/src/vstparam.cpp b/externals/grill/vst/src/vstparam.cpp
deleted file mode 100644
index bb80263e..00000000
--- a/externals/grill/vst/src/vstparam.cpp
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
-vst~ - VST plugin object for PD
-based on the work of Jarno Seppänen and Mark Williamson
-
-Copyright (c)2003-2005 Thomas Grill (gr@grrrr.org)
-For information on usage and redistribution, and for a DISCLAIMER OF ALL
-WARRANTIES, see the file, "license.txt," in this distribution.
-*/
-
-#include "vsthost.h"
-#include <ctype.h>
-
-static void striptrail(char *txt)
-{
- // strip trailing whitespace
- for(int i = strlen(txt)-1; i >= 0; --i)
- // cast to unsigned char since isspace functions don't want characters like 0x80 = -128
- if(isspace(((unsigned char *)txt)[i])) txt[i] = 0;
- else break;
-}
-
-void VSTPlugin::GetParamName(int numparam,char *name) const
-{
- if(numparam < GetNumParams()) {
- name[0] = 0;
- Dispatch(effGetParamName,numparam,0,name);
- striptrail(name);
- }
- else
- name[0] = 0;
-}
-
-bool VSTPlugin::SetParamFloat(int parameter,float value)
-{
- if(Is() && parameter >= 0 && parameter < GetNumParams()) {
- effect->setParameter(effect,parameter,value);
- return true;
- }
- else
- return false;
-}
-
-void VSTPlugin::GetParamValue(int numparam,char *parval) const
-{
- if(Is()) {
- if(numparam < GetNumParams()) {
- // how many chars needed?
- char par_display[64]; par_display[0] = 0;
- Dispatch(effGetParamDisplay,numparam,0,par_display);
-// if(par_display[7]) par_display[8] = 0; // set trailing zero
-
- // how many chars needed?
- char par_label[64]; par_label[0] = 0;
- Dispatch(effGetParamLabel,numparam,0,par_label);
- striptrail(par_label);
-// if(par_label[7]) par_label[8] = 0; // set trailing zero
-
- sprintf(parval,"%s%s",par_display,par_label);
- }
- else
- strcpy(parval,"Index out of range");
- }
- else
- strcpy(parval,"Plugin not loaded");
-}
-
-float VSTPlugin::GetParamValue(int numparam) const
-{
- if(Is() && numparam < GetNumParams())
- return effect->getParameter(effect,numparam);
- else
- return -1.0;
-}
-
-void VSTPlugin::ScanParams(int cnt)
-{
- if(cnt < 0) cnt = GetNumParams();
- if(paramnamecnt >= cnt) return;
- if(cnt >= GetNumParams()) cnt = GetNumParams();
-
- char name[64];
- for(int i = paramnamecnt; i < cnt; ++i) {
- GetParamName(i,name);
- if(*name) paramnames[std::string(name)] = i;
- }
- paramnamecnt = cnt;
-}
-
-int VSTPlugin::GetParamIx(const char *p) const
-{
- NameMap::const_iterator it = paramnames.find(std::string(p));
- return it == paramnames.end()?-1:it->second;
-}
-
-bool VSTPlugin::GetProgramName(int cat,int p,char *buf) const
-{
- buf[0] = 0;
- int parameter = p;
- if(parameter < GetNumPrograms() && cat < GetNumCategories()) {
- Dispatch(effGetProgramNameIndexed,parameter,cat,buf);
- striptrail(buf);
- return true;
- }
- else
- return false;
-}