I am trying to use VST plugins for equalizing in a C# project. When I tried to follow the “dsp_effect_per_speaker” example, I alway get exceptions of the type “PInvokeStackImbalance” which seemingly have their origin in a non-matching PInvoke signature compared to the signature on the C++ side.

Here is a little example showing this:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using System.Windows.Forms;

namespace VST_Test
    public partial class Form1 : Form
        private FMOD.System fmod_system;
        private FMOD.Sound sound_instance;
        private FMOD.Channel fmod_channel;
        private FMOD.ChannelGroup master_channelgroup;
        private FMOD.DSP vst_plugin1, vst_plugin2;
        private uint vst_plugin_handle;

        private FMOD.DSP main_head, main_mixer;
        private FMOD.DSPConnection dsp_left_out_connection, dsp_right_out_connection, dsp_left_in_connection, dsp_right_in_connection, main_mixer_connection;

        private System.Windows.Forms.Form config_window;

        public Form1()

        private void Form1_Shown(object sender, EventArgs e)
            FMOD.Factory.System_Create(out fmod_system);

            fmod_system.getMasterChannelGroup(out master_channelgroup);

            fmod_system.loadPlugin("Nova67P.dll", out vst_plugin_handle);
            fmod_system.createDSPByPlugin(vst_plugin_handle, out vst_plugin1);
            fmod_system.createDSPByPlugin(vst_plugin_handle, out vst_plugin2);

            fmod_system.createSound("Going-On.mp3", FMOD.MODE.NONBLOCKING, out sound_instance);

            master_channelgroup.getDSP(FMOD.CHANNELCONTROL_DSP_INDEX.HEAD, out main_head);
            main_head.getInput(0, out main_mixer, out main_mixer_connection);

            //----------------------------------------------------- PROBLEM ------------------------------------------------

            //main_head.disconnectFrom(main_mixer); // -------------------------- Causes PInvokeStackImbalance Exception
            //vst_plugin1.addInput(main_head, out dsp_left_in_connection); // --- Same problem!
            //main_head.addInput(vst_plugin1, out dsp_left_out_connection);// --- Same problem

            master_channelgroup.addDSP(0, vst_plugin1); // ---------------------- Works!


        private void button_play_Click(object sender, EventArgs e)
            fmod_system.playSound(sound_instance, master_channelgroup, false, out fmod_channel);

        private void button_show_ui_Click(object sender, EventArgs e)
            uint version;
            int channels;
            int config_width;
            int config_height;

            config_window = new Form();
            config_window.Width = 763;
            config_window.Height = 638;
            config_window.Text = "Equalizer";


            vst_plugin1.showConfigDialog(config_window.Handle, true);

        private void timer_update_Tick(object sender, EventArgs e)

Am I missing something or is this a bug in the C# wrapper?

Thanks for your help, Florian

  • You must to post comments
Best Answer

It is a bug in the C# wrapper, here is the answer from Nick Wilcox from FMOD:

Hi Florian,

Here is an update to the C# wrapper that fixes the issue. It will be also be included in 1.05.16 and 1.06.00.

Hope that helps!

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.