Ejemplo n.º 1
0
        //private IVstHostOfflineProcessor CreateOffline(IVstHostOfflineProcessor instance)
        //{
        //    if (instance == null &&
        //        _host.HostCommandStub.CanDo(VstHostCanDo.Offline) == VstCanDoResult.Yes)
        //    {
        //        return new VstHostOfflineProcessor(_host);
        //    }

        //    return instance;
        //}

        private IVstHostSequencer CreateSequencer(IVstHostSequencer instance)
        {
            if (instance == null)
            {
                return(new VstHostSequencer(_host));
            }

            return(instance);
        }
Ejemplo n.º 2
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>
        /// Called by the host to allow the plugin to process audio samples. This method is used to inform the rest of
        /// the plugin that the audio processing cycle is ending.
        /// </summary>
        public override void Process(VstAudioBuffer[] inChannels, VstAudioBuffer[] outChannels)
        {
            sampleTime += inChannels[0].SampleCount;

            IVstHostSequencer midiHostSeq = this.vstHost.GetInstance <IVstHostSequencer>();
            VstTimeInfo       timeInfo    = midiHostSeq.GetTime(VstTimeInfoTransmitter.RequiredTimeInfoFlags);

            this.timeInfoTransmitter.TransmitTimeInfoToRelay(timeInfo, sampleTime);

            // calling the base class transfers input samples to the output channels unchanged (bypass).
            base.Process(inChannels, outChannels);

            //Informs the HostInfoRelay that the audio processing cycle is ending.
            this.hostInfoInputPort.TriggerProcessingCycleEnd(sampleTime);
        }
Ejemplo n.º 4
0
        unsafe void IVstPluginAudioProcessor.Process(VstAudioBuffer[] inputChannels, VstAudioBuffer[] outputChannels)
        {
            long hostSamplePosition;
            var  creator = this.creator as Plugin;

            if (creator != null)
            {
                hostSamplePosition = (long)(hostSequencer ?? (hostSequencer = creator.Host.GetInstance <IVstHostSequencer>())).GetTime(0).SamplePosition;
            }
            else
            {
                throw new NotSupportedException();              // the VST host should create an instance of the plugin before calling the `Process` method.
            }
            int sampleCount = 0,
                L           = inputChannels.Length,
                L2          = outputChannels.Length;

            if (inputIntermediary == null || inputIntermediary.Length != L)
            {
                inputIntermediary = new float * [L];
            }
            if (outputIntermediary == null || outputIntermediary.Length != L2)
            {
                outputIntermediary = new float * [L2];
            }
            for (int i = 0; i < L; ++i)              // copies only the references to each channel's buffer over to a managed array of (unmanaged) buffers
            {
                if (i == 0)
                {
                    sampleCount = inputChannels[0].SampleCount;                    // ToDo: make sample count the smallest sample count of all arrays?
                }
                inputIntermediary[i] = ((IDirectBufferAccess32)inputChannels[i]).Buffer;
            }
            for (int i = 0; i < L2; ++i)
            {
                outputIntermediary[i] = ((IDirectBufferAccess32)outputChannels[i]).Buffer;
            }

            if (L > 0 && L2 > 0)
            {
                Process(inputIntermediary, outputIntermediary, hostSamplePosition, sampleCount);
            }
        }
Ejemplo n.º 5
0
        public IVstHostSequencer getHostSequencer()
        {
            IVstHostSequencer hostSequencer = this.Host.GetInstance <IVstHostSequencer>();

            return(hostSequencer);
        }