1 /** 2 Generic host commands. 3 Copyright: Auburn Sounds 2015-2016. 4 License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0) 5 */ 6 module dplug.host.host; 7 8 nothrow @nogc: 9 10 interface IPluginHost 11 { 12 nothrow @nogc: 13 14 /// Process some audio. 15 /// `setSampleRate` and `setMaxBufferSize` must be called before use. 16 /// samples must <= the maximum buffer size asked in 17 void processAudioFloat(float** inputs, float** ouputs, int samples); 18 19 /// Sets the desired sampleRate 20 void setSampleRate(float sampleRate); 21 22 /// Sets the maximum buffer size 23 void setMaxBufferSize(int samples); 24 25 /// Sets I/O arrangement (simple right now). 26 bool setIO(int numInputs, int numOutputs); 27 28 /// Sets a parameter's value. 29 void setParameter(int paramIndex, float normalizedValue); 30 31 /// Returns: Normalized value for parameter. 32 float getParameter(int paramIndex); 33 34 /// Returns: Full name for parameter. 35 /// Lifetime of return value is same as IPluginHost. 36 const(char)[] getParameterName(int paramIndex); 37 38 /// Returns: Number of parameters. 39 int getParameterCount(); 40 41 /// Loads a preset. 42 void loadPreset(int presetIndex); 43 44 /// Serialize state of the plugin, to restore with `restoreState`. 45 /// 46 /// Returns: `null` in case of error, else a state chunk. 47 /// The lifetime of this returned chunk is the same as the `IPluginHost`, or until 48 /// another call to `saveState` is done. 49 const(ubyte)[] saveState(); 50 51 /// Restore state of the plugin, saved with `saveState`. 52 /// Returns: `true` on success. 53 bool restoreState(const(ubyte)[] chunk); 54 55 /// Gets current "program" index. 56 /// Note: not all presets are exposed to the host. In many plug-ins they aren't. 57 int getCurrentProgram(); 58 59 /// Get plugin information. 60 /// Lifetime of return value is same as IPluginHost. 61 const(char)[] getProductString(); 62 63 ///ditto 64 /// Lifetime of return value is same as IPluginHost. 65 const(char)[] getEffectName(); 66 67 ///ditto 68 /// Lifetime of return value is same as IPluginHost. 69 const(char)[] getVendorString(); 70 71 /// Opens the editor window. 72 /// On Windows, pass a HWND 73 /// On Mac, a NSView 74 void openUI(void* windowHandle); 75 76 /// Closes the editor. 77 void closeUI(); 78 79 /// Gets the UI size. 80 int[2] getUISize(); 81 82 /// Switch on the plugin. Call it before processing. 83 void beginAudioProcessing(); 84 85 /// Switch off the plugin. Call it after processing. 86 void endAudioProcessing(); 87 88 /// Get current plug-in latency in samples. 89 /// Because of VST2 limitations, this number of only valid between a 90 /// `beginAudioProcessing` and `endAudioProcessing` call, and won't move while 91 /// processing. 92 int getLatencySamples(); 93 94 /// Get tail size in seconds. Precise semantics TBD. 95 double getTailSizeInSeconds(); 96 } 97 98