Skip to content

Instantly share code, notes, and snippets.

@akx
Created November 6, 2012 18:44

Revisions

  1. akx revised this gist Nov 6, 2012. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions gistfile1.c
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    #include "kiss_fft.h"
    #include "kiss_fftr.h"

    #define FRAMES_PER_BUFFER 2048

  2. akx created this gist Nov 6, 2012.
    17 changes: 17 additions & 0 deletions gistfile1.c
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@

    #define FRAMES_PER_BUFFER 2048

    kiss_fft_cpx freq_data[FRAMES_PER_BUFFER];
    kiss_fft_scalar audio_data[FRAMES_PER_BUFFER];
    kiss_fftr_cfg fft_cfg;


    void init() {
    fft_cfg = kiss_fftr_alloc( FRAMES_PER_BUFFER , 0, 0, 0);
    }

    void audio_callback() {
    // Update audio_data, apply window if required?
    kiss_fftr(fft_cfg, audio_data, freq_data);
    // frequency data should be the magnitude (.r * .r + .i * .i) of freq_data[0 .. FRAMES_PER_BUFFER / 2] (where FRAMES_PER_BUFFER / 2 == nyquist frequency)
    }