Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace rtl_fm with UDP or REST implementation #38

Open
wizardishungry opened this issue Mar 28, 2018 · 3 comments
Open

Replace rtl_fm with UDP or REST implementation #38

wizardishungry opened this issue Mar 28, 2018 · 3 comments
Labels
enhancement New feature or request epic question Further information is requested

Comments

@wizardishungry
Copy link
Member

rtl_udp or rtl_fm_python allow us to control an rtl_fm process over a UDP or TCP control socket respectively. Leaning towards the UDP implementation as it should be simpler.

Advantages

  • Easily allows multi dongle setups; right now rtl_fm has statically allocated structures that need to be converted to be per device. I'm not in the business of refactoring rtl_fm.
  • removes threading code; we'll just select on a file handle streaming PCM.
  • Additional tuning parameters:
    • controllable with CV: gain, squelch, decoding mode (FM,AM,USB,LSB)
    • controllable with panel control: auto gain enable
    • will require rtl_fm restart (use context menu): dongle index
  • Removes hacked rtl_fm code from repository; will be included as a submodule & packaged with zip.
  • potentially add other fm decoding modules to the mix
  • Moves all that I/O out of Rack
  • rtl_fm crashes won't crash Rack
  • Allows BSD license for entire module and maintains my copyright, so I can distribute this module linked against my proprietary code for the Pulsum Quadratum module pack.
  • Circumvents GPL licensing issues for adding panel graphics copyrighted by me. I will use a license similar to the Fundamental SVGs. See VCVRack/Rack#854
  • Fixes static linking issue on Linux Problems building static library on Linux #26

Disadvantages

  • Neither implementation has a network transport for PCM data, so we won't be able to add an option to stream from a remote dongle.
  • Potential increase in latency for both PCM data and tuning. Tuning granularity over time is bad right now; you may only tune ~10 times a second. I believe I also modified the rtl_fm sources to not clear the audio buffer after a tuning event. We may need to include a patch to the rtl_fm implementation to replicate this behavior.
@wizardishungry wizardishungry added enhancement New feature or request question Further information is requested epic labels Mar 28, 2018
@wizardishungry
Copy link
Member Author

@davephillips @dizzisound: feedback appreciated

@davephillips
Copy link

Hi Jon ! The proposed changes look good, I'd like to see the expanded capabilities. However, I am concerned about latency and granularity so I'll be watching/testing those aspects for any degraded performance. The module works well for me now but of course I'm always interested in your improvements. :)

@wizardishungry
Copy link
Member Author

  • Granularity – Existing rtl_fm code runs in a bunch of pthreads with a whole mess of synchronization between them. This is from memory but: tuning uses rtlsdr_set_center_freq which blocks for quite a while on each call. I played around with spawning a new thread to make a tuning call, but it looks like there's a a bit of back and forth between librtlsdr and the dongle for each tuning operation - i.e. it isn't just a single message "set dongle frequency". So having multiple rtlsdr_set_center_freq calls running breaks the instance. In short, I don't think this is going to make things much worse, as major limited factor for tuning granularity is librtlsdr chatting with USB not context switching. (Also just came up with EXPERIMENT: Don't wait on hopping mutex to improve tuner granularity. #39 to try to improve our tuning performance in existing architecture. )

  • Latency – there's two layers of buffering going on between the dongle and rack. I'm concerned that right now we're getting further behind on outputting the buffer than we need to be (and never catching up). What about using a popen pipe instead of the second shared memory buffer? Perhaps we could get better performance by seeking to the end of the popened stream on start, attempting to read into a buffer / outputting 0.f until we see data. Dropping a few samples at the start of operation is better than being thousands of samples behind the radio for the duration of operation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request epic question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants