PK þÞq• • ) FFT Audio Analysis\FFT Audio Analysis.mcp[HEADER]
magic_cookie={66E99B07-E706-4689-9E80-9B2582898A13}
file_version=1.0
device=PIC18F4550
[PATH_INFO]
BuildDirPolicy=BuildDirIsProjectDir
dir_src=
dir_bin=
dir_tmp=
dir_sin=
dir_inc=
dir_lib=
dir_lkr=
[CAT_FILTERS]
filter_src=*.c;*.as;*.asm;*.usb
filter_inc=*.h;
filter_obj=*.obj;*.p1;*.hex
filter_lib=*.lib;*.lpp
filter_lkr=*.unknown
[CAT_SUBFOLDERS]
subfolder_src=
subfolder_inc=
subfolder_obj=
subfolder_lib=
subfolder_lkr=
[FILE_SUBFOLDERS]
file_000=.
file_001=.
file_002=.
file_003=.
file_004=.
file_005=.
[GENERATED_FILES]
file_000=no
file_001=no
file_002=no
file_003=no
file_004=no
file_005=no
[OTHER_FILES]
file_000=no
file_001=no
file_002=no
file_003=no
file_004=no
file_005=no
[FILE_INFO]
file_000=main.c
file_001=fft.c
file_002=graph.c
file_003=hardware.h
file_004=fft.h
file_005=graph.h
[SUITE_INFO]
suite_guid={507D93FD-16F1-4270-980F-0C7C0207E6D3}
suite_state=
[TOOL_SETTINGS]
TS{3FF1D5F2-E530-4850-9F70-F61D55BD1AC9}=C9=5,4,3,2,1
TS{3FF1D5F2-E530-4850-9F70-F61D55BD1AC9}_alt=yes
TS{3FF1D5F2-E530-4850-9F70-F61D55BD1AC9}000=
TS{3FF1D5F2-E530-4850-9F70-F61D55BD1AC9}000_alt=yes
TS{3FF1D5F2-E530-4850-9F70-F61D55BD1AC9}001=
TS{3FF1D5F2-E530-4850-9F70-F61D55BD1AC9}001_alt=yes
TS{3FF1D5F2-E530-4850-9F70-F61D55BD1AC9}002=
TS{3FF1D5F2-E530-4850-9F70-F61D55BD1AC9}002_alt=yes
[ACTIVE_FILE_SETTINGS]
TS{3FF1D5F2-E530-4850-9F70-F61D55BD1AC9}000_active=yes
TS{3FF1D5F2-E530-4850-9F70-F61D55BD1AC9}001_active=yes
TS{3FF1D5F2-E530-4850-9F70-F61D55BD1AC9}002_active=yes
[INSTRUMENTED_TRACE]
enable=0
transport=0
format=0
[CUSTOM_BUILD]
Pre-Build=
Pre-BuildEnabled=1
Post-Build=
Post-BuildEnabled=1
PK 9‰ÁK K FFT Audio Analysis\main.c/************************************************************************
main.c
FFT Audio Analysis
Copyright (C) 2011 Simon Inns
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Email: simon.inns@gmail.com
************************************************************************/
#ifndef MAIN_C
#define MAIN_C
// Global includes
#include
#include
// Local includes
#include "hardware.h"
#include "fft.h"
#include "graph.h"
// PIC18F4550/PIC18F2550 fuse configuration:
// Config word 1 (Oscillator configuration)
// 20Mhz crystal input scaled to 48Mhz and configured for USB operation
__CONFIG(1, USBPLL & IESODIS & FCMDIS & HSPLL & CPUDIV1 & PLLDIV5);
// Config word 2
__CONFIG(2, VREGEN & PWRTDIS & BORDIS & BORV20 & WDTDIS & WDTPS32K);
// Config word 3
__CONFIG(3, PBDIGITAL & LPT1DIS & MCLREN);
// Config word 4
__CONFIG(4, XINSTDIS & STVREN & LVPDIS & ICPORTDIS & DEBUGDIS);
// Config word 5, 6 and 7 (protection configuration)
__CONFIG(5, UNPROTECT);
__CONFIG(6, UNPROTECT);
__CONFIG(7, UNPROTECT);
// Globals
short imaginaryNumbers[64];
short realNumbers[64];
void main(void)
{
// PIC port set up --------------------------------------------------------
// Configure on-board ADC
// Vss and Vdd as voltage references
ADCON1 = 0b00001110;
// Configure the ADC acquisition time according to the datasheet
ADCON2 = 0b10110110; // Note: output is right justified
// Configure ports as inputs (1) or outputs(0)
// 76543210
TRISA = 0b00000001;
TRISB = 0b00000000;
TRISC = 0b00000011;
TRISD = 0b00000000;
TRISE = 0b00000000;
// Clear all ports
// 76543210
PORTA = 0b00000000;
PORTB = 0b00000000;
PORTC = 0b00000000;
PORTD = 0b00000000;
PORTE = 0b00000000;
RE0 = 0;
RE1 = 0;
RE2 = 0;
// Initialise the gLCD
gLcdInit();
gLcdClear();
while(1)
{
// Perform the FFT
// Get 64 samples at 50uS intervals
// 50uS means our sampling rate is 20KHz which gives us
// Nyquist limit of 10Khz
short i = 0;
unsigned short result;
for (i = 0; i < 64; i++)
{
// Perform the ADC conversion
// Select the desired ADC and start the conversion
ADCON0 = 0b00000011; // Start the ADC conversion on AN0
// Wait for the ADC conversion to complete
TESTPIN_W4 = 1; // Don't remove this... it will affect the sample timing
while(GODONE);
TESTPIN_W4 = 0; // Don't remove this... it will affect the sample timing
// Get the 10-bit ADC result and adjust the virtual ground of 2.5V
// back to 0Vs to make the input wave centered correctly around 0
// (i.e. -512 to +512)
realNumbers[i] = ((short)(ADRESH << 8) + (short)ADRESL) - 512;
// Set the imaginary number to zero
imaginaryNumbers[i] = 0;
// This delay is calibrated using an oscilloscope according to the
// output on RA1 to ensure that the sampling periods are correct
// given the overhead of the rest of the code and the ADC sampling
// time.
//
// If you change anything in this loop or use the professional
// (optimised) version of Hi-Tech PICC18, you will need to re-
// calibrate this to achieve an accurate sampling rate.
__delay_us(7);
}
// Perform the (forward) FFT calculation
// Note: the FFT result length is half of the input data length
// so if we put 64 samples in we get 32 buckets out. The first bucket
// cannot be used so in reality our result is 31 buckets.
//
// The maximum frequency we can measure is half of the sampling rate
// so if we sample at 20Khz our maximum is 10Khz (this is called the
// Nyquist frequency). So if we have 32 buckets divided over 10Khz,
// each bucket represents 312.5Khz of range, so our lowest bucket is
// (bucket 1) 312.5Hz - 625Hz and so on up to our 32nd bucket which
// is 9687.5Hz - 10,000Hz
// 1 : 312.5 - 625
// 2 : 625 - 937.5
// 3 : 937.5 - 1250
// 4 : 1250 - 1562.5
// 5 : 1562.5 - 1875
// 6 : 1875 - 2187.5
// 7 : 2187.5 - 2500
// 8 : 2500 - 2812.5
// 9 : 2812.5 - 3125
// 10 : 3125 - 3437.5
// 11 : 3437.5 - 3750
// 12 : 3750 - 4062.5
// 13 : 4062.5 - 4375
// 14 : 4375 - 4687.5
// 15 : 4687.5 - 5000
// 16 : 5000 - 5312.5
// 17 : 5312.5 - 5625
// 18 : 5625 - 5937.5
// 19 : 5937.5 - 6250
// 20 : 6250 - 6562.5
// 21 : 6562.5 - 6875
// 22 : 6875 - 7187.5
// 23 : 7187.5 - 7500
// 24 : 7500 - 7812.5
// 25 : 7812.5 - 8125
// 26 : 8125 - 8437.5
// 27 : 8437.5 - 8750
// 28 : 8750 - 9062.5
// 29 : 9062.5 - 9375
// 30 : 9375 - 9687.5
// 31 : 9687.5 - 10000
// Note: the '6' is the size of the input data (2 to the power of 6 = 64)
TESTPIN_W5 = 1;
fix_fft(realNumbers, imaginaryNumbers, 6);
// Take the absolute value of the FFT results
// Note: The FFT routine returns 'complex' numbers which consist of
// both a real and imaginary part. To find the 'absolute' value
// of the returned data we have to calculate the complex number's
// distance from zero which requires a little pythagoras and therefore
// a square-root calculation too. Since the PIC has multiplication
// hardware, only the square-root needs to be optimised.
long place, root;
for (int k=0; k < 32; k++)
{
realNumbers[k] = (realNumbers[k] * realNumbers[k] +
imaginaryNumbers[k] * imaginaryNumbers[k]);
// Now we find the square root of realNumbers[k] using a very
// fast (but compiler dependent) integer approximation:
// (adapted from: http://www.codecodex.com/wiki/Calculate_an_integer_square_root)
place = 0x40000000;
root = 0;
if (realNumbers[k] >= 0) // Ensure we don't have a negative number
{
while (place > realNumbers[k]) place = place >> 2;
while (place)
{
if (realNumbers[k] >= root + place)
{
realNumbers[k] -= root + place;
root += place * 2;
}
root = root >> 1;
place = place >> 2;
}
}
realNumbers[k] = root;
}
TESTPIN_W5 = 0;
// Now we have 32 buckets of audio frequency data represented as
// linear intensity in realNumbers[]
//
// Since the maximum input value (in theory) to the SQRT function is
// 32767, the peak output at this stage is SQRT(32767) = 181.
// Draw a bar graph of the FFT output data
TESTPIN_W6 = 1;
drawFftGraph(realNumbers);
TESTPIN_W6 = 0;
}
}
#endifPK @sf¥} } FFT Audio Analysis\fft.c/************************************************************************
fft.c
FFT Audio Analysis
Copyright (C) 2011 Simon Inns
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Email: simon.inns@gmail.com
************************************************************************/
#ifndef FFT_C
#define FFT_C
#include
#include "fft.h"
// fix_fft.c - Fixed-point in-place Fast Fourier Transform
// All data are fixed-point short integers, in which -32768
// to +32768 represent -1.0 to +1.0 respectively. Integer
// arithmetic is used for speed, instead of the more natural
// floating-point.
//
// For the forward FFT (time -> freq), fixed scaling is
// performed to prevent arithmetic overflow, and to map a 0dB
// sine/cosine wave (i.e. amplitude = 32767) to two -6dB freq
// coefficients.
//
// Written by: Tom Roberts 11/8/89
// Made portable: Malcolm Slaney 12/15/94 malcolm@interval.com
// Enhanced: Dimitrios P. Bouras 14 Jun 2006 dbouras@ieee.org
// Ported to PIC18F: Simon Inns 20110104
/*
fix_fft() - perform forward fast Fourier transform.
fr[n],fi[n] are real and imaginary arrays, both INPUT AND
RESULT (in-place FFT), with 0 <= n < 2**m
*/
void fix_fft(short fr[], short fi[], short m)
{
long int mr = 0, nn, i, j, l, k, istep, n, shift;
short qr, qi, tr, ti, wr, wi;
n = 1 << m;
nn = n - 1;
/* max FFT size = N_WAVE */
//if (n > N_WAVE) return -1;
/* decimation in time - re-order data */
for (m=1; m<=nn; ++m)
{
l = n;
do
{
l >>= 1;
} while (mr+l > nn);
mr = (mr & (l-1)) + l;
if (mr <= m) continue;
tr = fr[m];
fr[m] = fr[mr];
fr[mr] = tr;
ti = fi[m];
fi[m] = fi[mr];
fi[mr] = ti;
}
l = 1;
k = LOG2_N_WAVE-1;
while (l < n)
{
/*
fixed scaling, for proper normalization --
there will be log2(n) passes, so this results
in an overall factor of 1/n, distributed to
maximize arithmetic accuracy.
It may not be obvious, but the shift will be
performed on each data point exactly once,
during this pass.
*/
// Variables for multiplication code
long int c;
short b;
istep = l << 1;
for (m=0; m>= 1;
wi >>= 1;
for (i=m; i> 14;
b = c & 0x01;
tr = (c >> 1) + b;
c = ((long int)wi * (long int)fi[j]);
c = c >> 14;
b = c & 0x01;
tr = tr - ((c >> 1) + b);
// ti = FIX_MPY(wr,fi[j]) + FIX_MPY(wi,fr[j]);
c = ((long int)wr * (long int)fi[j]);
c = c >> 14;
b = c & 0x01;
ti = (c >> 1) + b;
c = ((long int)wi * (long int)fr[j]);
c = c >> 14;
b = c & 0x01;
ti = ti + ((c >> 1) + b);
qr = fr[i];
qi = fi[i];
qr >>= 1;
qi >>= 1;
fr[j] = qr - tr;
fi[j] = qi - ti;
fr[i] = qr + tr;
fi[i] = qi + ti;
}
}
--k;
l = istep;
}
}
#endif
PK ZÝj¤ª ª FFT Audio Analysis\graph.c/************************************************************************
graph.c
FFT Audio Analysis
Copyright (C) 2011 Simon Inns
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Email: simon.inns@gmail.com
************************************************************************/
#ifndef GRAPH_C
#define GRAPH_C
// Global includes
#include
// Local includes
#include "hardware.h"
#include "graph.h"
// Write a byte directly to the screen hardware (quick version)
void fLcdWrite(unsigned char cmdType, unsigned char bank, unsigned char byte)
{
// Wait for the busy flag to clear
GLCD_DATADIRECTION = GLCD_READ;
GLCD_RW = READ;
GLCD_RS = GLCD_CMD;
do
{
// Strobe the EN line
GLCD_EN = 1;
__delay_us(ENSTROBEDELAY);
GLCD_EN = 0;
} while (GLCD_DB7 == 1);
// Select the command type
GLCD_RS = cmdType;
// Select the screen bank
if (bank == 0)
{
GLCD_CS1 = 1;
GLCD_CS2 = 0;
}
else
{
GLCD_CS1 = 0;
GLCD_CS2 = 1;
}
// Place the byte on the databus
GLCD_DATADIRECTION = GLCD_WRITE;
GLCD_RW = WRITE;
GLCD_DATABUS = byte;
// Strobe the EN line
GLCD_EN = 1;
__delay_us(ENSTROBEDELAY);
GLCD_EN = 0;
}
// Global to hold the display data (required for output damping)
short displayData[32];
// Plot the output graph
void drawFftGraph(short inputData[])
{
short inputValue;
// Scale the input data to 0-63 and perform the dampening of the display
for (unsigned char counter = 1; counter < 32; counter++)
{
// Scale the input data for the display (linear) x1 or x8
if (SWITCH0 == 0) inputValue = inputData[counter] * 8;
else inputValue = inputData[counter];
if (inputValue > 181) inputValue = 181;
// Apply a linear or logarithmic conversion on the data
if (SWITCH1 == 0) inputValue = (short)logTable[inputValue];
else inputValue = (short)linTable[inputValue];
// Perform damping on the displayed output
if (inputValue > displayData[counter]) displayData[counter] = inputValue;
else displayData[counter] -= 10;
if (displayData[counter] < 0) displayData[counter] = 0;
}
// Our FFT animation speed is dependent on how fast the LCD can
// be updated, so here we use a bargraph drawing routine which
// is highly optimised to the manner in which the LCD is updated.
unsigned char xByte, requiredY, y, pointer;
for (y = 0; y < 8; y++)
{
// Move to the correct screen page
// Left bank
fLcdWrite(GLCD_CMD, 0, y | 0b10111000);
fLcdWrite(GLCD_CMD, 0, 0b01000000);
// Right bank
fLcdWrite(GLCD_CMD, 1, y | 0b10111000);
fLcdWrite(GLCD_CMD, 1, 0b01000000);
unsigned char xPos = 0;
// We only draw buckets 1 to 31 (bucket 0 is invalid)
for (pointer = 0; pointer < 32; pointer++)
{
xByte = 0;
requiredY = 63 - displayData[pointer];
// Either fill the whole byte or
// left shift according to the remainder of
// the division to get the right number of pixels
if (requiredY <= y * 8) xByte = 0b11111111;
else if (requiredY / 8 <= y) xByte = 0b11111111 << (requiredY % 8);
if (xPos < 64) fLcdWrite(GLCD_DATA, 0, xByte); // 1/3 of bar
else fLcdWrite(GLCD_DATA, 1, xByte);
xPos++;
if (xPos < 64) fLcdWrite(GLCD_DATA, 0, xByte); // 1/3 of bar
else fLcdWrite(GLCD_DATA, 1, xByte);
xPos++;
if (xPos < 64) fLcdWrite(GLCD_DATA, 0, xByte); // 1/3 of bar
else fLcdWrite(GLCD_DATA, 1, xByte);
xPos++;
if (xPos < 64) fLcdWrite(GLCD_DATA, 0, 0x00); // gap
else fLcdWrite(GLCD_DATA, 1, 0x00);
xPos++;
}
}
}
// Initialise the gLCD
void gLcdInit(void)
{
// Bring the display out of reset
//GLCD_RES = 0; // Screen in reset
__delay_us(250);
//GLCD_RES = 1; // Screen out of reset
__delay_us(250);
// Set Y Address = 0
fLcdWrite(GLCD_CMD, 0, 0b01000000);
fLcdWrite(GLCD_CMD, 1, 0b01000000);
// Set X Address = 0
fLcdWrite(GLCD_CMD, 0, 0b10111000);
fLcdWrite(GLCD_CMD, 1, 0b10111000);
// Set Display start line = 0
fLcdWrite(GLCD_CMD, 0, 0b11000000);
fLcdWrite(GLCD_CMD, 1, 0b11000000);
// Turn the display ON
fLcdWrite(GLCD_CMD, 0, 0b00111111);
fLcdWrite(GLCD_CMD, 1, 0b00111111);
}
// Clear the gLCD to black (zero)
void gLcdClear(void)
{
unsigned char x, y;
for (y = 0; y < 8; y++)
{
// Move to the correct screen page
fLcdWrite(GLCD_CMD, 0, y | 0b10111000);
fLcdWrite(GLCD_CMD, 0, 0b01000000);
fLcdWrite(GLCD_CMD, 1, y | 0b10111000);
fLcdWrite(GLCD_CMD, 1, 0b01000000);
for (x = 0; x < 64; x++)
{
fLcdWrite(GLCD_DATA, 0, 0x00);
fLcdWrite(GLCD_DATA, 1, 0x00);
}
}
}
#endifPK ²ÛÜ… FFT Audio Analysis\hardware.h/************************************************************************
hardware.h
FFT Audio Analysis
Copyright (C) 2011 Simon Inns
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Email: simon.inns@gmail.com
************************************************************************/
#ifndef _HARDWARE_H_
#define _HARDWARE_H_
// Fosc frequency (48 Mhz)
#define _XTAL_FREQ 48000000
#define OFF 0
#define ON 1
#define TOGGLE 2
#define TRUE 1
#define FALSE 0
#define READ 1
#define WRITE 0
// Hardware mapping definitions
// gLCD character display hardware
#define GLCD_DB0 RD0
#define GLCD_DB1 RD1
#define GLCD_DB2 RD2
#define GLCD_DB3 RD3
#define GLCD_DB4 RD4
#define GLCD_DB5 RD5
#define GLCD_DB6 RD6
#define GLCD_DB7 RD7
#define GLCD_DATABUS PORTD
#define GLCD_DATADIRECTION TRISD
#define GLCD_RS RB0
#define GLCD_RW RB1
#define GLCD_EN RB2
#define GLCD_CS1 RB3
#define GLCD_CS2 RB4
#define LED0 RE0
#define LED1 RE1
#define LED2 RE2
#define TESTPIN_W4 RA1
#define TESTPIN_W5 RA2
#define TESTPIN_W6 RA3
#define SWITCH0 RC0
#define SWITCH1 RC1
#endifPK h(r| | FFT Audio Analysis\fft.h/************************************************************************
fft.h
FFT Audio Analysis
Copyright (C) 2011 Simon Inns
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Email: simon.inns@gmail.com
************************************************************************/
#ifndef _FFT_H
#define _FFT_H
// Definitions
#define N_WAVE 1024 // full length of Sinewave[]
#define LOG2_N_WAVE 10 // log2(N_WAVE)
// Since we only use 3/4 of N_WAVE, we define only
// this many samples, in order to conserve data space.
const short Sinewave[N_WAVE-N_WAVE/4] = {
0, 201, 402, 603, 804, 1005, 1206, 1406,
1607, 1808, 2009, 2209, 2410, 2610, 2811, 3011,
3211, 3411, 3611, 3811, 4011, 4210, 4409, 4608,
4807, 5006, 5205, 5403, 5601, 5799, 5997, 6195,
6392, 6589, 6786, 6982, 7179, 7375, 7571, 7766,
7961, 8156, 8351, 8545, 8739, 8932, 9126, 9319,
9511, 9703, 9895, 10087, 10278, 10469, 10659, 10849,
11038, 11227, 11416, 11604, 11792, 11980, 12166, 12353,
12539, 12724, 12909, 13094, 13278, 13462, 13645, 13827,
14009, 14191, 14372, 14552, 14732, 14911, 15090, 15268,
15446, 15623, 15799, 15975, 16150, 16325, 16499, 16672,
16845, 17017, 17189, 17360, 17530, 17699, 17868, 18036,
18204, 18371, 18537, 18702, 18867, 19031, 19194, 19357,
19519, 19680, 19840, 20000, 20159, 20317, 20474, 20631,
20787, 20942, 21096, 21249, 21402, 21554, 21705, 21855,
22004, 22153, 22301, 22448, 22594, 22739, 22883, 23027,
23169, 23311, 23452, 23592, 23731, 23869, 24006, 24143,
24278, 24413, 24546, 24679, 24811, 24942, 25072, 25201,
25329, 25456, 25582, 25707, 25831, 25954, 26077, 26198,
26318, 26437, 26556, 26673, 26789, 26905, 27019, 27132,
27244, 27355, 27466, 27575, 27683, 27790, 27896, 28001,
28105, 28208, 28309, 28410, 28510, 28608, 28706, 28802,
28897, 28992, 29085, 29177, 29268, 29358, 29446, 29534,
29621, 29706, 29790, 29873, 29955, 30036, 30116, 30195,
30272, 30349, 30424, 30498, 30571, 30643, 30713, 30783,
30851, 30918, 30984, 31049, 31113, 31175, 31236, 31297,
31356, 31413, 31470, 31525, 31580, 31633, 31684, 31735,
31785, 31833, 31880, 31926, 31970, 32014, 32056, 32097,
32137, 32176, 32213, 32249, 32284, 32318, 32350, 32382,
32412, 32441, 32468, 32495, 32520, 32544, 32567, 32588,
32609, 32628, 32646, 32662, 32678, 32692, 32705, 32717,
32727, 32736, 32744, 32751, 32757, 32761, 32764, 32766,
32767, 32766, 32764, 32761, 32757, 32751, 32744, 32736,
32727, 32717, 32705, 32692, 32678, 32662, 32646, 32628,
32609, 32588, 32567, 32544, 32520, 32495, 32468, 32441,
32412, 32382, 32350, 32318, 32284, 32249, 32213, 32176,
32137, 32097, 32056, 32014, 31970, 31926, 31880, 31833,
31785, 31735, 31684, 31633, 31580, 31525, 31470, 31413,
31356, 31297, 31236, 31175, 31113, 31049, 30984, 30918,
30851, 30783, 30713, 30643, 30571, 30498, 30424, 30349,
30272, 30195, 30116, 30036, 29955, 29873, 29790, 29706,
29621, 29534, 29446, 29358, 29268, 29177, 29085, 28992,
28897, 28802, 28706, 28608, 28510, 28410, 28309, 28208,
28105, 28001, 27896, 27790, 27683, 27575, 27466, 27355,
27244, 27132, 27019, 26905, 26789, 26673, 26556, 26437,
26318, 26198, 26077, 25954, 25831, 25707, 25582, 25456,
25329, 25201, 25072, 24942, 24811, 24679, 24546, 24413,
24278, 24143, 24006, 23869, 23731, 23592, 23452, 23311,
23169, 23027, 22883, 22739, 22594, 22448, 22301, 22153,
22004, 21855, 21705, 21554, 21402, 21249, 21096, 20942,
20787, 20631, 20474, 20317, 20159, 20000, 19840, 19680,
19519, 19357, 19194, 19031, 18867, 18702, 18537, 18371,
18204, 18036, 17868, 17699, 17530, 17360, 17189, 17017,
16845, 16672, 16499, 16325, 16150, 15975, 15799, 15623,
15446, 15268, 15090, 14911, 14732, 14552, 14372, 14191,
14009, 13827, 13645, 13462, 13278, 13094, 12909, 12724,
12539, 12353, 12166, 11980, 11792, 11604, 11416, 11227,
11038, 10849, 10659, 10469, 10278, 10087, 9895, 9703,
9511, 9319, 9126, 8932, 8739, 8545, 8351, 8156,
7961, 7766, 7571, 7375, 7179, 6982, 6786, 6589,
6392, 6195, 5997, 5799, 5601, 5403, 5205, 5006,
4807, 4608, 4409, 4210, 4011, 3811, 3611, 3411,
3211, 3011, 2811, 2610, 2410, 2209, 2009, 1808,
1607, 1406, 1206, 1005, 804, 603, 402, 201,
0, -201, -402, -603, -804, -1005, -1206, -1406,
-1607, -1808, -2009, -2209, -2410, -2610, -2811, -3011,
-3211, -3411, -3611, -3811, -4011, -4210, -4409, -4608,
-4807, -5006, -5205, -5403, -5601, -5799, -5997, -6195,
-6392, -6589, -6786, -6982, -7179, -7375, -7571, -7766,
-7961, -8156, -8351, -8545, -8739, -8932, -9126, -9319,
-9511, -9703, -9895, -10087, -10278, -10469, -10659, -10849,
-11038, -11227, -11416, -11604, -11792, -11980, -12166, -12353,
-12539, -12724, -12909, -13094, -13278, -13462, -13645, -13827,
-14009, -14191, -14372, -14552, -14732, -14911, -15090, -15268,
-15446, -15623, -15799, -15975, -16150, -16325, -16499, -16672,
-16845, -17017, -17189, -17360, -17530, -17699, -17868, -18036,
-18204, -18371, -18537, -18702, -18867, -19031, -19194, -19357,
-19519, -19680, -19840, -20000, -20159, -20317, -20474, -20631,
-20787, -20942, -21096, -21249, -21402, -21554, -21705, -21855,
-22004, -22153, -22301, -22448, -22594, -22739, -22883, -23027,
-23169, -23311, -23452, -23592, -23731, -23869, -24006, -24143,
-24278, -24413, -24546, -24679, -24811, -24942, -25072, -25201,
-25329, -25456, -25582, -25707, -25831, -25954, -26077, -26198,
-26318, -26437, -26556, -26673, -26789, -26905, -27019, -27132,
-27244, -27355, -27466, -27575, -27683, -27790, -27896, -28001,
-28105, -28208, -28309, -28410, -28510, -28608, -28706, -28802,
-28897, -28992, -29085, -29177, -29268, -29358, -29446, -29534,
-29621, -29706, -29790, -29873, -29955, -30036, -30116, -30195,
-30272, -30349, -30424, -30498, -30571, -30643, -30713, -30783,
-30851, -30918, -30984, -31049, -31113, -31175, -31236, -31297,
-31356, -31413, -31470, -31525, -31580, -31633, -31684, -31735,
-31785, -31833, -31880, -31926, -31970, -32014, -32056, -32097,
-32137, -32176, -32213, -32249, -32284, -32318, -32350, -32382,
-32412, -32441, -32468, -32495, -32520, -32544, -32567, -32588,
-32609, -32628, -32646, -32662, -32678, -32692, -32705, -32717,
-32727, -32736, -32744, -32751, -32757, -32761, -32764, -32766,
};
// Function prototypes
void fix_fft(short fr[], short fi[], short m);
#endif
PK Ì9²4
4
FFT Audio Analysis\graph.h/************************************************************************
graph.h
FFT Audio Analysis
Copyright (C) 2011 Simon Inns
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Email: simon.inns@gmail.com
************************************************************************/
#ifndef _GRAPH_H_
#define _GRAPH_H_
// This table is used to convert the FFT output range of 0-181 to the
// display's Y resolution of 64 pixels using a linear scale.
const unsigned char linTable[182] =
{
0, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8,
8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 12, 13, 13, 13, 14, 14,
14, 15, 15, 15, 16, 16, 17, 17, 17, 18, 18, 18, 19, 19, 19, 20, 20,
20, 21, 21, 21, 22, 22, 22, 23, 23, 23, 24, 24, 25, 25, 25, 26, 26,
26, 27, 27, 27, 28, 28, 28, 29, 29, 29, 30, 30, 30, 31, 31, 31, 32,
32, 33, 33, 33, 34, 34, 34, 35, 35, 35, 36, 36, 36, 37, 37, 37, 38,
38, 38, 39, 39, 39, 40, 40, 41, 41, 41, 42, 42, 42, 43, 43, 43, 44,
44, 44, 45, 45, 45, 46, 46, 46, 47, 47, 47, 48, 48, 49, 49, 49, 50,
50, 50, 51, 51, 51, 52, 52, 52, 53, 53, 53, 54, 54, 54, 55, 55, 55,
56, 56, 57, 57, 57, 58, 58, 58, 59, 59, 59, 60, 60, 60, 61, 61, 61,
62, 62, 62, 63, 63, 63
};
// This table is used to convert the FFT output range of 0-181 to the
// display's Y resolution of 64 pixels using a logarithmic scale.
// Note: this table is based on a 'dB' conversion of a = 18.1 * log(x/181)
// with some shifting to prevent the noise-floor being displayed. It's
// basically useless for audio analysis, but makes for a nice looking
// output :)
const unsigned char logTable[182] =
{
0, 0, 22, 27, 30, 33, 34, 36, 37, 38, 39, 40, 40, 41, 42, 42, 43, 43,
44, 44, 45, 45, 46, 46, 46, 47, 47, 47, 48, 48, 48, 48, 49, 49, 49,
49, 50, 50, 50, 50, 50, 51, 51, 51, 51, 51, 52, 52, 52, 52, 52, 52,
53, 53, 53, 53, 53, 53, 53, 54, 54, 54, 54, 54, 54, 54, 54, 55, 55,
55, 55, 55, 55, 55, 55, 55, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
57, 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, 58, 58, 58, 58, 58, 58,
58, 58, 58, 58, 58, 58, 58, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59,
59, 59, 59, 59, 59, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60,
60, 60, 60, 60, 60, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61,
61, 61, 61, 61, 61, 61, 61, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62,
62, 62, 62, 62, 62, 62, 62, 62, 62, 63, 63
};
// This define states the delay when strobing the EN
// line in uS
#define ENSTROBEDELAY 10
// gLCD definitions
#define GLCD_READ 0b11111111
#define GLCD_WRITE 0b00000000
#define GLCD_CMD 0
#define GLCD_DATA 1
// Function prototypes
void drawFftGraph(short inputData[]);
void gLcdInit(void);
void gLcdClear(void);
#endifPK þÞq• • ) FFT Audio Analysis\FFT Audio Analysis.mcpPK 9‰ÁK K Ü FFT Audio Analysis\main.cPK @sf¥} } ^# FFT Audio Analysis\fft.cPK ZÝj¤ª ª 3 FFT Audio Analysis\graph.cPK ²ÛÜ… óG FFT Audio Analysis\hardware.hPK h(r| | :O FFT Audio Analysis\fft.hPK Ì9²4
4
ìl FFT Audio Analysis\graph.hPK Xz