Search
  • Tim Cave

Making a VSTi Host - Part 3

Updated: Jan 15, 2021

Part 3 of this series builds on the code in Part 2 and in this blog I am going to show the following:

  1. Load a VSTi (instrument plugin) in the editor form

  2. Create a plugin stream


Load a VSTi

In order to load a VSTi you need to drop the BASS_VST_ChannelSetDSP line of code and use the following instead:



ch = BASS_VST_ChannelCreate(44100, 2, "C:\\Program Files (x86)\\Vstplugins\\DSK The Grand.dll", 0);


You also need to also move the ChannelPlay to before the VSTi editor form opens. Make sure you also change the form vstHandle parameter to ch. I've also added the plugin product name to be show in the editor form title. There are many more properties under vstInfo you can display - for details go here.


Also try adding this new code to a new function that you can call from a new button on your main form. The full code for this function is as follows:



void playVSTiNoMidi() {

    // create a normal BASS stream
    BASS_Init(-1, 44100, 0, 0, NULL); 

     //assign a VSTi plugin to the channel
    DWORD ch = BASS_VST_ChannelCreate(44100, 2, "C:\\Program Files (x86)\\Vstplugins\\DSK The Grand.dll", 0);
        
    BASS_VST_INFO vstInfo; //vst info   

    BASS_ChannelPlay(ch, false);
    //show editor
    VSTiHostBlog::MyForm1 form;
    if (BASS_VST_GetInfo(ch, &vstInfo) && vstInfo.hasEditor)
    {
        const char* charstr = "";
        charstr = vstInfo.productName;
        String^ clistr = gcnew String(charstr);
        form.Text = clistr;
        form.Width = vstInfo.editorWidth + 10;
        form.Height = vstInfo.editorHeight + 40;
        
        IntPtr iHwnd = form.Handle;
        HWND hwnd = (HWND)iHwnd.ToInt32();
        BASS_VST_EmbedEditor(ch, hwnd);

        form.ShowDialog();
    }
    else {
        MessageBox::Show("No editor");
    }
    form.Close();    

     // delete the stream - this will also delete the VSTi
    BASS_StreamFree(ch);

}


C++ VSTi Plugin in Editor Form
C++ VSTi Plugin in Editor Form

Go on to Part 4 ...



11 views0 comments

Recent Posts

See All