Closed mntnmn closed 5 years ago
You need to pipe raw data in at at sample rate of 22050, with 16 bit signed integers. If need be, you can pipe your data to SoX first, manipulate it to 22.5k, 16bit, then pipe from SoX to the demodulator. I would pipe to aplay (part of SoX) first, and you should hear your stream as you expect it through your speakers. This will verify the UDP stream you are using is in fact working.
Thanks, 22.5K or 22050? Oh, I see in the demod code it is 22050 for sound card and 12000 for stdin. I have it set to 12000. I am listening to the audio on SDRangel as I am also streaming to UDP. I suppose I can kill it on the receiver and try to monitor the stream. This would be a good test. I believe the data on UDP is just the same raw 16 bit demodulated audio data that would be sent to the sound card. I can output a chunk of it to a file and look at it or try to play it.
The command 'nc -l -u -p 9999 | aplay -fS16_LE -r22050' produces very clear audio. So does 'nc -l -u -p 9999 | aplay -fS16_LE -r12000'. SDRangel can be set up to output any rate. The command 'nc -l -u -p 9999 | ./demod 1 -' produces no output after the initial Input Type: STDIN Raw Samples Decoder: MDC1200. I have tried it with both sample rates. Should this work? The code looks like it should ' fprintf(stderr, "MDC1200: %02x %02x %04x\n", op, arg, unitID); ' whenever a decodable signal tone gets sampled. This signal gets sampled a lot on this busy public safety channel. How would I troubleshoot this?
Closed by accident. Not enough coffee this morning.
I've been putting print statements in the code and it gets to demod.c:245 and segfaults there. This is 'result = mdc_decoder_process_samples(m_decoder, buffer, sizeof(buffer));' a call to the decoder lib. I will look into this next.
Cured the segfault by cutting the buffer size in half to 4K. Except for intermittently it crashes the first time but not the second time it's started. I put a print statement on numSample in the decoder loop and noticed it would read about 14K of the 16K samples and then crash. Samples are twice the buffer size. Now it runs but is not outputting anything decoded. This may be because of the signal quality or something as it is definitely going through the decoder loop.
I compiled it on 2 separate machines and it works as expected, both with raw SDR samples and raw soundcard samples. The decoder functions don't care about sample sizes, it just eats up available samples until the callback runs (if data is received). It is fairly particular about quality however. If you are using an SDR try offsetting the PPM a few points either way until the decoder fires.
For me, it really does need the smaller buffer size. It works very reliably at 2048. The LimeSDR does not have PPM adjustment. It's clock is 1 PPM with a maximum drift of 4 PPM. I have found it to be more accurate than that. I can adjust the center frequency in 1 Hz increments though. It hasn't seemed to make any difference +-50 Hz. There are other adjustments for RF bandwidth, FM deviation, and gain, that make a difference to audio quality. I have used aplay to listen while I adjust these for the clearest sound to my ears. I'm not sure that is what the decoder wants, though. I have gotten it to fire. Strangely, it only does it when I'm not looking. If I leave it running and the screensaver comes on and I come back later, there will be a list of results. If I watch it it will never fire. Maybe my display adapter is interfering somehow. Or it could be some process in the background that stops when the screen goes dark.
Try again now - just did a major overhaul. Decoding has a way larger margin now. Check the readme for notes.
Hi, I am trying to interface wit a program that outputs raw audio on a UDP port. I use netcat to open a pipe from UDP to stdout and start 'demod 1 -'. This segfaults as soon as it goes up. Netcat by itself streams a lot of raw bytes OK as there is audio to output. I tried demod without the pipe going and demod waits after being started. As soon as I type something and hit enter it segfaults. Strace shows an si fault. I have tried a lot of sox and nc commands to read from the audio or UDP streams but I can get no output from the demod or the python program. I am using a LimeSDDR with SDRangel.