protected override VstPluginInfo CreatePluginInfo(IVstPlugin plugin)
        {
            var info = base.CreatePluginInfo(plugin);

            info.ParameterCount = Plugin.ParametersManager.Parameters.Count();
            info.ProgramCount   = Plugin.ParametersManager.Programs.Count();

            return(info);
        }
Example #2
0
        /// <summary>
        /// Constructs a new instance of the host class based on the <paramref name="hostCmdStub"/>
        /// (from Interop) and a reference to the current <paramref name="plugin"/>.
        /// </summary>
        /// <param name="hostCmdStub">Must not be null.</param>
        /// <param name="plugin">Must not be null.</param>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="hostCmdStub"/> or
        /// <paramref name="plugin"/> is not set to an instance of an object.</exception>
        public VstHost(IVstHostCommandStub hostCmdStub, IVstPlugin plugin)
        {
            Throw.IfArgumentIsNull(hostCmdStub, "hostCmdStub");
            Throw.IfArgumentIsNull(plugin, "plugin");

            HostCommandStub = hostCmdStub;
            Plugin          = plugin;

            _intfMgr = new VstHostInterfaceManager(this);
        }
Example #3
0
        /// <summary>
        /// Constructs a new instance of the host class based on the <paramref name="hostCmdProxy"/>
        /// (from Interop) and a reference to the current <paramref name="plugin"/>.
        /// </summary>
        /// <param name="hostCmdProxy">Must not be null.</param>
        /// <param name="plugin">Must not be null.</param>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="hostCmdProxy"/> or
        /// <paramref name="plugin"/> is not set to an instance of an object.</exception>
        public VstHost(IVstHostCommandProxy hostCmdProxy, IVstPlugin plugin)
        {
            Throw.IfArgumentIsNull(hostCmdProxy, nameof(hostCmdProxy));
            Throw.IfArgumentIsNull(plugin, nameof(plugin));

            HostCommandProxy = hostCmdProxy;
            Plugin           = plugin;

            _automation    = new VstHostAutomation(this);
            _sequencer     = new VstHostSequencer(this);
            _shell         = new VstHostShell(this);
            _midiProcessor = new VstHostMidiProcessor(this);
        }
        /// <summary>
        /// Disposes all members, cascades the Dispose call.
        /// </summary>
        public void Dispose()
        {
            PluginInfo = null;

            if (Plugin != null)
            {
                Plugin.Dispose();
                Plugin = null;
            }

            if (Host != null)
            {
                Host.Dispose();
                Host = null;
            }
        }
Example #5
0
        /// <summary>
        /// Disposes all members, cascades the Dispose call.
        /// </summary>
        public void Dispose()
        {
            PluginInfo = null;

            if (Plugin != null)
            {
                Plugin.Dispose();
                Plugin = null;
            }

            if (Host != null)
            {
                Host.Dispose();
                Host = null;
            }
        }
        /// <summary>
        /// Called by the Interop loader to retrieve the plugin information.
        /// </summary>
        /// <param name="hostCmdStub">Must not be null.</param>
        /// <returns>Returns a fully populated <see cref="VstPluginInfo"/> instance. Never returns null.</returns>
        /// <remarks>Override <see cref="CreatePluginInfo"/> to change the default behavior of how the plugin info is built.</remarks>
        public VstPluginInfo?GetPluginInfo(IVstHostCommandProxy hostCmdStub)
        {
            IVstPlugin plugin = CreatePluginInstance();

            if (plugin != null)
            {
                if (plugin is IConfigurable config)
                {
                    config.Configuration = this.PluginConfiguration;
                }

                _pluginCtx = new VstPluginContext(
                    plugin, new Host.VstHost(hostCmdStub, plugin), CreatePluginInfo(plugin));

                Commands = CreatePluginCommands(_pluginCtx);

                return(_pluginCtx.PluginInfo);
            }

            return(null);
        }
        /// <summary>
        /// Creates summary info based on the <paramref name="plugin"/>.
        /// </summary>
        /// <param name="plugin">Must not be null.</param>
        /// <returns>Never returns null.</returns>
        /// <remarks>Override to add or change behavior.</remarks>
        protected virtual VstPluginInfo CreatePluginInfo(IVstPlugin plugin)
        {
            VstPluginInfo pluginInfo = new VstPluginInfo();

            var audioProcessor = plugin.GetInstance <IVstPluginAudioProcessor>();

            // determine flags
            if (plugin.Supports <IVstPluginEditor>())
            {
                pluginInfo.Flags |= VstPluginFlags.HasEditor;
            }
            if (audioProcessor != null)
            {
                pluginInfo.Flags |= VstPluginFlags.CanReplacing;
            }
            if (plugin.Supports <IVstPluginAudioPrecisionProcessor>())
            {
                pluginInfo.Flags |= VstPluginFlags.CanDoubleReplacing;
            }
            if (plugin.Supports <IVstPluginPersistence>())
            {
                pluginInfo.Flags |= VstPluginFlags.ProgramChunks;
            }
            if (audioProcessor != null && plugin.Supports <IVstMidiProcessor>())
            {
                pluginInfo.Flags |= VstPluginFlags.IsSynth;
            }
            if ((plugin.Capabilities & VstPluginCapabilities.NoSoundInStop) > 0)
            {
                pluginInfo.Flags |= VstPluginFlags.NoSoundInStop;
            }

            // basic plugin info
            pluginInfo.InitialDelay  = plugin.InitialDelay;
            pluginInfo.PluginID      = plugin.PluginID;
            pluginInfo.PluginVersion = plugin.ProductInfo.Version;

            // audio processing info
            if (audioProcessor != null)
            {
                pluginInfo.AudioInputCount  = audioProcessor.InputCount;
                pluginInfo.AudioOutputCount = audioProcessor.OutputCount;
            }

            // parameter info
            IVstPluginParameters?pluginParameters = plugin.GetInstance <IVstPluginParameters>();

            if (pluginParameters != null)
            {
                pluginInfo.ParameterCount = pluginParameters.Parameters.Count;
            }

            // program info
            IVstPluginPrograms?pluginPrograms = plugin.GetInstance <IVstPluginPrograms>();

            if (pluginPrograms != null)
            {
                pluginInfo.ProgramCount = pluginPrograms.Programs.Count;
            }

            return(pluginInfo);
        }
Example #8
0
 internal VstPluginContext(IVstPlugin plugin, VstHost host, VstPluginInfo info)
 {
     Plugin     = plugin ?? throw new ArgumentNullException(nameof(plugin));
     _host      = host ?? throw new ArgumentNullException(nameof(host));
     PluginInfo = info ?? throw new ArgumentNullException(nameof(plugin));
 }
        /// <summary>
        /// Creates summary info based on the <paramref name="plugin"/>.
        /// </summary>
        /// <param name="plugin">Must not be null.</param>
        /// <returns>Never returns null.</returns>
        /// <remarks>Override to add or change behavior.</remarks>
        protected virtual VstPluginInfo CreatePluginInfo(IVstPlugin plugin)
        {
            VstPluginInfo pluginInfo = new VstPluginInfo();

            IVstPluginAudioProcessor audioProcessor = plugin.GetInstance<IVstPluginAudioProcessor>();

            // determine flags
            if (plugin.Supports<IVstPluginEditor>())
                pluginInfo.Flags |= VstPluginFlags.HasEditor;
            if (audioProcessor != null)
                pluginInfo.Flags |= VstPluginFlags.CanReplacing;
            if (plugin.Supports<IVstPluginAudioPrecisionProcessor>())
                pluginInfo.Flags |= VstPluginFlags.CanDoubleReplacing;
            if (plugin.Supports<IVstPluginPersistence>())
                pluginInfo.Flags |= VstPluginFlags.ProgramChunks;
            if (audioProcessor != null && plugin.Supports<IVstMidiProcessor>())
                pluginInfo.Flags |= VstPluginFlags.IsSynth;
            if ((plugin.Capabilities & VstPluginCapabilities.NoSoundInStop) > 0)
                pluginInfo.Flags |= VstPluginFlags.NoSoundInStop;

            // basic plugin info
            pluginInfo.InitialDelay = plugin.InitialDelay;
            pluginInfo.PluginID = plugin.PluginID;
            pluginInfo.PluginVersion = plugin.ProductInfo.Version;

            // audio processing info
            if (audioProcessor != null)
            {
                pluginInfo.AudioInputCount = audioProcessor.InputCount;
                pluginInfo.AudioOutputCount = audioProcessor.OutputCount;
            }

            // parameter info
            IVstPluginParameters pluginParameters = plugin.GetInstance<IVstPluginParameters>();
            if (pluginParameters != null)
                pluginInfo.ParameterCount = pluginParameters.Parameters.Count;

            // program info
            IVstPluginPrograms pluginPrograms = plugin.GetInstance<IVstPluginPrograms>();
            if (pluginPrograms != null)
                pluginInfo.ProgramCount = pluginPrograms.Programs.Count;

            return pluginInfo;
        }