Thanks for helping me out I really appreciate it. Marc, I adjusted my code and changed the functions as follows:
// I use this to set up the VSTi buffers and only call it once when the user clicks a button.
private void initiateAudioOutput()
int inputCount = this.ctx.PluginInfo.AudioInputCount;
int outputCount = this.ctx.PluginInfo.AudioOutputCount;
this.inputMgr = new VstAudioBufferManager(inputCount, blockSize);
this.outputMgr = new VstAudioBufferManager(outputCount, blockSize);
foreach (VstAudioBuffer buffer in inputMgr.ToArray())
for (int i = 0; i < blockSize; i++)
buffer[i] = 0; // Initialize to 0
this.inputBuffers = inputMgr.ToArray();
this.outputBuffers = outputMgr.ToArray();
// I use this to pass midi data into the VSTi again happens when the user clicks a button
private void processMidiOnce(int volume, int pitch)
VstEvent vEvent = createEvent(volume, pitch);
//This function then calls process replacing and fills the audio output buffers, this is called in a while loop (this is the function i am most unsure about where and when to call)
private void processBuffers(VstAudioBuffer inputBuffers, VstAudioBuffer outputBuffers, int blockSize)
for (int i = 0;/* i < inputBuffers.Length &&*/ i < outputBuffers.Length; i++)
for (int j = 0; j < blockSize; j++)
if (outputBuffers[i][j] != 0.0)
// IF THIS LINE IS HIT YOU HAVE SOMETHING PLAYING
//outputBuffers[i][j] = outputBuffers[i][j] * Byte.MaxValue;
Globals.globuf[j] = outputBuffers[i][j];
// and to dispose of objects
private void VSToff()
// Close resources
I am still getting the stuttering sound and I believe you maybe right Yury, as when i look at the globuf there are periods of many zeros. globuf is declared as: static internal float globuf = new float; I have tried lowering the array size but this
throws an error.
I have also tried using waveprovider32 but it throws the following error:
The runtime has encountered a fatal error. The address of the error was at 0x52fd3a3a, on thread 0x1df0. The error code is 0xc0000005. This error may be a bug in the CLR or in the unsafe or non-verifiable portions of user code. Common sources of this bug
include user marshaling errors for COM-interop or PInvoke, which may corrupt the stack.
Im really greatful for any further light you can shed as to what might be wrong as I have been trying to resolve this for weeks!
Thanks once again,