Arguments for new block event from audio source.
Inheritance: System.EventArgs
Esempio n. 1
0
        void source_NewFrame(object sender, NewFrameEventArgs eventArgs)
        {

            ComplexSignal signal = ComplexSignal.FromSignal(eventArgs.Signal);

            if (hammingWindowToolStripMenuItem.Checked)
            {
                ComplexSignal c = window.Apply(signal, 0);
                signal = c;
            }


            signal.ForwardFourierTransform();

            Complex[] channel = signal.GetChannel(0);
            double[] power = Accord.Audio.Tools.GetPowerSpectrum(channel);
            double[] freqv = Accord.Audio.Tools.GetFrequencyVector(signal.Length, signal.SampleRate);

            power[0] = 0; // zero DC

            float[] g = new float[power.Length];

            for (int i = 0; i < power.Length; i++)
            {
                // g[i, 0] = freqv[i];
                g[i] = (float)power[i];
            }

            chart1.RangeX = new DoubleRange(freqv[0], freqv[freqv.Length - 1] / hScrollBar1.Value);
            chart1.RangeY = new DoubleRange(0f, Math.Pow(10, -vScrollBar1.Value));

            chart1.UpdateWaveform("fft", g);
        }
 /// <summary>
 ///   This method will be called whenever there is a new input audio frame 
 ///   to be processed. This would be the case for samples arriving at the 
 ///   computer's microphone
 /// </summary>
 /// 
 private void source_NewFrame(object sender, NewFrameEventArgs eventArgs)
 {
     this.encoder.addNewFrame(eventArgs.Signal);
     updateWaveform(this.encoder.current, eventArgs.Signal.Length);
 }
Esempio n. 3
0
 private void source_NewFrame(object sender, NewFrameEventArgs e)
 {
     IAudioSource source = sender as IAudioSource;
     int index = (int)source.UserData;
     signals[index] = e.Signal;
     stopEvents[index].Set();
 }
Esempio n. 4
0
        /// <summary>
        ///   This method will be called whenever there is a new input audio frame 
        ///   to be processed. This would be the case for samples arriving at the 
        ///   computer's microphone
        /// </summary>
        /// 
        private void source_NewFrame(object sender, NewFrameEventArgs eventArgs)
        {
            // Save current frame
            eventArgs.Signal.CopyTo(current);

            // Update waveform
            updateWaveform(current, eventArgs.Signal.Length);

            // Save to memory
            encoder.Encode(eventArgs.Signal);

            // Update counters
            duration += eventArgs.Signal.Duration;
            samples += eventArgs.Signal.Samples;
            frames += eventArgs.Signal.Length;
        }
Esempio n. 5
0
        /// <summary>
        ///   This method will be called whenever there is a new audio
        ///   frame to be processed.
        /// </summary>
        /// 
        void source_NewFrame(object sender, NewFrameEventArgs eventArgs)
        {
            // We can start by converting the audio frame to a complex signal
            ComplexSignal signal = ComplexSignal.FromSignal(eventArgs.Signal);

            // If its needed,
            if (window != null)
            {
                // Apply the chosen audio window
                signal = window.Apply(signal, 0);
            }

            // Transform to the complex domain
            signal.ForwardFourierTransform();

            // Now we can get the power spectrum output and its
            // related frequency vector to plot our spectrometer.

            Complex[] channel = signal.GetChannel(0);
            double[] power = Accord.Audio.Tools.GetPowerSpectrum(channel);
            double[] freqv = Accord.Audio.Tools.GetFrequencyVector(signal.Length, signal.SampleRate);

            power[0] = 0; // zero DC
            float[] g = new float[power.Length];
            for (int i = 0; i < power.Length; i++)
                g[i] = (float)power[i];

            // Adjust the zoom according to the horizontal and vertical scrollbars.
            chart1.RangeX = new DoubleRange(freqv[0], freqv[freqv.Length - 1] / hScrollBar1.Value);
            chart1.RangeY = new DoubleRange(0f, Math.Pow(10, -vScrollBar1.Value));

            chart1.UpdateWaveform("fft", g);
        }
Esempio n. 6
0
        void source_NewFrame(object sender, NewFrameEventArgs eventArgs)
        {
            current = eventArgs.Signal;


            detector.Detect(current);

            if (initializing)
            {
                initializing = false;
                lbStatus.Invoke((MethodInvoker)delegate()
                {
                    label1.Text = "Frame duration (ms): " + current.Duration;
                    lbStatus.Text = "Ready";
                });
            } 
        }
        void source_NewFrame(object sender, NewFrameEventArgs eventArgs)
        {
            // We can start by converting the audio frame to a complex signal
            var signal = ComplexSignal.FromSignal(eventArgs.Signal);

            // If its needed,
            if (window != null)
            {
                // Apply the chosen audio window
                signal = window.Apply(signal, 0);
            }

            // Transform to the complex domain
            signal.ForwardFourierTransform();

            // Now we can get the power spectrum output and its
            // related frequency vector to plot our spectrometer.
            Complex[] channel = signal.GetChannel(0);

            double[] power = Accord.Audio.Tools.GetPowerSpectrum(channel);

            ListOfPowerSpectrum.Add(power);

            foreach (double value in power)
            {
                if (value != 0.0 && value > 1.0E-10)
                {
                    //Console.WriteLine("Index to {0}", ListOfPowerSpectrum.IndexOf(power));
                    soundsDetectedIndexes.Add(ListOfPowerSpectrum.IndexOf(power));
                    break;
                }
            }
        }