romanz / amodem

Audio MODEM Communication Library in Python
Other
950 stars 119 forks source link

streaming decode amodem #54

Open YD1RUH opened 2 years ago

YD1RUH commented 2 years ago

Hi, I'm a radio amateur. I want to do an experiment to send flags with bpsk modulation. after seeing the issue section I already know how to get wav output from amodem and I will try to send it via rf. but my problem is whether the modem can do the deocde process by streaming? thank you.

ptsmonteiro commented 8 months ago

We're trying to use amodem in FreeDATA as a codec but there are issues that need to be solved before it can work (bandwidth, symbol duration and carrier frequency handling).

ke4ahr commented 1 month ago

You'll need to edit amodem/config.py and setup an arbritrary BITRATE answer (see below) that uses frequencies 1e3 and/or 2e3. Out of the box, the program assumes you have 0-15 kHz to play with, which is appropriate if you are using a wideband broadcast remote transmitter like a Marti RPT-25. Using 1e3 will use up 0-2 kHz, 2e3 will use 2-4 kHz, and combining the two will give you the best possible throughput for a 0-4 kHz audio path.


export BITRATE=99
pip install . 

amodem/config.py:

# MODEM configurations for various bitrates [kbps]
bitrates = {
    1: Configuration(Fs=8e3, Npoints=2, frequencies=[2e3]),
    2: Configuration(Fs=8e3, Npoints=4, frequencies=[2e3]),
    4: Configuration(Fs=8e3, Npoints=16, frequencies=[2e3]),
    8: Configuration(Fs=8e3, Npoints=16, frequencies=[1e3, 2e3]),
    12: Configuration(Fs=16e3, Npoints=16, frequencies=[3e3, 5e3]),
    16: Configuration(Fs=16e3, Npoints=16, frequencies=[2e3, 5e3]),
    20: Configuration(Fs=16e3, Npoints=16, frequencies=[2e3, 6e3]),
    24: Configuration(Fs=16e3, Npoints=16, frequencies=[1e3, 6e3]),
    28: Configuration(Fs=32e3, Npoints=16, frequencies=[3e3, 9e3]),
    32: Configuration(Fs=32e3, Npoints=16, frequencies=[2e3, 9e3]),
    36: Configuration(Fs=32e3, Npoints=64, frequencies=[4e3, 9e3]),
    42: Configuration(Fs=32e3, Npoints=64, frequencies=[4e3, 10e3]),
    48: Configuration(Fs=32e3, Npoints=64, frequencies=[3e3, 10e3]),
    54: Configuration(Fs=32e3, Npoints=64, frequencies=[2e3, 10e3]),
    60: Configuration(Fs=32e3, Npoints=64, frequencies=[2e3, 11e3]),
    64: Configuration(Fs=32e3, Npoints=256, frequencies=[3e3, 10e3]),
    72: Configuration(Fs=32e3, Npoints=256, frequencies=[2e3, 10e3]),
    80: Configuration(Fs=32e3, Npoints=256, frequencies=[2e3, 11e3]),
    97: Configuration(Fs=32e3, Npoints=256, frequencies=[1e3]),
    98: Configuration(Fs=32e3, Npoints=256, frequencies=[2e3]),
    99: Configuration(Fs=32e3, Npoints=256, frequencies=[1e3,2e3]),
}

The audio out needs to be low-pass filtered to below 4100 Hz with a brick-wall or FIR filter. There is a notch in the output audio around that frequency. Otherwise the spectrum looks like sin (x^2/x), and harmonics all the way up. However, you need flat audio (discriminator/modulator access in the radio, no pre-emphasis or de-emphasis) to take advantage of the QAM between 0-2 kHz.