Certain VSTs not playing sound (memory access violation error)

Topics: 64 bit, Midi, VST.NET Core, VST.NET Interop
Dec 12, 2016 at 6:09 AM
Edited Dec 12, 2016 at 6:13 AM
Hello, in an ongoing effort to create a host playing MIDI data on VST instruments, I'm having a specific problem related to certain VSTs. That is, most VSTs on my system are responding to ProcessReplacing and providing audio samples properly, which are played, but certain VSTs throw an memory access violation error.

Incidentally, the specific VSTs (so far) are AddictiveDrums and EZDrummer.

I'm using VST.Core/VST.Interop (and implementing ISampleProvider from NAudio) to produce the sound.

The Read Function of the ISampleProvider (which is being used to .init an instance of a WaveOut) looks like this:
(Here, "VPlug" is the instance of IVstPluginCommandStub already associated with the ISampleProvider)
public int Read(float[] buffer, int offset, int count)
{

    vstBufManIn = new VstAudioBufferManager(2, count / 2);
    vstBufManOut = new VstAudioBufferManager(2, count / 2);

    #Disable Warning BC40000 ' Type or member is obsolete
    vstBufIn = vstBufManIn.ToArray();
    vstBufOut = vstBufManOut.ToArray();
    #Enable Warning BC40000 ' Type or member is obsolete

    VPlug.ProcessReplacing(vstBufIn, vstBufOut);

    int outno = 0;
    for (int i = 0; i <= count / 2 - 1; i++) {
        buffer(outno) = vstBufOut(0).Item(i);
        buffer(outno + 1) = vstBufOut(1).Item(i);
        outno += 2;
    }

    return count;

}
It's set up so that clicking on a note in a piano roll sends a VSTMidiEvent through ProcessEvents to the instance of the PlugInCommandStub.
For 90% of the VSTs I can choose on my system, this works properly with no errors and produces the expected sound, but with Addictive Drums, for example, I get the error:

"An unhandled exception of type 'System.AccessViolationException' occurred in Jacobi.Vst.Interop.dll"
with further info "... attempted to read or write protected memory..."

Incidentally, the OpenEditor works fine for Addictve drums, it opens the editor and you can select drum sets from it... but any call to ProcessReplacing throws that error and execution stops.

I have to admit I don't fully understand things related to memory usage so I'm at a bit of brick wall here... :-(
Dec 19, 2016 at 7:10 AM
Not much happening on this discussion board, but some additional info if pertinent (I don't know)
Among the details for the exception I find:

Module = Jacobi.Vst.Interop.dll
TargetSite= {Void CallProcess32(Single**, Single**, Int32)}
HRESULT = -2147467261
Data = {System.Collections.ListDictionaryInternal}

Michael
Coordinator
Apr 21 at 12:41 PM
First I am very sorry I did not see your message sooner. It seems codeplex does not send notification emails anymore.

To the best of my knowledge VST.NET handles the ProcessReplacing correct. However, it seems that these plugins in question obey different rules when it comes to how to access the audio buffers passed to them by the host.

Are you (as a Host) sure the size of the VstAudioBuffers is equal or greater than the BlockSize you specify for each plugin?