Author Topic: How to save preset data when i change the parameters in the Editor  (Read 124 times)

josemym

  • Posts: 1
Please, how to save preset data when i change the parameters in the Editor?

Code: [Select]
public void SaveVstPreset(int vstHandle, string filePath, float delayTime)
    {
        //yield return new WaitForSeconds(delayTime);
        // Now do your thing here
   
    // Function to save the VST preset to a file
        byte[] presetData = BassVst.BASS_VST_GetChunk(vstHandle, true);
        if (presetData != null)
        {
            System.IO.File.WriteAllBytes(filePath + "preset_data.vstpreset", presetData);
            Console.WriteLine("Preset data saved successfully!");
        }
        else
        {
            Console.WriteLine("Error retrieving preset data!");
        }
    }


Code: [Select]
private int YourVstProc(int vstHandle, BASSVSTAction action, int param1, int param2, IntPtr user)
    {
        switch (action)
        {
            case BASSVSTAction.BASS_VST_PARAM_CHANGED:
                // we get notified that the user has changed some sliders in the editor -
                // do what to do here ...
                if (vstHandle2 != 0)
                {
                    SaveVstPreset(vstHandle2, UnityEngine.Application.dataPath + @"\..\VSTIplugins\", 1f);
                }
                break;
            case BASSVSTAction.BASS_VST_EDITOR_RESIZED:

                // the editor window requests a new size,
                // maybe we should resize the window the editor is embedded in?
                // the new width/height can be found in param1/param2
                if (f != null && !f.IsDisposed)
                {
                    // param1 = width, param2 = height
                    f.ClientSize = new Size(param1, param2);
                }
                break;
            case BASSVSTAction.BASS_VST_AUDIO_MASTER:
                // this is only for people familiar with the VST SDK,
                // param1 is a pointer to a BASS_VST_AUDIO_MASTER_PARAM structure
                // which contains all information needed
                break;
        }
        return 0;
   
   
       
    }

My application freeze and crash, please help.

Ian @ un4seen

  • Administrator
  • Posts: 26172
Please confirm which line the crash is happening at. Catching it in the debugger will hopefully reveal that. Also confirm that you have setup a delegate for your "YourVstProc" function as instructed in the "Callbacks and Delegates" section of the BASS.Net documentation's "Interoperating with Unmanaged Code" page.