markondej / fm_transmitter

Raspberry Pi as FM transmitter
1.32k stars 292 forks source link

[NOT AN ISSUE, QUESTION] How to transmit the audio of the raspberry (not a file, not a microphone) #144

Closed ghost closed 2 years ago

ghost commented 3 years ago

Hi so I'm using a music bot that plays songs from youtube into the raspberry, so if I plug headphones to it I can listen songs. Is there any way I can transmit the audio played in the raspberry to fm? I could't find any parameters to do that.

hydranix commented 3 years ago

Here's what I do.

First I load the alsa loopback module.

modprobe snd-aloop

This creates a loopback audio device.

Then I use the arecord program. (part of alsa-utils package if you use ArchLinux)

I pipe the output of arecord to fm_transmitter like this:

arecord -D hw:0,1,0 -c 1 -d 0 -r 44100 -f S16_LE|fm_transmitter -f 102.5 -

Now just play your audio through the loopback device. Be sure to use subchannel 0

aplay -D hw:0,0,0 -c 1 -r 44100 -f S16_LE /path/to/audio.file

Or you use arecord your microphone and pipe it into aplay to loopback device. You can also do some more interesting things like mix your mic into the playing audio file. Kind of like a live DJ...

markondej commented 2 years ago

I've added these informations in readme file

fuadxtps23 commented 1 year ago

Here's what I do.

First I load the alsa loopback module.

modprobe snd-aloop

This creates a loopback audio device.

Then I use the arecord program. (part of alsa-utils package if you use ArchLinux)

I pipe the output of arecord to fm_transmitter like this:

arecord -D hw:0,1,0 -c 1 -d 0 -r 44100 -f S16_LE|fm_transmitter -f 102.5 -

Now just play your audio through the loopback device. Be sure to use subchannel 0

aplay -D hw:0,0,0 -c 1 -r 44100 -f S16_LE /path/to/audio.file

Or you use arecord your microphone and pipe it into aplay to loopback device. You can also do some more interesting things like mix your mic into the playing audio file. Kind of like a live DJ...

not working for me, but working for me is this command arecord -c 2 -f S16_LE -r 44100 | sudo ./fm_transmitter -f 100.6 -d 255 -

alheyne commented 1 year ago

So if I wanted to play a movie file(for projection mapping to my house) how might I re-direct the audio out from vlc media player to fm_transmitter? Any help would be greatly appreciated. thanks in advance.

hydranix commented 1 year ago

So if I wanted to play a movie file(for projection mapping to my house) how might I re-direct the audio out from vlc media player to fm_transmitter? Any help would be greatly appreciated. thanks in advance.

It's pretty simple. Scroll up to my comment about using an alsa loopback device.

Then just point VLC's audio output to the loopback device and thats it.

vlc --alsa-audio-device hw:0,0,0 --alsa-audio-channels 2 <rest of your vlc commandline>

I haven't tested the above command, but that should give you enough info to get it going.