/// <summary>
 /// Force a timed frame into the encoder's buffers.
 /// May cause unexpected operation. Use with caution!
 /// </summary>
 public void ForceInsertFrame(TimedSample AudioFrame)
 {
     if (AudioBuffers != null)
     {
         AudioBuffers.HandleCapturedSamples(this, new AudioDataEventArgs()
         {
             Samples = AudioFrame.Samples, CaptureTime = AudioFrame.Seconds
         });
     }
     else
     {
         throw new Exception("Can't send audio frame to uninitialised buffer. Please include an audio device in your config.");
     }
 }
    IEnumerable <TimedSample> GetTimedSamples(int count, TimeSpan interval)
    {
        TimedSample sample = null;

        for (int i = 0; i < count; i++)
        {
            sample = new TimedSample()
            {
                Value = String.Format("Item{0}", i),
                Begin = sample != null ? sample.End : DateTime.Now,
                End   = (sample != null ? sample.End : DateTime.Now) + interval
            };
            yield return(sample);
        }
    }
        /// <summary>
        /// Called by plug-in host (encoder)
        /// </summary>
        public void ProcessSample(TimedSample Sample)
        {
            float[] samps = ResampleForTone(Sample.Samples);

            foreach (float s in samps)
            {
                osc[osc_pos] *= decay;                 // fade old signal, to reduce response time
                osc[osc_pos] += s * gain;
                osc_pos       = (osc_pos + 1) % osc.Length;

                if (osc_pos == 0)
                {
                    // Prepare
                    BalanceOscillator();
                    FilterOscillator();

                    // Tone detection
                    DetectTone();
                }
            }
        }