summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TALK.md8
-rw-r--r--async_fm_demod.py14
-rw-r--r--requirements.txt1
3 files changed, 15 insertions, 8 deletions
diff --git a/TALK.md b/TALK.md
new file mode 100644
index 0000000..8bd859d
--- /dev/null
+++ b/TALK.md
@@ -0,0 +1,8 @@
+## Ideas
+
+- Radio waves in the air
+- Animation of antenna capturing energy from the air
+- Modulation basics (AM, FM) how information is encoded in carrier
+- Digital modulation modes (ASK, FSK) overview
+
+- GNU Radio is the go-to framework for building RT flows
diff --git a/async_fm_demod.py b/async_fm_demod.py
index e1f4640..3d46a9e 100644
--- a/async_fm_demod.py
+++ b/async_fm_demod.py
@@ -1,17 +1,14 @@
import asyncio
-import alsaaudio
+import pyaudio
import numpy as np
import scipy.signal as signal
from rtlsdr import RtlSdr
-device = alsaaudio.PCM(alsaaudio.PCM_PLAYBACK, device='default')
-device.setchannels(1)
-device.setrate(50000)
-device.setformat(alsaaudio.PCM_FORMAT_S16_LE)
-device.setperiodsize(520)
+pa = pyaudio.PyAudio()
+stream = pa.open(format=pyaudio.paInt16, channels=1, rate=50000, output=True)
async def streaming():
sdr = RtlSdr()
@@ -20,7 +17,8 @@ async def streaming():
prev = None
- device.write(np.array([0] * 100000).astype('int16'))
+ stream.write(np.array([0] * 100000).astype('int16'))
+ stream.start_stream()
async for samples in sdr.stream():
samples = np.array(samples).astype('complex64')
@@ -37,7 +35,7 @@ async def streaming():
samples = signal.decimate(samples, int(200e3 / 50e3))
samples *= 10000
- device.write(samples.astype('int16'))
+ stream.write(samples.astype('int16'))
await sdr.stop()
sdr.close()
diff --git a/requirements.txt b/requirements.txt
index e5912c5..0af5c7b 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -29,6 +29,7 @@ pickleshare==0.7.4
prompt-toolkit==1.0.15
ptyprocess==0.5.2
pyalsaaudio==0.8.4
+PyAudio==0.2.11
Pygments==2.2.0
pyparsing==2.2.0
pyrtlsdr==0.2.7