<jupyter_start><jupyter_text>\tableofcontents% These TeX commands run at the start to remove section numbering\renewcommand{\thesection}{\hspace*{-1.0em}}\renewcommand{\thesubsection}{\hspace*{-1.0em}}\renewcommand{\thesubsubsection}{\hspace*{-1.0em}}<jupyter_code># fill namespace with nupy and matplotlib + static notebook plots
%pylab inline
# fill namespace with nupy and matplotlib + and interactive plots
#%pylab notebook 
#%matplotlib qt
from __future__ import division # use so 1/2 = 0.5, etc.
import sk_dsp_comm.sigsys as ss
import sk_dsp_comm.digitalcom as dc
import sk_dsp_comm.rtlsdr_helper as sdr
import imp # for module reloading
import scipy.signal as signal
from IPython.display import Audio, display
from IPython.display import Image, SVG
pylab.rcParams['savefig.dpi'] = 100 # default 72
#pylab.rcParams['figure.figsize'] = (6.0, 4.0) # default (6,4)
#%config InlineBackend.figure_formats=['png'] # default for inline viewing
%config InlineBackend.figure_formats=['svg'] # SVG inline viewing
#%config InlineBackend.figure_formats=['pdf'] # render pdf figs for LaTeX
#Image('fname.png',width='80%')<jupyter_output><empty_output><jupyter_text>Capture NOAA Weather RadioUsing `rtlsdr_helper` record a short complex baseband array using `capture()`.<jupyter_code># From the docstring
#x = sdr.capture(Tc, fo=88700000.0, fs=2400000.0, gain=40, device_index=0)
x = sdr.capture(Tc=5,fo=162.4e6,fs=2.4e6,gain=40,device_index=0)
sdr.complex2wav('capture_162475.wav',2400000,x)
fs, x = sdr.wav2complex('capture_162475.wav')
psd(x,2**10,2400);<jupyter_output><empty_output><jupyter_text>Narrowband FM Demodulator<jupyter_code>def NBFM_demod(x,fs=2.4e6,file_name='test.wav',B1=50e3,N1=10,B2=5e3,N2=5):
    """
    Narrowband FM Demodulator
    """
    b = signal.firwin(64,2*B1/float(fs))
    # Filter and decimate (should be polyphase)
    y = signal.lfilter(b,1,x)
    z = ss.downsample(y,N1)
    # Apply complex baseband discriminator
    z_bb = sdr.discrim(z)
    z_bb -= mean(z_bb)
    # Design 2nd decimation lowpass filter
    bb = signal.firwin(64,2*B2/(float(fs)/N1))
    # Filter and decimate
    zz_bb = signal.lfilter(bb,1,z_bb)
    # Decimate by N2
    z_out = ss.downsample(zz_bb,N2)
    # Save to wave file
    ss.to_wav(file_name, 48000, z_out)
    print('Done!')
    return z_bb, z_out
z_bb, z_demod = NBFM_demod(x,file_name='NOAA_cos_demod.wav')
psd(z_demod,2**10,2400/50);
xlabel(r'Frequency (kHz)');
ylim([-80,-20])
Audio('NOAA_cos_demod.wav')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13690952762209768, 'fraction_numerical': 0.05244195356285028, 'mean_word_length': 5.6997319034852545, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '269608', 'license': 'BSD-2-Clause', 'n_tokens_mistral': 1044, 'n_tokens_neox': 990, 'n_words': 194, 'path': 'tutorial_part3/RTL_SDR2.ipynb', 'repo_name': 'mwickert/SP-Comm-Tutorial-using-scikit-dsp-comm', 'size': '2498'}