Well, so I was reading about this raspberry pi tutorial that makes you play audio files from raspberry pi and stream them into a FM signal and something got me curious. You can stream .wav files, which is ok, but there's a command that makes it stream live audio from the microphone.
I'm curious about how it works. This is the command:
arecord -d0 -c2 -f S16_LE -r 22050 -twav -D copy | sudo ./pifm -
Well, I'm curious about how it works. I've searched and understood that arecord is a program that records audio from your microphone. It has an option where you can write the file name and it'll save the recorded file to you. But in this example, something is happening: it looks like the audio is going directly to python, live. I mean, how is this possible? Is the program arecord feeding python with sound data?
I've only seen this syntax in this command, for example:
cat file.txt | grep 'test'
which is a way of reading the file 'file.txt' but only output the lines with 'test' written in it.
So, what does, in general, the symbol | mean in linux? What is happening when he does | sudo ./pifm after some program?
I really liked this possibility in linux, it's something I've never seen before. Am I right about my assumptions? Also, how does python receive this data? Is there a library for this?
cat file.txt | grep 'test'can be replaced withgrep 'test' <file.txt(catwith a single file can almost always be removed).