Accord.Audio.AudioSourceMixer.Start C# (CSharp) Method

Start() public method

Start audio source.
Starts audio source and return execution to caller. Audio source object creates background thread and notifies about new frames with the help of NewFrame event.
public Start ( ) : void
return void
        public void Start()
        {
            if (thread == null)
            {
                // check source
                for (int i = 0; i < Sources.Length; i++)
                {
                    IAudioSource source = Sources[i];

                    if (source == null)
                        throw new ArgumentException("Audio source is not specified");

                    source.UserData = i;

                    source.NewFrame += source_NewFrame;
                    channels = Math.Max(channels, source.Channels);
                    if (sampleRate == 0)
                        sampleRate = source.SampleRate;
                    else if (source.SampleRate != sampleRate)
                        throw new InvalidSignalPropertiesException(
                            "The sample rates of all audio sources must match");

                    if (frameSize == 0)
                        frameSize = source.DesiredFrameSize;
                    else if (source.DesiredFrameSize != frameSize)
                        throw new InvalidSignalPropertiesException(
                            "The sample rates of all audio sources must match");
                }

                if (channels > 2)
                    throw new ArgumentException("Only a maximum of 2 channels is supported.");

                framesReceived = 0;
                bytesReceived = 0;

                // create events
                signals = new Signal[Sources.Length];
                stopEvents = new AutoResetEvent[Sources.Length];
                for (int i = 0; i < stopEvents.Length; i++)
                    stopEvents[i] = new AutoResetEvent(false);


                // create and start new thread
                thread = new Thread(WorkerThread);
                thread.Name = "Software Audio Mixer";
                thread.Start();
            }
        }