FFT_BUENA
Dependencies: FastAnalogIn HSI2RGBW_PWM NVIC_set_all_priorities mbed-dsp mbed
Fork of KL25Z_FFT_Demo by
Revision 1:736b34e0f484, committed 2014-03-08
- Comitter:
- frankvnk
- Date:
- Sat Mar 08 18:56:14 2014 +0000
- Parent:
- 0:0c037aff5039
- Child:
- 2:035d551759a5
- Commit message:
- Replaced AnalogIn with FastAnalogIn
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/FastAnalogIn.lib Sat Mar 08 18:56:14 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/Sissors/code/FastAnalogIn/#a9b753c25073
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/arm_const_structs.h Sat Mar 08 18:56:14 2014 +0000 @@ -0,0 +1,86 @@ +/* ---------------------------------------------------------------------- +* Copyright (C) 2010-2013 ARM Limited. All rights reserved. +* +* $Date: 17. January 2013 +* $Revision: V1.4.1 +* +* Project: CMSIS DSP Library +* Title: arm_const_structs.h +* +* Description: This file has constant structs that are initialized for +* user convenience. For example, some can be given as +* arguments to the arm_cfft_f32() function. +* +* Target Processor: Cortex-M4/Cortex-M3 +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions +* are met: +* - Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* - Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in +* the documentation and/or other materials provided with the +* distribution. +* - Neither the name of ARM LIMITED nor the names of its contributors +* may be used to endorse or promote products derived from this +* software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +* POSSIBILITY OF SUCH DAMAGE. +* -------------------------------------------------------------------- */ + +#ifndef _ARM_CONST_STRUCTS_H +#define _ARM_CONST_STRUCTS_H + +#include "arm_math.h" +#include "arm_common_tables.h" + + const arm_cfft_instance_f32 arm_cfft_sR_f32_len16 = { + 16, twiddleCoef_16, armBitRevIndexTable16, ARMBITREVINDEXTABLE__16_TABLE_LENGTH + }; + + const arm_cfft_instance_f32 arm_cfft_sR_f32_len32 = { + 32, twiddleCoef_32, armBitRevIndexTable32, ARMBITREVINDEXTABLE__32_TABLE_LENGTH + }; + + const arm_cfft_instance_f32 arm_cfft_sR_f32_len64 = { + 64, twiddleCoef_64, armBitRevIndexTable64, ARMBITREVINDEXTABLE__64_TABLE_LENGTH + }; + + const arm_cfft_instance_f32 arm_cfft_sR_f32_len128 = { + 128, twiddleCoef_128, armBitRevIndexTable128, ARMBITREVINDEXTABLE_128_TABLE_LENGTH + }; + + const arm_cfft_instance_f32 arm_cfft_sR_f32_len256 = { + 256, twiddleCoef_256, armBitRevIndexTable256, ARMBITREVINDEXTABLE_256_TABLE_LENGTH + }; + + const arm_cfft_instance_f32 arm_cfft_sR_f32_len512 = { + 512, twiddleCoef_512, armBitRevIndexTable512, ARMBITREVINDEXTABLE_512_TABLE_LENGTH + }; + + const arm_cfft_instance_f32 arm_cfft_sR_f32_len1024 = { + 1024, twiddleCoef_1024, armBitRevIndexTable1024, ARMBITREVINDEXTABLE1024_TABLE_LENGTH + }; + + const arm_cfft_instance_f32 arm_cfft_sR_f32_len2048 = { + 2048, twiddleCoef_2048, armBitRevIndexTable2048, ARMBITREVINDEXTABLE2048_TABLE_LENGTH + }; + + const arm_cfft_instance_f32 arm_cfft_sR_f32_len4096 = { + 4096, twiddleCoef_4096, armBitRevIndexTable4096, ARMBITREVINDEXTABLE4096_TABLE_LENGTH + }; + +#endif +
--- a/main.cpp Tue Feb 25 17:42:59 2014 +0000 +++ b/main.cpp Sat Mar 08 18:56:14 2014 +0000 @@ -7,11 +7,11 @@ #include <ctype.h> #include "arm_math.h" #include "hsi2rgbw_pwm.h" +#include "FastAnalogIn.h" Serial pc(USBTX, USBRX); -AnalogIn left(PTC2); -AnalogIn right(PTB3); +FastAnalogIn Audio(PTC2); //#define RGBW_ext // Disable this line when you want to use the KL25Z on-board RGB LED. @@ -44,17 +44,17 @@ // Max allowed FFT_SIZE is 16 //////////////////////////////////////////////////////////////////////////////// -int SLOWDOWN = 16; // Create an optical delay in spectrumLoop - useful when only one RGB led is used. +int SLOWDOWN = 3; // Create an optical delay in spectrumLoop - useful when only one RGB led is used. // Only active when nonzero. // A value >= 1000 and <= 1000 + PIXEL_COUNT fixes the output to a single frequency // window = a single color. int SAMPLE_RATE_HZ = 40000; // Sample rate of the audio in hertz. -float SPECTRUM_MIN_DB = 30.0; // Audio intensity (in decibels) that maps to low LED brightness. -float SPECTRUM_MAX_DB = 60.0; // Audio intensity (in decibels) that maps to high LED brightness. +float SPECTRUM_MIN_DB = 40.0; // Audio intensity (in decibels) that maps to low LED brightness. +float SPECTRUM_MAX_DB = 80.0; // Audio intensity (in decibels) that maps to high LED brightness. int LEDS_ENABLED = 1; // Control if the LED's should display the spectrum or not. 1 is true, 0 is false. // Useful for turning the LED display on and off with commands from the serial port. -const int FFT_SIZE = 16; // Size of the FFT. -const int PIXEL_COUNT = 8; // Number of pixels. You should be able to increase this without +const int FFT_SIZE = 64; // Size of the FFT. +const int PIXEL_COUNT = 32; // Number of pixels. You should be able to increase this without // any other changes to the program. const int MAX_CHARS = 65; // Max size of the input command buffer @@ -192,7 +192,7 @@ void samplingCallback() { // Read from the ADC and store the sample data - samples[sampleCounter] = 1023 * ((left + right)/2); + samples[sampleCounter] = (1023 * Audio) - 511.0f; // 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;