# Digital FM Demodulation

I have created a Common Lisp Library to receive samples of an FM signal from BladeRF1 SDR. I want to write a subroutine to implement FM demodulation. The input should be in the format of IQ data.

What is the algorithm for demodulating an FM signal?

• Hi @mwanamutapa, and welcome to DSP.SE. It is hard to understand your question. Please extend it, e.g., by mentioning what "IQ" means and by being specific about what exactly your problem is. For example, you say that you have problems translating (assumedly) the demodulation algorithm into code. What have you tried? At what point are you stuck? Furthermore, samples typically do not have a center frequency, so be specific about what your "center frequency" means. – applesoup Jul 31 '19 at 14:20
• Regarding your second question (how to generate a wave file): Please create another question, as this is an unrelated topic. Then, extend the formulation of the question, again, by being specific about what you're trying to achieve. Do you want to create the wave file in Common Lisp? If so, you should ask on Stack Overflow, as it's not DSP specific. If not, let us know what your specific problem is. Sorry for repeating myself, but these are important points that should be considered to make sure people will be able to help you. – applesoup Jul 31 '19 at 14:23
• @applesoup I have rephrased my question. I hope it is clear what I am asking – mwanamutapa Aug 1 '19 at 8:33

Assuming you understand how the FM signal is theoretically generated, here is a simplified strategy to start with. In an FM Signal (https://en.wikipedia.org/wiki/Frequency_modulation), the frequency of the carrier is modulated according to the message signal (mostly audio). The instantaneous frequency $$f_c(t)$$
$$f_c(t) = k*m(t) + f_0$$
where $$k$$ is a modulation constant. The phase of the carrier as a function of time is
$$\phi(t) = \int f_c(t) = k t m(t) + f_0 t + \phi_0$$.
Theoretically you FM signal have infinite BW but as per the Carson's rule most of the BW is concentrated around $$f_c$$. You have to make sure that the IQ samples had sufficient BW around $$f_c$$. Once you extract the phase information from IQ samples, you can take first differential $$\phi_n - \phi_{n-1}$$ to get the instantaneous frequency information $$f[n]$$. The message signal $$m[n]$$ will be a proportionate of $$f[n]$$. With the knowledge of $$k$$ you should be able to get back (demodulate) the message signal. There are a lot of assumptions here though. You should be aware of $$k$$, Bandwidth of message signal, $$f_c$$ the center frequency etc.