огшор
Dependencies: CMSIS_DSP_401 mbed
Fork of fir_f32 by
Diff: main.cpp
- Revision:
- 5:bd3887263120
- Parent:
- 4:397e8f4699df
--- a/main.cpp Thu Oct 23 15:58:45 2014 +0000 +++ b/main.cpp Thu Nov 13 17:39:05 2014 +0000 @@ -9,10 +9,13 @@ uint8_t ifftFlag, uint8_t bitReverseFlag); -Serial pc(USBTX, USBRX); +Serial pc(USBTX, USBRX);//:D ПРИВЕТ!!!! + + AnalogIn left(A2); AnalogIn right(A3); +AnalogIn center(A3); int SAMPLE_RATE_HZ = 40000; // Sample rate of the audio in hertz. const int FFT_SIZE = 16; // Size of the FFT. @@ -21,16 +24,26 @@ //static arm_cfft_radix2_instance_f32 *S; Ticker samplingTimer; float samples[FFT_SIZE*2]; +float samples2[FFT_SIZE*2]; +float samples3[FFT_SIZE*2]; + float magnitudes[FFT_SIZE]; +float magnitudes2[FFT_SIZE]; +float magnitudes3[FFT_SIZE]; int sampleCounter = 0; + void samplingCallback() { // Read from the ADC and store the sample data samples[sampleCounter] = 1000*left.read(); + samples2[sampleCounter] = 1000*left.read(); + samples3[sampleCounter] = 1000*left.read(); // Complex FFT functions require a coefficient for the imaginary part of the input. // Since we only have real data, set this coefficient to zero. samples[sampleCounter+1] = 0.0; + samples2[sampleCounter+1] = 0.0; + samples3[sampleCounter+1] = 0.0; // Update sample buffer position and stop after the buffer is filled sampleCounter += 2; @@ -89,10 +102,17 @@ break; } float maxValue = 0.0f; + float maxValue2 = 0.0f; + float maxValue3 = 0.0f; + unsigned int testIndex = 0; + unsigned int testIndex2 = 0; + unsigned int testIndex3 = 0; // Begin sampling audio samplingBegin(); + + pc.printf(" MAX value a"); while(1) { @@ -102,20 +122,30 @@ // Run FFT on sample data. //arm_cfft_radix2_f32(arm_cfft_radix2_instance_f32*S, samples); arm_cfft_f32(S, samples, 0, 1); - samples[0] = 0; + samples[0]=0; + samples2[0]=0; + samples3[0]=0; + /* Initialize the CFFT/CIFFT module */ //arm_cfft_radix2_init_f32(S, 128, 0, 1); //arm_cfft_radix2_f32(S, samples); - for(int i = 0;i < FFT_SIZE*2;++i) - pc.printf(" Samples[%d]: %8.2f ",i,samples[i]); - pc.printf("\r\n"); + //for(int i = 0;i < FFT_SIZE*2;++i) + // pc.printf(" Samples[%d]: %8.2f ",i,samples[i]); + //pc.printf("\r\n"); // Calculate magnitude of complex numbers output by the FFT. arm_cmplx_mag_f32(samples, magnitudes, FFT_SIZE); - for(int i = 0;i < FFT_SIZE;++i) - pc.printf(" Magnitude: %d = %8.2f ;", i, magnitudes[i]); - pc.printf(" \r\n"); + arm_cmplx_mag_f32(samples2, magnitudes2, FFT_SIZE); + arm_cmplx_mag_f32(samples3, magnitudes3, FFT_SIZE); + + //for(int i = 0;i < FFT_SIZE;++i) + // pc.printf(" Magnitude: %d = %8.2f ;", i, magnitudes[i]); + //pc.printf(" \r\n"); arm_max_f32(magnitudes, FFT_SIZE, &maxValue, &testIndex); - pc.printf(" MAX value at magnitudes[%d] : %+8.2f\r\n", testIndex, maxValue); + arm_max_f32(magnitudes2, FFT_SIZE, &maxValue2, &testIndex2); + arm_max_f32(magnitudes3, FFT_SIZE, &maxValue3, &testIndex3); + pc.printf(" MAX value at magnitudes 1[%d] : %+8.2f\r\n", testIndex, maxValue);//Я НЯШКА А АНЯ ВЛАСЮК КОЗА:DDDDDDDDDDDDD + //pc.printf(" MAX value at magnitudes 2[%d] : %+8.2f\r\n", testIndex2, maxValue2); + //pc.printf(" MAX value at magnitudes 3[%d] : %+8.2f\r\n", testIndex2, maxValue3); // Wait for user confirmation to restart audio sampling. //pc.getc(); wait(1);