6 ms·
Thank you! For weeks now I've been thinking about how handy it'd be if I could audibly 'listen' to the output of a command. I had no idea it was as easy as pipi
by brody_hamer 6y ago
Thank you! For weeks now I've been thinking about how handy it'd be if I could audibly 'listen' to the output of a command. I had no idea it was as easy as piping it to aplay.
`tail -f output.txt | aplay`
I know this is a lame takeaway, but I'm just so happy to learn about this.
- kortex 6y agoThis is most decidedly not lame! I'm sitting there looking at the code poem trying to figure out how the sound happens, it looks like it's just writing bytes to a file. I figured there was some driver or something but "sound driver from file" is not super googleable. aplay was the missing link.
- lloeki 6y agoThere’s /dev/dsp that you can write to (and read from). https://en.wikipedia.org/wiki/Open_Sound_System https://en.wikipedia.org/wiki/Open_Sound_System
- slx26 6y agoI find the lack of a common API for audio across OSes a tragedy. The waves are so deadly simple to work with that you could even use them as exercises to start learning programming. You would also need to be aware of the buffer you send the audio samples to; yes, you need to be aware that latency exists, there's no way around that. But in practice it's much more annoying: you have to deal with the APIs on each OS, which treat audio devices differently. Even getting info about the devices might be poorly documented and rather cumbersome, and then each device might or might not support the sample format you need/want, and might or might not support the buffer sizes you need/want. And if you try to work with a language that's not C/C++, then you have to resort to C wrappers to connect to the APIs (which in many languages is not trivial). 99% of the things we want to do could be so easy (give me a format that's 100% supported everywhere, a minimum buffer size supported everywhere, and support for 2 channels everywhere)... but nope.
- PaulDavisThe1st 6y agoWhat's the common API for drawing across OSes? What's the common API for video across OSes? What's the common API for "put this string in a message dialog on the screen" across OSes? And meanwhile there's JACK, RtAudio, PortAudio and several other crossplatform APIs, most of which have wrappers in non-C languages (despite the problems with realtime audio that this can lead to).
- ratww 6y agoLack of a common API is a problem even inside OSs. Here's Windows: http://shanekirk.com/2015/10/a-brief-history-of-windows-audio-apis/ http://shanekirk.com/2015/10/a-brief-history-of-windows-audi... And I disagree that it's deadly simple... Even sound synthesis (where it's "just math") is very hard, because you have to watch out for aliasing. Same if you're changing pitch or doing anything other than playing back a WAV. Also, it's hard-realtime, which limits the programming languages you can use. Then, if you're not using the OS audio mixer (lots of different reasons not to), you gotta do the mixing yourself, which is another can of worms.
- slx26 6y agoI have worked a bit with ALSA and dabbled in VST development and I understand some of these issues. I agree with you, but these are the inherently hard problems that we can't remove; I still believe accessibility can be much improved. By the way, the article you linked is really good, thanks for that. Anyone else reading this discussion will surely be interested in that article too.
- zengargoyle 6y agoThis is a good way to blow out your laptop's speakers. One simple `cat /vmlinuz > /dev/dsp` and poof.
- schwartzworld 6y agoDo you mean hearing it read aloud? I pipe to espeak for that.