CsoundVST.hpp

Go to the documentation of this file.
00001 /*
00002  * C S O U N D   V S T
00003  *
00004  * A VST plugin version of Csound.
00005  *
00006  * L I C E N S E
00007  *
00008  * This software is free software; you can redistribute it and/or
00009  * modify it under the terms of the GNU Lesser General Public
00010  * License as published by the Free Software Foundation; either
00011  * version 2.1 of the License, or (at your option) any later version.
00012  *
00013  * This software is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016  * Lesser General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU Lesser General Public
00019  * License along with this software; if not, write to the Free Software
00020  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00021  */
00022 #ifndef __CSOUNDVST_H
00023 #define __CSOUNDVST_H
00024 
00025 #include <Platform.hpp>
00026 // Hack to compile all this GNU stuff on Windows.
00027 #ifdef _MSC_VER
00028 #include <windows.h>
00029 #include <mmsystem.h>
00030 #endif
00031 
00032 #include "public.sdk/source/vst2.x/audioeffectx.h"
00033 #include <CppSound.hpp>
00034 #include <list>
00035 
00036 class CsoundVstFltk;
00037 
00038 class Preset
00039 {
00040 public:
00041   std::string name;
00042   std::string text;
00043 };
00044 
00045 class CsoundVST :
00046   public CppSound,
00047   public AudioEffectX
00048 {
00049 public:
00050   enum
00051     {
00052       kNumInputs = 2
00053     };
00054   enum
00055     {
00056       kNumOutputs = 2
00057     };
00058   enum
00059     {
00060       kNumPrograms = 10
00061     };
00062   static double inputScale;
00063   static double outputScale;
00067   static void *fltkWaitThreadId;
00068   bool isSynth;
00069   bool isMultiThreaded;
00070   size_t csoundFrameI;
00071   size_t csoundLastFrame;
00072   size_t channelI;
00073   size_t channelN;
00074   size_t hostFrameI;
00075   float vstSr;
00076   float vstCurrentSampleBlockStart;
00077   float vstCurrentSampleBlockEnd;
00078   float vstCurrentSamplePosition;
00079   float vstPriorSamplePosition;
00080   CsoundVstFltk *csoundVstFltk;
00081   std::list<VstMidiEvent> midiEventQueue;
00082   std::vector<Preset> bank;
00083   // AudioEffectX overrides.
00084   CsoundVST(audioMasterCallback audioMaster);
00085   virtual ~CsoundVST();
00086   virtual AEffEditor *getEditor();
00087   virtual bool getEffectName(char* name);
00088   virtual bool getVendorString(char* name);
00089   virtual bool getProductString(char* name);
00090   virtual VstInt32 canDo(char* text);
00091   virtual bool getInputProperties(VstInt32 index, VstPinProperties* properties);
00092   virtual bool getOutputProperties(VstInt32 index, VstPinProperties* properties);
00093   virtual bool keysRequired();
00094   virtual VstInt32 getProgram();
00095   virtual void setProgram(VstInt32 program);
00096   virtual void setProgramName(char *name);
00097   virtual void getProgramName(char *name);
00098   virtual bool copyProgram(VstInt32 destination);
00099   virtual bool getProgramNameIndexed(VstInt32 category, VstInt32 index, char* text);
00100   virtual VstInt32 getChunk(void** data, bool isPreset);
00101   virtual VstInt32 setChunk(void* data, VstInt32 byteSize, bool isPreset);
00102   virtual void suspend();
00103   virtual void resume();
00104   virtual VstInt32 processEvents (VstEvents* events);
00105   virtual void process(float **inputs, float **outputs, VstInt32 sampleFrames);
00106   virtual void processReplacing(float **inputs, float **outputs, VstInt32 sampleFrames);
00107   // Shell overrides.
00108   virtual void open();
00109   // Peculiar to CsoundVST.
00110   CsoundVST();
00111   virtual bool getIsSynth() const;
00112   virtual void setIsSynth(bool isSynth);
00113   virtual bool getIsVst() const;
00114   virtual uintptr_t performanceThreadRoutine();
00115   virtual int performance();
00116   virtual std::string getText();
00117   virtual void setText(const std::string text);
00118   virtual void synchronizeScore();
00119   virtual void reset();
00120   virtual void openFile(std::string filename);
00121   virtual void openView(bool doRun = true);
00122   virtual void closeView();
00123   virtual bool getIsMultiThreaded() const;
00124   virtual void setIsMultiThreaded(bool isMultiThreaded);
00125   virtual void fltklock();
00126   virtual void fltkunlock();
00127   virtual void fltkflush();
00128   virtual void fltkwait();
00129   virtual int fltkrun();
00130   static int midiDeviceOpen(CSOUND *csound, void **userData,
00131                             const char *devName);
00132   static int midiRead(CSOUND *csound, void *userData,
00133                       unsigned char *buf, int nbytes);
00134 };
00135 
00136 #if !defined(SWIGJAVA)
00137 
00138 extern "C"
00139 {
00140   SILENCE_PUBLIC CsoundVST* CreateCsoundVST();
00141   SILENCE_PUBLIC void RunCsoundVST(const char *filename);
00142 }
00143 
00144 #endif
00145 
00146 #endif
00147 

Generated on Tue Apr 14 11:00:49 2009 for Csound and CsoundAC by  doxygen 1.5.8