markondej / fm_transmitter

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

Stdin not working #47

Open gabrielfior opened 7 years ago

gabrielfior commented 7 years ago

Hello, I think the stdin is not working properly. After connecting my Android phone with the Raspberry pi 3 via bluetooth (audio enabled), I send audio by playing a Spotify song, but I cannot play it through by this command

sudo ./fm_transmitter -f 100.6 -
Playing: stdin, 44100 Hz, 16 bits, mono

Thanks in advance for the help

sonich2401 commented 5 years ago

Hey gabrielfior, i know its been 2 years since you wrote this but i hope it can help. I enjoy using this fm_transmitter because its simple to use. However I believe this program has it limitations. I am trying to do the same thing currently except I'm using shairport for the source instead of the Bluetooth. The point is the reason for markondej making the suggestion to convert it using sox my-audio.mp3 -r 22050 -c 1 -b 16 -t wav my-converted-audio.wav to convert the audio to a lower quality. -c makes it mono and -r makes the sample rate drop to 22050 Hz. It looks like you set it to 44100 Hz. I believe that fm_transmitter doesn't support 44100 Hz. Again, I don't completely understand this program but iv'e done enough messing around to know that it may be a problem. Also, were you using sox for stdin? The whole command would be nice. I also don't know what your using for the Bluetooth connection, but the command that might help would be sudo ./shairport-sync/shairport-sync -o pipe -- /home/pi/shairport-sync/fmfifo | sox -t raw -r 22050 -b 16 -e signed-integer -c 1 - -t wav - | sudo ./fm_transmitter -f 100.6 -. Just replace the first command with your Bluetooth service, it needs to write to a stream file like a fifo file it doesn't need to be read but since it writes the audio stream it returns a output that can be piped into the next command. Sox takes the raw data and converts it into a .wav that can be interrupted by the transmitter program. So basically it converts the fifo file into a .wav. However, I believe that PiFmRDS would reap you better results. Just clone it and relace sudo ./shairport-sync/shairport-sync -o pipe -- /home/pi/shairport-sync/fmfifo | sox -t raw -r 22050 -b 16 -e signed-integer -c 1 - -t wav - | sudo ./fm_transmitter -f 100.6 - and replace it with, sudo ./shairport-sync/shairport-sync -o pipe -- /home/pi/shairport-sync/fmfifo | sox -t raw -r 22050 -b 16 -e signed-integer -c 1 - -t wav - | (The Command for PiFMRDS)

The Reason i canon't test this myslef is because im using shairport for the first command. I can't get shairport to work and i don't have the software to test your Bluetooth idea so if your still active I could try to help you.