0

I had a vstplugin to remove noise of sound. I made connection it with input device and output device and it worked fine. Load vst function

public static void LoadPlugin(string path, out VstPluginContext plugin)
    {
        var hcs = new HostCommandStub();
        hcs.PluginCalled += new EventHandler<PluginCalledEventArgs>(HostCmdStub_PluginCalled);
        try
        {
            plugin = VstPluginContext.Create(path, hcs);
            plugin.Set("PluginPath", path);
            plugin.Set("HotCmdStub", hcs);

            plugin.PluginCommandStub.Commands.Open();
            plugin.PluginCommandStub.Commands.MainsChanged(true);
            _logger.Info("Load VST Plugin successful");
        }
        catch (Exception ex)
        {
            plugin = null;
            _logger.Error("Failed to load VST Plugin", ex);
        }
    }

Create connection:

public static void ConnectPlugin(bool restartDevice = false, bool byPass = false, bool debug = false)
    {
        _IsConnecting = true;
        try
        {
            _currentConfig = new CurrentConfig
            {
                InputDeviceNum = _currentInput?.DeviceNumber ?? 0,
                OutputDeviceNum = _currentOutput?.DeviceNumber ?? 1,
                ByPass = byPass,
                Debug = debug
            };

            if (!restartDevice && waveIn != null) return;

            DisconnectDevices();

            if (_currentInput == null || _currentOutput == null) return;

            sampleRate = 48000f;
            blockSize = (int)(4800);

            waveIn = new WaveInEvent();
            waveIn.BufferMilliseconds = 100;
            waveIn.DataAvailable += Plugin_DataAvailable;
            waveIn.DeviceNumber = _currentConfig.InputDeviceNum;
            waveIn.WaveFormat = new WaveFormat((int)sampleRate, 16, 1);

            waveProviderout = new BufferedWaveProvider(waveIn.WaveFormat) { DiscardOnBufferOverflow = true };

            int inputCount = _vstPlugin.PluginInfo.AudioInputCount;
            int outputCount = _vstPlugin.PluginInfo.AudioOutputCount;

            var inputMgr = new VstAudioBufferManager(inputCount, blockSize);
            var outputMgr = new VstAudioBufferManager(outputCount, blockSize);

            _vstPlugin.PluginCommandStub.Commands.SetBlockSize(blockSize);
            _vstPlugin.PluginCommandStub.Commands.SetSampleRate(sampleRate);
            _vstPlugin.PluginCommandStub.Commands.SetProcessPrecision(VstProcessPrecision.Process32);

            // set value for bypass
            _vstPlugin.PluginCommandStub.Commands.SetBypass(_currentConfig.ByPass);

            // set value for debug - index = 0
            _vstPlugin.PluginCommandStub.Commands.SetParameter(0, _currentConfig.Debug ? 1f : 0);

            inputBuffers = inputMgr.Buffers.ToArray();
            outputBuffers = outputMgr.Buffers.ToArray();

            waveOut = new WaveOutEvent();
            waveOut.DesiredLatency = 100;
            waveOut.DeviceNumber = _currentConfig?.OutputDeviceNum ?? 1;
            waveOut.Init(waveProviderout);

            waveOut.Play();

            waveIn.StartRecording();

            //SetScheduleForReset(1800000); // reset plugin every 2 hours (7200000 ms)
        }
        catch (Exception ex)
        {
        }

        _IsConnecting = false;

        Autofix();
    }

Currently I want to add a connection from a new input device to a new output device with the same plugin but with a different bypass parameter.. I tried to clone the above code to create a new connection, it works fine, but it doesn't seem to receive the bypass parameter. Please help me

  • 1 vst plugin (noise removed)
  • Connections
    • Connection 1: Input Device A ---> Output Device B: with bypass = false
    • Connection 2: Input Device C ---> Output Device D: with bypass = true

Thanks

4

0 回答 0