コード例 #1
0
 private void FftCalculated(object sender, FftEventArgs e)
 {
     Bass = 0f;
     Complex[] res = e.Result;
     for(int i = 20; i < 60; i++) {
         Bass += res[i].X;
         Bass /= 2;
     }
 }
コード例 #2
0
ファイル: SampleAggregator.cs プロジェクト: Magicpig55/MMP
 public SampleAggregator(int fftLength)
 {
     if (!IsPowerOfTwo(fftLength)) {
         throw new ArgumentException("FFT Length must be a power of two");
     }
     this.m = (int)Math.Log(fftLength, 2.0);
     this.fftLength = fftLength;
     this.fftBuffer = new Complex[fftLength];
     this.fftArgs = new FftEventArgs(fftBuffer);
 }
コード例 #3
0
	public SampleAggregator(int fftLength)
	{
		if (!IsPowerOfTwo(fftLength))
		{
			throw new ArgumentException("Wielokrotność 2 !!!");
		}
		this.m = (int)Math.Log(fftLength, 2.0);
		this.fftLength = fftLength;
		this.fftBuffer = new Complex[fftLength];
		this.fftArgs = new FftEventArgs(fftBuffer);
	}
コード例 #4
0
ファイル: Form1.cs プロジェクト: JonasVanGool/DMXSound
        void FftCalculated(object sender, FftEventArgs e)
        {
            double sumFreq1 = 0;
            double sumFreq2 = 0;
            double sumFreq3 = 0;
            double temp = 0;
            FftChart.Series[fft].Points.Clear();
            for (var i = 0; i < e.Result.Length/2; i++)
            {
                temp = Math.Sqrt(e.Result[i].X * e.Result[i].X + e.Result[i].Y * e.Result[i].Y);
                if (i < 3)
                {
                    sumFreq1 = sumFreq1 + temp;
                }else if(i<10){
                    sumFreq2 = sumFreq2 + temp;
                }
                else
                {
                    sumFreq3 = sumFreq3 + temp;
                }

                FftChart.Series[fft].Points.AddY(temp);
            }
            if (counter2 > 100)
            {
                SumFreq1Chart.Series[sumFreq1series].Points.Remove(SumFreq1Chart.Series[sumFreq1series].Points.First());
                SumFreq2Chart.Series[sumFreq2series].Points.Remove(SumFreq2Chart.Series[sumFreq2series].Points.First());
                SumFreq3Chart.Series[sumFreq3series].Points.Remove(SumFreq3Chart.Series[sumFreq3series].Points.First());
            }
            else
            {
                counter2++;
            }
            SumFreq1Chart.Series[sumFreq1series].Points.AddY(sumFreq1);
            SumFreq2Chart.Series[sumFreq2series].Points.AddY(sumFreq2);
            SumFreq3Chart.Series[sumFreq3series].Points.AddY(sumFreq3);
        }
コード例 #5
0
		void FftCalculated(object sender, FftEventArgs fftEvent)
		{
			double[] spectrumData = CalculateSpectrum(fftEvent.Result);
			
			dataBuffer.Enqueue(spectrumData);	

			if (dataBuffer.Count<double[]>() >= bufferLenght)
			{
				double[] average = new double[spectrumData.Length];               
				for (int i = 0; i < spectrumData.Length; i++)
				{
					average[i] = dataBuffer.Sum<double[]>( (x) => x[i] ) / dataBuffer.Count<double[]>();
                    //if (average.Max((x) => Math.Abs(x)) > temp)
                    //{
                    //    temp = average.Max((x) => Math.Abs(x));
                    //}
                }
                while (dataBuffer.Count<double[]>() != bufferLenght) dataBuffer.Dequeue();
                

                //double[] spectrumBars = SpectrumBars(average);
				SpectrumCalculated.Invoke(average);	
			}			
		}