amodem icon indicating copy to clipboard operation
amodem copied to clipboard

Decoding failed

Open DavidVentura opened this issue 2 years ago • 4 comments

Hi! I am testing this on some of my systems and can't get a transfer to work:

Sender (using aplay because amodem picks the wrong interface):

$ echo  123 |  amodem  send -vvvv -o - | aplay
2021-08-03 12:49:32,213 INFO       Audio OFDM MODEM v1.15.3: 1.0 kb/s (2-QAM x 1 carriers) Fs=8.0 kHz                                   __main__.py:230
Playing raw data 'stdin' : Unsigned 8 bit, Rate 8000 Hz, Mono
2021-08-03 12:49:32,221 INFO       Sending 1.050 seconds of training audio                                                              main.py:23
2021-08-03 12:49:32,221 INFO       Starting modulation                                                                                  main.py:28
2021-08-03 12:49:32,226 INFO       Sent 0.004 kB @ 0.113 seconds                                                                        main.py:32
2021-08-03 12:49:32,226 DEBUG      Finished I/O                                                                                         __main__.py:261
$ 

Receiver:

$ amodem  recv  -vv
2021-08-03 12:49:31,789 INFO       Audio OFDM MODEM v1.15.3: 1.0 kb/s (2-QAM x 1 carriers) Fs=8.0 kHz                                   __main__.py:230
2021-08-03 12:49:31,790 INFO       b'PortAudio V19.6.0-devel, revision 396fe4b6699ae929d3a685b3ef8a7e97396139a4' loaded                 audio.py:21
ALSA lib pcm_dsnoop.c:642:(snd_pcm_dsnoop_open) unable to open slave
ALSA lib pcm_dmix.c:1090:(snd_pcm_dmix_open) unable to open slave
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2660:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm_oss.c:377:(_snd_pcm_oss_open) Unknown field port
ALSA lib pcm_oss.c:377:(_snd_pcm_oss_open) Unknown field port
ALSA lib pcm_usb_stream.c:486:(_snd_pcm_usb_stream_open) Invalid type for card
ALSA lib pcm_usb_stream.c:486:(_snd_pcm_usb_stream_open) Invalid type for card
ALSA lib pcm_dmix.c:1090:(snd_pcm_dmix_open) unable to open slave
2021-08-03 12:49:31,878 DEBUG      AsyncReader thread started                                                                           async_reader.py:26
2021-08-03 12:49:31,878 DEBUG      Skipping 0.100 seconds                                                                               main.py:46
2021-08-03 12:49:32,572 INFO       Waiting for carrier tone: 2.0 kHz                                                                    main.py:53
2021-08-03 12:49:36,086 INFO       Carrier detected at ~3634.0 ms @ 2.0 kHz                                                             detect.py:60
2021-08-03 12:49:36,087 DEBUG      Buffered 1000 ms of audio                                                                            detect.py:63
2021-08-03 12:49:36,088 INFO       Carrier coherence: 71.645%                                                                           detect.py:94
2021-08-03 12:49:36,088 DEBUG      Carrier starts at 3714.625 ms                                                                        detect.py:73
2021-08-03 12:49:36,089 INFO       Carrier symbols amplitude : 0.916                                                                    detect.py:105
2021-08-03 12:49:36,090 INFO       Frequency error: 1.633 ppm                                                                           detect.py:115
2021-08-03 12:49:36,090 DEBUG      Frequency correction: -1.633 ppm                                                                     main.py:57
2021-08-03 12:49:36,090 DEBUG      Gain correction: 1.092                                                                               main.py:60
2021-08-03 12:49:36,090 DEBUG      Receiving                                                                                            recv.py:161
2021-08-03 12:49:36,106 ERROR      Decoding failed                                                                                      main.py:67
Traceback (most recent call last):
  File "/home/david/.local/lib/python3.8/site-packages/amodem/main.py", line 64, in recv
    receiver.run(sampler, gain=1.0/amplitude, output=dst)
  File "/home/david/.local/lib/python3.8/site-packages/amodem/recv.py", line 163, in run
    self._prefix(symbols, gain=gain)
  File "/home/david/.local/lib/python3.8/site-packages/amodem/recv.py", line 49, in _prefix
    raise ValueError(msg)
ValueError: Incorrect prefix: 50 errors
2021-08-03 12:49:36,175 DEBUG      AsyncReader thread stopped (read 67200 bytes)                                                        async_reader.py:31
2021-08-03 12:49:36,177 DEBUG      Finished I/O                                                                                         __main__.py:261

However, calibration seems good?

2021-08-03 12:47:20,394 INFO         2000 Hz: good signal         total=0.9294, rms=0.9291, coherency=0.9996, peak=0.9813               calib.py:141
2021-08-03 12:47:20,594 INFO         2000 Hz: good signal         total=0.9205, rms=0.9201, coherency=0.9996, peak=0.9687               calib.py:141
2021-08-03 12:47:20,809 INFO         2000 Hz: good signal         total=0.9119, rms=0.9116, coherency=0.9996, peak=0.9649               calib.py:141
2021-08-03 12:47:20,985 INFO         2000 Hz: good signal         total=0.9052, rms=0.9048, coherency=0.9996, peak=0.9596               calib.py:141
2021-08-03 12:47:21,214 INFO         2000 Hz: good signal         total=0.9077, rms=0.9073, coherency=0.9996, peak=0.9631               calib.py:141
2021-08-03 12:47:21,413 INFO         2000 Hz: good signal         total=0.9063, rms=0.9060, coherency=0.9996, peak=0.9611               calib.py:141
2021-08-03 12:47:21,613 INFO         2000 Hz: good signal         total=0.9061, rms=0.9057, coherency=0.9996, peak=0.9582               calib.py:141
2021-08-03 12:47:21,814 INFO         2000 Hz: good signal         total=0.9074, rms=0.9070, coherency=0.9996, peak=0.9605               calib.py:141
2021-08-03 12:47:21,986 INFO         2000 Hz: good signal         total=0.9075, rms=0.9071, coherency=0.9996, peak=0.9640               calib.py:141
2021-08-03 12:47:22,171 INFO         2000 Hz: good signal         total=0.9067, rms=0.9063, coherency=0.9996, peak=0.9563               calib.py:141
2021-08-03 12:47:22,371 INFO         2000 Hz: good signal         total=0.9077, rms=0.9073, coherency=0.9996, peak=0.9636               calib.py:141
2021-08-03 12:47:22,598 INFO         2000 Hz: good signal         total=0.9078, rms=0.9074, coherency=0.9996, peak=0.9638               calib.py:141
2021-08-03 12:47:22,772 INFO         2000 Hz: good signal         total=0.9061, rms=0.9057, coherency=0.9996, peak=0.9608               calib.py:141
2021-08-03 12:47:22,971 INFO         2000 Hz: good signal         total=0.9073, rms=0.9069, coherency=0.9996, peak=0.9599               calib.py:141
2021-08-03 12:47:23,202 INFO         2000 Hz: good signal         total=0.9064, rms=0.9060, coherency=0.9996, peak=0.9592               calib.py:141
2021-08-03 12:47:23,397 INFO         2000 Hz: good signal         total=0.9062, rms=0.9058, coherency=0.9996, peak=0.9606               calib.py:141
2021-08-03 12:47:23,598 INFO         2000 Hz: good signal         total=0.9085, rms=0.9081, coherency=0.9996, peak=0.9623               calib.py:141
2021-08-03 12:47:23,798 INFO         2000 Hz: good signal         total=0.9069, rms=0.9065, coherency=0.9996, peak=0.9608               calib.py:141
2021-08-03 12:47:23,998 INFO         2000 Hz: good signal         total=0.9053, rms=0.9049, coherency=0.9996, peak=0.9564               calib.py:141
2021-08-03 12:47:24,202 INFO         2000 Hz: good signal         total=0.9074, rms=0.9070, coherency=0.9996, peak=0.9604               calib.py:141
2021-08-03 12:47:24,402 INFO         2000 Hz: good signal         total=0.9041, rms=0.9037, coherency=0.9996, peak=0.9534               calib.py:141
2021-08-03 12:47:24,602 INFO         2000 Hz: good signal         total=0.9050, rms=0.9047, coherency=0.9996, peak=0.9611               calib.py:141
2021-08-03 12:47:24,802 INFO         2000 Hz: good signal         total=0.9068, rms=0.9064, coherency=0.9996, peak=0.9576 

Can you advise? Thanks

DavidVentura avatar Aug 03 '21 10:08 DavidVentura

For what it's worth, I'm having similar problems. I'm running the sender and receiver on the same computer. I've also tried against the Android app. I believe the only success I've had is from the computer to the app. Here are my logs for a local calibration and test, and the matplotlib graphs (of a subsequent test). amodem_rx.log amodem_rx_cal.log amodem_tx.log amodem_tx_cal.log Screenshot from 2021-09-04 15-21-00

Erhannis avatar Sep 04 '21 19:09 Erhannis

Ok, so I DID just manage to get a message from the phone to the computer. I turned down the volume on my phone and the mic on the computer and put the speaker within an inch of the microphone. Looks like it's just not very tolerant of noise? Is there a way to improve that? Further reduce the bitrate or something?

Erhannis avatar Sep 04 '21 19:09 Erhannis

Ah - one problem is that aplay and arecord don't play at the correct samplerates, I think. A little more investigation to follow.

Erhannis avatar Sep 04 '21 20:09 Erhannis

I dunno. :/ In increments, I've turned the symbol length up by a factor of 20, decreased the frequency to 6e2, increased the sample rate to 32e3, left Npoints at 2, messed a lot with the volumes - nothing seems to work.

Erhannis avatar Sep 04 '21 20:09 Erhannis