3 ms·
Ask HN: Cross platform method for accessing system audio output?
I was hoping to create a desktop app that analyses the system audio output in real time. Eg. I can analyse audio coming from YouTube, or Spotify, or iTunes. Nothing nefarious, just visualisation.
I looked into Electron’s desktop capture, and it doesn’t work for mac. I also looked at Swift MacOS app, but I don’t think that’s possible without a seperate program called SoundFlower and I don’t think it can be packaged with the macOS app itself.
How might I go about creating a desktop app which can access the audio output feed of the host system?
- blaerk 4y agoPortaudio may be applicable, it supports most platforms I think. http://www.portaudio.com/ http://www.portaudio.com/
- brudgers 4y agoAn oscilloscope reading the headphone jack might be the simplest thing that might work...unless the problem is underspecified.
- eduardosasso 4y agoNot sure how clean you want the audio to be but in a project I’m working on I’m using the input microphone to analyze the audio to build a music visualizer. https://soundq.co https://soundq.co
- minhmeoke 4y agoPerhaps you could use either http://libsound.io/ http://libsound.io/ which provides low-level APIs to access operating-system sound systems like Alsa, PulseAudio, PipeWire, and CoreAudio. Or https://python-sounddevice.readthedocs.io/en/0.4.4/ https://python-sounddevice.readthedocs.io/en/0.4.4/ if you prefer Python. Comparisons: - https://github.com/andrewrk/libsoundio/wiki/libsoundio-vs-PortAudio https://github.com/andrewrk/libsoundio/wiki/libsoundio-vs-Po... - https://github.com/andrewrk/libsoundio/wiki/libsoundio-vs-JUCE https://github.com/andrewrk/libsoundio/wiki/libsoundio-vs-JU... - https://github.com/andrewrk/libsoundio/wiki/libsoundio-vs-SDL2 https://github.com/andrewrk/libsoundio/wiki/libsoundio-vs-SD... SDL2 game library + SDLAudioIn (doesn't appear to support Mac though: http://burningsmell.org/sdl_audioin/ http://burningsmell.org/sdl_audioin/) On a related note, a friend created some visualizations of interesting sounds. If you'd like the source code (Python Jupyter notebooks), please let me know! A few examples: 1. Dialtone using dual-tone multi-frequency signaling and 56K dial-up modem connection: https://www.youtube.com/watch?v=FomWraKuDFg&list=PLn67ccdhCssEJsJE6BnAqqBCDIdQHPFQb https://www.youtube.com/watch?v=FomWraKuDFg&list=PLn67ccdhCs... 2. Deluxe Multitone Car Alarm: https://www.youtube.com/watch?v=A4uKcvZL7HM&list=PLn67ccdhCssEJsJE6BnAqqBCDIdQHPFQb https://www.youtube.com/watch?v=A4uKcvZL7HM&list=PLn67ccdhCs... 3. Composition using only sounds from Windows 98 and XP https://www.youtube.com/watch?v=6lT-jr9sS6Y&list=PLn67ccdhCssEJsJE6BnAqqBCDIdQHPFQb https://www.youtube.com/watch?v=6lT-jr9sS6Y&list=PLn67ccdhCs... 4. Piano Music (Ballade Pour Adeline): https://www.youtube.com/watch?v=RnAfrEk429w&list=PLn67ccdhCssHTboc1l6tK_j-16u9Z3G_8&index=1 https://www.youtube.com/watch?v=RnAfrEk429w&list=PLn67ccdhCs... 5. Electronic Music Demo: https://www.youtube.com/watch?v=MllJLIX1glg&list=PLn67ccdhCssHLdXIUHHNVaO-N8fCY_Wi5&index=1 https://www.youtube.com/watch?v=MllJLIX1glg&list=PLn67ccdhCs...