{"id":252,"date":"2017-11-17T12:53:52","date_gmt":"2017-11-17T11:53:52","guid":{"rendered":"http:\/\/www.em-company.fr\/blog\/?p=252"},"modified":"2017-11-17T14:59:27","modified_gmt":"2017-11-17T13:59:27","slug":"fft-based-frequency-calculation-implementation","status":"publish","type":"post","link":"https:\/\/www.em-company.fr\/blog\/index.php\/2017\/11\/17\/fft-based-frequency-calculation-implementation\/","title":{"rendered":"FFT based frequency calculation (implementation)"},"content":{"rendered":"<p>In a <a href=\"http:\/\/www.em-company.fr\/blog\/index.php\/2017\/11\/03\/fft-based-frequency-calculation\/\">previous article<\/a> I described the goal, which was to do a simple tool to measure the fundamental frequency of a simple sine wave. In this article, I describe the implementation, which is based on 2 open source libraries:<\/p>\n<ol>\n<li>\u00a0<a class=\"external-link\" href=\"http:\/\/www.fftw.org\/install\/windows.html\" rel=\"nofollow\">lib FFTW<\/a>\u00a0for Fourier calculation<\/li>\n<li><a class=\"external-link\" href=\"http:\/\/www.mega-nerd.com\/libsndfile\/\" rel=\"nofollow\">libsndfile<\/a> for wav file parsing<\/li>\n<\/ol>\n<p><!--more--><\/p>\n<p>Using those libraries allows a great deal of flexibility in testing various options, samples quantity, FFT types (1 or 2 dimensions). Both libraries quite naturally expose some form of Init functions, Worker functions and cleanup functions.<\/p>\n<p>The following will concentrate on the essential issues for using both libraries and some gotchas but I deliberately\u00a0\u00a0skept all the boiling plate of command line parameter parsing, result formatting, error handling &#8230; as this is very standard code.<\/p>\n<h3>Some design choices<\/h3>\n<h4>THD calculation<\/h4>\n<p>Interestingly, computing the THD (<em>Total Harmonic Distortion<\/em>)\u00a0 was a bit more challenging &#8230;. as there are a lot of slightly different definitions for THD. After some research, I landed on this\u00a0 <a href=\"http:\/\/electrical-engineering-portal.com\/essential-basics-of-total-harmonic-distortion-thd\">very comprehensive site<\/a> \u00a0\u00a0 which helped converge to the following definition:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-253 size-full\" src=\"http:\/\/www.em-company.fr\/blog\/wp-content\/uploads\/2017\/11\/thd.jpg\" alt=\"THD formula\" width=\"186\" height=\"136\" \/><\/p>\n<pre>\/\/ Definition THDf (aka THD) = SQRT(SUM(RMS(Y(2..N))) \/ RMS(Y(1)\r\n\/\/ Where:\r\n\/\/ Y(i) = Amplitude of harmonic i\r\n\/\/ Y(1) = Amplitude of harmonic 1 (Fundamental frequency)\r\n\/\/ Note: in the litterature, Fundamental is 1, harmonics start at 2<\/pre>\n<p>Which basically means the ratio of the energies found in all harmonics but the fundamental, to the energy of the fundamental. Different definitions can be found, but I opted for this one.<\/p>\n<h4>Number of FFT POINTS<\/h4>\n<p>The design assumption was that the input waveform is given as a .wav format file, made of a few seconds of a 16-bit mono PCM stream. The frequency was 1000 Hz and the stream was sampled at 48 kHz.<\/p>\n<ol>\n<li>I want to be able to appreciate a frequency deviation from the nominal 1000 Hz, knowing that the deviation will likely be either significant, or almost zero.<\/li>\n<li>Memory consumption of the tool is not very critical, but should still be reasonable. Processing time is more important.<\/li>\n<\/ol>\n<p>As the number of points together with the sampling frequency will define the\u00a0 frequency resolution, the more points we take, the more memory we consume but the better our resolution. To stay with reasonable numbers, I opted for <strong>1024<\/strong> samples. As the sampling was 48 kHz (so Shanon frequency is 24 kHz), this translates to frequency bins of about <strong>48 Hz<\/strong>.This can be improved with an interpolator.<\/p>\n<p><strong><span style=\"text-decoration: underline;\">What is an interpolator<\/span> ?<\/strong><\/p>\n<p>It basically takes 2 successive samples of a FFT, and computing a weighted middle point, which is assumed to be a more precise frequency result. There are various\u00a0 methods, linear, quadratic, barycentric, etc .. I opted for the <a href=\"http:\/\/www.ericjacobsen.org\/fe.htm\">Quinn interpolator<\/a><\/p>\n<h4>Software architecture<\/h4>\n<p>Although I\u00a0 use of Open Source libraries, I wanted to decorrelate as much as possible the core code from the libraries internals. There is an obvious reason for that. As this tool, would be used in mass production for commercial products, we needed to maintain flexibility to change library components (for example, if any legal issue arises).<\/p>\n<p>In the same vein, two more constraints can be listed<\/p>\n<ol>\n<li>We wanted very low reliance on external libraries, so exit Python and the like.<\/li>\n<li>The tool will be integrated into a manufacturing line. No User to contemplate the output, but\u00a0an\u00a0\u00a0automated test and validation system. So the result shall expose very simple numerical values, in an easy to parse format\u00a0 (TAB delimited, etc ..).<\/li>\n<\/ol>\n<p>For all those fairly classical reasons, I built small wrappers around the FFT library, the WAV parsing library and the THD calculation routines. This should allow easy maintenance and evolution. The code was built with VC13 (command line executable) in C language.<\/p>\n<h3>Implementation<\/h3>\n<p>First, we defined three interfaces (poor man API :)) for<\/p>\n<pre><strong><span style=\"text-decoration: underline;\">libsndfile library<\/span><\/strong>\r\n\r\nextern int wavLibInit(const char * const);\r\nextern int wavGetAudioSamples(float **buf, unsigned int* count);\r\nextern int wavGetSamplingFrequency(void);\r\nextern void wavLibCleanup();\r\n\r\n<span style=\"text-decoration: underline;\"><strong>FFT Library<\/strong><\/span>\r\n\r\n\/\/ Windowing\r\n#define HAS_HANN_WINDOW\r\n\r\ndouble* fftLibInit(int samplesNb, int freq);\r\nfftw_complex *fftLibCompute(void);\r\nint fftLibFindCentralFrequency(fftw_complex* out);\r\nint fftLibGetFreqBin(void);\r\nvoid fft_window(float *inputBuf, int sampleNb);\r\nvoid fftLibCleanup(void);\r\n\r\n<span style=\"text-decoration: underline;\"><strong>THD Calculation module\r\n\r\n<\/strong><\/span>typedef enum { THD_FUNDAMENTAL, THD_RELATIVE, THD_NOISE } thd_t;\r\n\r\ndouble thdCompute (const fftw_complex *buf, int size, int f0bin, thd_t type);<\/pre>\n<p>This is not perfect, as it still relies on a proprietary type (<em>fftw_complex<\/em>) which is defined the the FFT library. However, as this a very simple\u00a0 &#8220;double [2]&#8221; vector, this is generic enough and not worth the effort of abstracting it (call for debate here ..)<\/p>\n<h6>FFTW Library usage<\/h6>\n<p>To use the lib, we need to first allocate a buffer for the samples, by using the supplied &#8220;fftw-malloc&#8221; and passing the number of samples to work on.<\/p>\n<pre><strong>(extract from the wrapper\u00a0<em>fftLibInit<\/em> method)<\/strong>\u00a0\r\n\r\n if (in = (double*)fftw_malloc(sizeof (double)* samplesNb))\r\n return in;\r\n     return NULL;<\/pre>\n<p>Then, we need to allocate a buffer for the output samples (hence the importance of careful choice of the Number Of Samples &#8230;. twice the memory is needed.<\/p>\n<pre>out = (fftw_complex*)fftw_malloc(sizeof (fftw_complex)* nc);<\/pre>\n<p>Then we need to define a &#8220;plan&#8221;. In\u00a0 FFTW terminology, this is a set of parameters describing which FFT we want to use (direct, reverse), what type of numbers we operate on, etc &#8230;. In our case, we needed a One Dimensional DFT, operated on Real Numbers. Refer to\u00a0<a href=\"http:\/\/www.fftw.org\/fftw3_doc\/\">ffttw3 official site<\/a>\u00a0 for an exhaustive list of all. There are a lot of them !<\/p>\n<pre>plan_forward = fftw_plan_dft_r2c_1d(nc, in, out, FFTW_ESTIMATE);<\/pre>\n<p>Then &#8230;.. we execute the plan \ud83d\ude42<\/p>\n<pre>fftw_execute(plan_forward);<\/pre>\n<p>As a side effect, the output samples are present in the &#8220;out&#8221; buffer, previously allocated. Once done, we cleanup everything<\/p>\n<pre>void fftLibCleanup(void)\r\n{\r\n fftw_destroy_plan(plan_forward);\r\n fftw_free(in);\r\n fftw_free(out);\r\n}<\/pre>\n<h6>Libsndfile library usage<\/h6>\n<p>This lib operates on custom types, which need to be defined beforehand. Here is the code extract<\/p>\n<pre>#include &lt;sndfile.h&gt;\r\n\r\n#define NB_AUDIO_SAMPLES (1024*1)\r\n\r\nstatic SNDFILE* inputWav, *refWav;\r\nstatic SF_INFO wavFileInfo;\r\nstatic float * localBuf;\r\n\r\n......\r\n......\r\n memset(&amp;wavFileInfo, 0, sizeof(wavFileInfo));\r\n if ((inputWav = sf_open(file_name, SFM_READ, &amp;wavFileInfo)) == NULL)\r\n return (-EBADF);\r\nreturn 0;\r\n......<\/pre>\n<p>Calling the <em>sf_open<\/em> will get automatically all the file meta-data into the <em>wavFileInfo<\/em> structure. From there, sampling rate can be extracted, encoding width, number of channels, etc.<\/p>\n<p>Then, the file is simply read, the WAV format is interpreted and the audio samples are put in the provided buffer. Here is my small wrapper around these operations<\/p>\n<pre>int wavGetAudioSamples(float **buf, unsigned int * count)\r\n{\r\n \/\/ Allocate mem to read in the channel data\r\n int bytesPerSample;\r\n if ((bytesPerSample = wavGetBytesPerSample(&amp;wavFileInfo) == -EINVAL))\r\n return (-EINVAL);\r\n\r\n*buf = (float *)malloc((size_t)wavFileInfo.frames*wavFileInfo.channels*sizeof(float));\r\n\r\nsf_count_t samples = sf_read_float(inputWav, *buf, NB_AUDIO_SAMPLES * wavFileInfo.channels); \/\/ read 1000 samples both channels ... but will process only one\r\n *count = (unsigned int)samples;\r\n return 0;\r\n}<\/pre>\n<p>we use the previously defined xxx structure to retrieve info about size, number of samples (<em>wavFileInfo.frames, wavFileInfo.channels<\/em>) . Note also the <em>sf_read_float<\/em> which would do the translation to float as well (As this is need for the FFTW lib).<\/p>\n<p>Then, some cleanup<\/p>\n<pre>void wavLibCleanup()\r\n{\r\n sf_close(inputWav);\r\n free(localBuf);\r\n}<\/pre>\n<h3>Results and gotchas<\/h3>\n<p>There is an interesting and very important point in the FFTW operations: the results are NOT normalized. This is very well describe in the <a href=\"http:\/\/www.fftw.org\/fftw3_doc\/The-1d-Discrete-Fourier-Transform-_0028DFT_0029.html#The-1d-Discrete-Fourier-Transform-_0028DFT_0029\">FFTW documentation<\/a>\u00a0. As stated<\/p>\n<blockquote><p>FFTW computes an unnormalized transform, in that there is no coefficient in front of the summation in the DFT. In other words, applying the forward and then the backward transform will multiply the input by n.<\/p><\/blockquote>\n<p>so that mean that you need to take this into account in the calling code. Otherwise the results will look fancy.<\/p>\n<p>One can apply a Windowing function before calling the FTT. I tried various window, ended up applying an Hann window as follows:<\/p>\n<pre>static void fft_hann_window(float *inputBuf, int sampleNb)\r\n{\r\n float multiplier;\r\n for (int i = 0; i &lt; sampleNb; i++)\r\n {\r\n multiplier = 0.5f * (1 - cosf(2.0f * (float)M_PI*i \/ sampleNb));\r\n inputBuf[i] *= multiplier;\r\n }\r\n}<\/pre>\n<p>but I couldn&#8217;t see a dramatic effect \ud83d\ude41 and even sometimes, it seemed to me there was a degradation on the frequency calculation. This is FFS (For Further Study)<\/p>\n<p>So when everything was bundled together (and he tool coined &#8220;wavcheck&#8221;), we got the following:<\/p>\n<div class=\"container\" title=\"Hint: double-click to select code\">\n<pre>C:\\&gt;wavcheck.exe\r\nwavcheck\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 version 1.0.0\r\nsimple manufacturing wv file analyser\r\nUsage:\r\nwavecheck [-thd] &lt;sound.wav&gt;\r\n\r\nWhere:\r\n\r\n---&gt; thd : adds the thd calculation\r\n---&gt; &lt;sound.wav&gt; is the .wav file to analyze\r\nC:\\&gt;<\/pre>\n<div><\/div>\n<\/div>\n<p>and the output \ud83d\ude42<\/p>\n<div style=\"font-family: Courier New; background: black; color: white; padding: 1em 1em 1em 1em;\">C:\\&gt;wavcheck.exe ..\\..\\1050_ref.wav<br \/>\n1050<br \/>\nC:\\&gt;wavcheck.exe thd ..\\..\\1050_ref.wav<br \/>\n1050\u00a0\u00a0\u00a0 2.41\u00a0\u00a0\u00a0 -32.4\u00a0\u00a0 50.36\u00a0\u00a0 -6.0<br \/>\nC:\\&gt;<\/div>\n<p>&nbsp;<\/p>\n<p>Et voila !<\/p>\n<p><span style=\"text-decoration: underline;\"><strong>References<\/strong><\/span><\/p>\n<ol>\n<li>http:\/\/www.ericjacobsen.org\/FTinterp.pdf<\/li>\n<li>https:\/\/dspguru.com\/dsp\/howtos\/how-to-interpolate-fft-peak\/<\/li>\n<li><a href=\"http:\/\/www.fftw.org\/\">FFTW3<\/a>\u00a0library<\/li>\n<li><a href=\"http:\/\/www.mega-nerd.com\/libsndfile\/\">Libsndfile<\/a> library<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In a previous article I described the goal, which was to do a simple tool to measure the fundamental frequency of a simple sine wave. In this article, I describe the implementation, which is based on 2 open source libraries: \u00a0lib FFTW\u00a0for Fourier calculation libsndfile for wav file parsing<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20,14],"tags":[40],"class_list":["post-252","post","type-post","status-publish","format-standard","hentry","category-embedded","category-programming","tag-fft"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>FFT based frequency calculation (implementation) - Embedded<\/title>\n<meta name=\"description\" content=\"detailed implementation, tradeoffs and usage on an FFT based frequency calculation using the FFTW3 and the linsdnfile libraries.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.em-company.fr\/blog\/index.php\/2017\/11\/17\/fft-based-frequency-calculation-implementation\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"FFT based frequency calculation (implementation) - Embedded\" \/>\n<meta property=\"og:description\" content=\"detailed implementation, tradeoffs and usage on an FFT based frequency calculation using the FFTW3 and the linsdnfile libraries.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.em-company.fr\/blog\/index.php\/2017\/11\/17\/fft-based-frequency-calculation-implementation\/\" \/>\n<meta property=\"og:site_name\" content=\"Embedded\" \/>\n<meta property=\"article:published_time\" content=\"2017-11-17T11:53:52+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2017-11-17T13:59:27+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.em-company.fr\/blog\/wp-content\/uploads\/2017\/11\/thd.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"186\" \/>\n\t<meta property=\"og:image:height\" content=\"136\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"kriko\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"kriko\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.em-company.fr\\\/blog\\\/index.php\\\/2017\\\/11\\\/17\\\/fft-based-frequency-calculation-implementation\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.em-company.fr\\\/blog\\\/index.php\\\/2017\\\/11\\\/17\\\/fft-based-frequency-calculation-implementation\\\/\"},\"author\":{\"name\":\"kriko\",\"@id\":\"https:\\\/\\\/www.em-company.fr\\\/blog\\\/#\\\/schema\\\/person\\\/fcb297f759038f0e8cb969c4c29742df\"},\"headline\":\"FFT based frequency calculation (implementation)\",\"datePublished\":\"2017-11-17T11:53:52+00:00\",\"dateModified\":\"2017-11-17T13:59:27+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.em-company.fr\\\/blog\\\/index.php\\\/2017\\\/11\\\/17\\\/fft-based-frequency-calculation-implementation\\\/\"},\"wordCount\":1078,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/www.em-company.fr\\\/blog\\\/index.php\\\/2017\\\/11\\\/17\\\/fft-based-frequency-calculation-implementation\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/www.em-company.fr\\\/blog\\\/wp-content\\\/uploads\\\/2017\\\/11\\\/thd.jpg\",\"keywords\":[\"FFT\"],\"articleSection\":[\"embedded\",\"programming\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.em-company.fr\\\/blog\\\/index.php\\\/2017\\\/11\\\/17\\\/fft-based-frequency-calculation-implementation\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.em-company.fr\\\/blog\\\/index.php\\\/2017\\\/11\\\/17\\\/fft-based-frequency-calculation-implementation\\\/\",\"url\":\"https:\\\/\\\/www.em-company.fr\\\/blog\\\/index.php\\\/2017\\\/11\\\/17\\\/fft-based-frequency-calculation-implementation\\\/\",\"name\":\"FFT based frequency calculation (implementation) - Embedded\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.em-company.fr\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.em-company.fr\\\/blog\\\/index.php\\\/2017\\\/11\\\/17\\\/fft-based-frequency-calculation-implementation\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.em-company.fr\\\/blog\\\/index.php\\\/2017\\\/11\\\/17\\\/fft-based-frequency-calculation-implementation\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/www.em-company.fr\\\/blog\\\/wp-content\\\/uploads\\\/2017\\\/11\\\/thd.jpg\",\"datePublished\":\"2017-11-17T11:53:52+00:00\",\"dateModified\":\"2017-11-17T13:59:27+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.em-company.fr\\\/blog\\\/#\\\/schema\\\/person\\\/fcb297f759038f0e8cb969c4c29742df\"},\"description\":\"detailed implementation, tradeoffs and usage on an FFT based frequency calculation using the FFTW3 and the linsdnfile libraries.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.em-company.fr\\\/blog\\\/index.php\\\/2017\\\/11\\\/17\\\/fft-based-frequency-calculation-implementation\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.em-company.fr\\\/blog\\\/index.php\\\/2017\\\/11\\\/17\\\/fft-based-frequency-calculation-implementation\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.em-company.fr\\\/blog\\\/index.php\\\/2017\\\/11\\\/17\\\/fft-based-frequency-calculation-implementation\\\/#primaryimage\",\"url\":\"http:\\\/\\\/www.em-company.fr\\\/blog\\\/wp-content\\\/uploads\\\/2017\\\/11\\\/thd.jpg\",\"contentUrl\":\"http:\\\/\\\/www.em-company.fr\\\/blog\\\/wp-content\\\/uploads\\\/2017\\\/11\\\/thd.jpg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.em-company.fr\\\/blog\\\/index.php\\\/2017\\\/11\\\/17\\\/fft-based-frequency-calculation-implementation\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Accueil\",\"item\":\"https:\\\/\\\/www.em-company.fr\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"FFT based frequency calculation (implementation)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.em-company.fr\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.em-company.fr\\\/blog\\\/\",\"name\":\"Embedded\",\"description\":\"(...but not only)\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.em-company.fr\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.em-company.fr\\\/blog\\\/#\\\/schema\\\/person\\\/fcb297f759038f0e8cb969c4c29742df\",\"name\":\"kriko\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"FFT based frequency calculation (implementation) - Embedded","description":"detailed implementation, tradeoffs and usage on an FFT based frequency calculation using the FFTW3 and the linsdnfile libraries.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.em-company.fr\/blog\/index.php\/2017\/11\/17\/fft-based-frequency-calculation-implementation\/","og_locale":"en_US","og_type":"article","og_title":"FFT based frequency calculation (implementation) - Embedded","og_description":"detailed implementation, tradeoffs and usage on an FFT based frequency calculation using the FFTW3 and the linsdnfile libraries.","og_url":"https:\/\/www.em-company.fr\/blog\/index.php\/2017\/11\/17\/fft-based-frequency-calculation-implementation\/","og_site_name":"Embedded","article_published_time":"2017-11-17T11:53:52+00:00","article_modified_time":"2017-11-17T13:59:27+00:00","og_image":[{"width":186,"height":136,"url":"https:\/\/www.em-company.fr\/blog\/wp-content\/uploads\/2017\/11\/thd.jpg","type":"image\/jpeg"}],"author":"kriko","twitter_card":"summary_large_image","twitter_misc":{"Written by":"kriko","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.em-company.fr\/blog\/index.php\/2017\/11\/17\/fft-based-frequency-calculation-implementation\/#article","isPartOf":{"@id":"https:\/\/www.em-company.fr\/blog\/index.php\/2017\/11\/17\/fft-based-frequency-calculation-implementation\/"},"author":{"name":"kriko","@id":"https:\/\/www.em-company.fr\/blog\/#\/schema\/person\/fcb297f759038f0e8cb969c4c29742df"},"headline":"FFT based frequency calculation (implementation)","datePublished":"2017-11-17T11:53:52+00:00","dateModified":"2017-11-17T13:59:27+00:00","mainEntityOfPage":{"@id":"https:\/\/www.em-company.fr\/blog\/index.php\/2017\/11\/17\/fft-based-frequency-calculation-implementation\/"},"wordCount":1078,"commentCount":0,"image":{"@id":"https:\/\/www.em-company.fr\/blog\/index.php\/2017\/11\/17\/fft-based-frequency-calculation-implementation\/#primaryimage"},"thumbnailUrl":"http:\/\/www.em-company.fr\/blog\/wp-content\/uploads\/2017\/11\/thd.jpg","keywords":["FFT"],"articleSection":["embedded","programming"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.em-company.fr\/blog\/index.php\/2017\/11\/17\/fft-based-frequency-calculation-implementation\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.em-company.fr\/blog\/index.php\/2017\/11\/17\/fft-based-frequency-calculation-implementation\/","url":"https:\/\/www.em-company.fr\/blog\/index.php\/2017\/11\/17\/fft-based-frequency-calculation-implementation\/","name":"FFT based frequency calculation (implementation) - Embedded","isPartOf":{"@id":"https:\/\/www.em-company.fr\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.em-company.fr\/blog\/index.php\/2017\/11\/17\/fft-based-frequency-calculation-implementation\/#primaryimage"},"image":{"@id":"https:\/\/www.em-company.fr\/blog\/index.php\/2017\/11\/17\/fft-based-frequency-calculation-implementation\/#primaryimage"},"thumbnailUrl":"http:\/\/www.em-company.fr\/blog\/wp-content\/uploads\/2017\/11\/thd.jpg","datePublished":"2017-11-17T11:53:52+00:00","dateModified":"2017-11-17T13:59:27+00:00","author":{"@id":"https:\/\/www.em-company.fr\/blog\/#\/schema\/person\/fcb297f759038f0e8cb969c4c29742df"},"description":"detailed implementation, tradeoffs and usage on an FFT based frequency calculation using the FFTW3 and the linsdnfile libraries.","breadcrumb":{"@id":"https:\/\/www.em-company.fr\/blog\/index.php\/2017\/11\/17\/fft-based-frequency-calculation-implementation\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.em-company.fr\/blog\/index.php\/2017\/11\/17\/fft-based-frequency-calculation-implementation\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.em-company.fr\/blog\/index.php\/2017\/11\/17\/fft-based-frequency-calculation-implementation\/#primaryimage","url":"http:\/\/www.em-company.fr\/blog\/wp-content\/uploads\/2017\/11\/thd.jpg","contentUrl":"http:\/\/www.em-company.fr\/blog\/wp-content\/uploads\/2017\/11\/thd.jpg"},{"@type":"BreadcrumbList","@id":"https:\/\/www.em-company.fr\/blog\/index.php\/2017\/11\/17\/fft-based-frequency-calculation-implementation\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Accueil","item":"https:\/\/www.em-company.fr\/blog\/"},{"@type":"ListItem","position":2,"name":"FFT based frequency calculation (implementation)"}]},{"@type":"WebSite","@id":"https:\/\/www.em-company.fr\/blog\/#website","url":"https:\/\/www.em-company.fr\/blog\/","name":"Embedded","description":"(...but not only)","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.em-company.fr\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.em-company.fr\/blog\/#\/schema\/person\/fcb297f759038f0e8cb969c4c29742df","name":"kriko"}]}},"_links":{"self":[{"href":"https:\/\/www.em-company.fr\/blog\/index.php\/wp-json\/wp\/v2\/posts\/252","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.em-company.fr\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.em-company.fr\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.em-company.fr\/blog\/index.php\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.em-company.fr\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=252"}],"version-history":[{"count":10,"href":"https:\/\/www.em-company.fr\/blog\/index.php\/wp-json\/wp\/v2\/posts\/252\/revisions"}],"predecessor-version":[{"id":267,"href":"https:\/\/www.em-company.fr\/blog\/index.php\/wp-json\/wp\/v2\/posts\/252\/revisions\/267"}],"wp:attachment":[{"href":"https:\/\/www.em-company.fr\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=252"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.em-company.fr\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=252"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.em-company.fr\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=252"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}