00001 /*---------------------------------------------------------------------------- 00002 MoMu: A Mobile Music Toolkit 00003 Copyright (c) 2010 Nicholas J. Bryan, Jorge Herrera, Jieun Oh, and Ge Wang 00004 All rights reserved. 00005 http://momu.stanford.edu/toolkit/ 00006 00007 Mobile Music Research @ CCRMA 00008 Music, Computing, Design Group 00009 Stanford University 00010 http://momu.stanford.edu/ 00011 http://ccrma.stanford.edu/groups/mcd/ 00012 00013 MoMu is distributed under the following BSD style open source license: 00014 00015 Permission is hereby granted, free of charge, to any person obtaining a 00016 copy of this software and associated documentation files (the 00017 "Software"), to deal in the Software without restriction, including 00018 without limitation the rights to use, copy, modify, merge, publish, 00019 distribute, sublicense, and/or sell copies of the Software, and to 00020 permit persons to whom the Software is furnished to do so, subject to 00021 the following conditions: 00022 00023 The authors encourage users of MoMu to include this copyright notice, 00024 and to let us know that you are using MoMu. Any person wishing to 00025 distribute modifications to the Software is encouraged to send the 00026 modifications to the original authors so that they can be incorporated 00027 into the canonical version. 00028 00029 The Software is provided "as is", WITHOUT ANY WARRANTY, express or implied, 00030 including but not limited to the warranties of MERCHANTABILITY, FITNESS 00031 FOR A PARTICULAR PURPOSE and NONINFRINGEMENT. In no event shall the authors 00032 or copyright holders by liable for any claim, damages, or other liability, 00033 whether in an actino of a contract, tort or otherwise, arising from, out of 00034 or in connection with the Software or the use or other dealings in the 00035 software. 00036 -----------------------------------------------------------------------------*/ 00037 00038 /*----------------------------------------------------------------------------*/ 00049 /*----------------------------------------------------------------------------*/ 00050 #ifndef __MO_FFT_H__ 00051 #define __MO_FFT_H__ 00052 00053 00054 00055 /*----------------------------------------------------------------------------*/ 00060 /*----------------------------------------------------------------------------*/ 00061 typedef struct { float re ; float im ; } complex; 00062 00064 #define cmp_abs(x) ( sqrt( (x).re * (x).re + (x).im * (x).im ) ) 00065 00066 #define FFT_FORWARD 1 00067 #define FFT_INVERSE 0 00068 00069 /*----------------------------------------------------------------------------*/ 00074 /*----------------------------------------------------------------------------*/ 00075 class MoFFT 00076 { 00077 public: 00079 static void rfft( float * x, long N, unsigned int forward ); 00080 00082 static void cfft( float * x, long NC, unsigned int forward ); 00083 00085 static void hanning( float * window, unsigned long length ); 00086 00088 static void hamming( float * window, unsigned long length ); 00089 00091 static void blackman( float * window, unsigned long length ); 00092 00094 static void apply_window( float * data, float * window, unsigned long length ); 00095 00096 private: 00097 static void bit_reverse( float * x, long N ); 00098 }; 00099 00100 00101 #endif