Fast Fourier Transform


Closed Thread
Results 1 to 4 of 4
  1. #1
    egberttheone's Avatar
    egberttheone Guest

    Cool Fast Fourier Transform

    Hello,

    just wondering if one of you guys ever attempted this? i want to make a spectrum analyzer; maby using multiple processors. I do not have enough experience to understand the FFT formulas so i need a example on how to use them using pbp. If you have information thanks!

  2. #2
    egberttheone's Avatar
    egberttheone Guest


    Did you find this post helpful? Yes | No

    Default

    Hmm I did give a little less information so lets give some more, I want to make a Audio spectrum analyzer, it needs to drive 32 bars with 16 LED's a bar. so the frequentation's doesn't need to be VERY precise; we need to extract the signal in to 32 frequentation's. well that is about it

  3. #3
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    mmm, in the past the old spectrum analyser like Klark Teknik was using really selective bandpass filter for each frequency in the audio spectrum + regular LM3914 or something like that bargraph driver for front plate LEDs. But for sure PC software(like spectra-lab or Smaart) and Neutrik ML1 or else have to use those kind of calculation. If you find the great formulas post them here. We can probably do something.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  4. #4
    egberttheone's Avatar
    egberttheone Guest


    Did you find this post helpful? Yes | No

    Default

    this is a working formula; i think its kinda hard to import its a piece of vb code.

    Code:
     
       Sub FFTAudio(RealIn() As Integer, RealOut() As Single)
        'In this case, NumSamples isn't included (since it's always the same),
        'and the imaginary components are left out since they have no meaning here.
        
        'I've used Singles instead of Doubles pretty much everywhere.  I think this
        'makes it faster, but due to type conversion, it actually might not.  I should
        'check, but I haven't.
        
        'The imaginary components have no meaning in this application.  I just left out
        'the parts of the calculation that need the imaginary input values (which is a
        'big speed improvement right there), but we still need the output array because
        'it's used in the calculation.  It's static so that it doesn't get reallocated.
        Static ImagOut(0 To NumSamples - 1) As Single
        
        'In fact... I declare everything as static!  They all get initialized elsewhere,
        'and Staticing them saves from wasting time reallocating and takes pressure off
        'the heap.
        Static I As Long, j As Long, k As Long, n As Long, BlockSize As Long, BlockEnd As Long
        Static DeltaAngle As Single, DeltaAr As Single
        Static Alpha As Single, Beta As Single
        Static TR As Single, TI As Single, AR As Single, AI As Single
        
        For I = 0 To (NumSamples - 1)
            j = ReversedBits(I) 'I saved time here by pre-calculating all these values
            RealOut(j) = RealIn(I)
            ImagOut(j) = 0 'Since this array is static, gotta make sure it's clear
        Next
        
        BlockEnd = 1
        BlockSize = 2
        
        Do While BlockSize <= NumSamples
            DeltaAngle = AngleNumerator / BlockSize
            Alpha = Sin(0.5 * DeltaAngle)
            Alpha = 2! * Alpha * Alpha
            Beta = Sin(DeltaAngle)
            
            I = 0
            Do While I < NumSamples
                AR = 1!
                AI = 0!
                
                j = I
                For n = 0 To BlockEnd - 1
                    k = j + BlockEnd
                    TR = AR * RealOut(k) - AI * ImagOut(k)
                    TI = AI * RealOut(k) + AR * ImagOut(k)
                    RealOut(k) = RealOut(j) - TR
                    ImagOut(k) = ImagOut(j) - TI
                    RealOut(j) = RealOut(j) + TR
                    ImagOut(j) = ImagOut(j) + TI
                    DeltaAr = Alpha * AR + Beta * AI
                    AI = AI - (Alpha * AI - Beta * AR)
                    AR = AR - DeltaAr
                    j = j + 1
                Next
                
                I = I + BlockSize
            Loop
            
            BlockEnd = BlockSize
            BlockSize = BlockSize * 2
        Loop
    End Sub

Similar Threads

  1. Fast Data Logging
    By dksoba in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 20th February 2010, 21:08
  2. Fast / low resolution A/D conversion
    By AndrewC in forum General
    Replies: 7
    Last Post: - 7th April 2009, 12:18
  3. Detect fast movement using photodiode
    By Pic2008 in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 22nd November 2008, 14:07
  4. Discreat fourier transform
    By rocky79 in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 27th September 2005, 23:50
  5. A/D on 16F877. How fast can I go?
    By atomski in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 8th April 2004, 06:51

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts