3

i wanted to ask you guys, if it is possible to use the Raspberry Pi as a transmitter from a audio source, lets say a TV for example. I want to send the sound from the TV to the Raspberry Pi via audio Jack and then send the sound via Bluetooth to a wireless speaker. So the Rasberry should act like a bridge between TV and the speaker.

It should look like this in the end:

TV --Sound via audio jack--> Raspberry Pi ~~Sound via Bluetooth~~> speaker

So, if there is a way, how can i do this ? Thanks in advance

Abhishek kumar
  • 4,347
  • 8
  • 29
  • 44
VDuc
  • 55
  • 1
  • 9

2 Answers2

2

RPi doen't have audio input. You need one of these adapter like this (http://raspberry-projects.com/pi/pi-hardware/audio-input) and connect input to TV and RPi output to wireless / bluetooth speakers. I haven't tried it yet. Let me your feedback.

4runl0g
  • 21
  • 2
2

Since a web search might bring others here as it did me, here's how I did this connecting my record player through a Raspberry Pi 3 to a Bose Portable Home/Smart Speaker.

Get an audio input into the Pi

I used a cheap USB soundcard bought on Adafruit

Identify your new PulseAudio input/source and note name

This can be done by calling pactl list sources (mine was identifiable from its name and description)

$ pactl list sources
...
Source #2
        State: RUNNING
        Name: alsa_input.usb-GeneralPlus_USB_Audio_Device-00.mono-fallback
        Description: USB Audio Device Mono
...

Connect your Pi to your bluetooth speaker

  1. Run sudo bluetoothctl (running this without sudo resulted in settings being forgotten upon reboot) and enter the commands below
  2. (Optional) Give your Pi an alias when connecting over bluetooth: [bluetooth]# system-alias 'Your New BT Alias'
  3. Enter scanning mode [bluetooth]# scan on
  4. Put your speaker in pairing mode and wait for it to be listed in the rolling output. E.g.
[NEW] Device AA:AA:AA:AA:AA:AA AA-AA-AA-AA-AA-AA
[NEW] Device BB:BB:BB:BB:BB:BB BB-BB-BB-BB-BB-BB
[NEW] Device CC:CC:CC:CC:CC:CC My speaker's name
  1. Pair with it referencing its address:
[bluetooth]# pair CC:CC:CC:CC:CC:CC 
Attempting to pair with CC:CC:CC:CC:CC:CC
[CHG] Device CC:CC:CC:CC:CC:CC Connected: yes
Request confirmation
[agent] Confirm passkey 123456 (yes/no): yes
  1. Connect to the speaker now
[bluetooth]# connect CC:CC:CC:CC:CC:CC 
Attempting to connect to CC:CC:CC:CC:CC:CC
[CHG] Device CC:CC:CC:CC:CC:CC Connected: yes
Connection successful
  1. Trust the speaker so it is automatically connected to when available
[My speaker's name]# trust CC:CC:CC:CC:CC:CC 
[CHG] Device CC:CC:CC:CC:CC:CC Trusted: yes
Changing CC:CC:CC:CC:CC:CC trust succeeded

Note your bluetooth speaker's associated PulseAudio output/sink name

This can be done by calling pactl list sinks (again, should be identifiable by name and description)

$ pactl list sinks
...
Sink #2
        State: RUNNING
        Name: bluez_sink.CC_CC_CC_CC_CC_CC.a2dp_sink
        Description: My speaker's name
...

Set up PulseAudio defaults

  1. Identify a good volume level for your input so distortion is minimal. E.g.
pactl set-source-volume alsa_input.usb-GeneralPlus_USB_Audio_Device-00.mono-fallback 16000
  1. Add your version of the following lines to /etc/pulse/default.pa to set up an audio loopback and ensure the correct devices (based on the names you noted above) are used by default:
### Make some devices default
set-default-sink bluez_sink.60_AB_D2_57_42_A9.a2dp_sink
set-default-source alsa_input.usb-GeneralPlus_USB_Audio_Device-00.mono-fallback

# Set up loopback
load-module module-loopback latency_msec=1

# Set input volume
set-source-volume alsa_input.usb-GeneralPlus_USB_Audio_Device-00.mono-fallback 16000
esmail
  • 517
  • 11
  • 9
  • I ended up having to set up Pulse to run [system-wide](https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/SystemWide/) for this to work without needing an active SSH session. Will update when I get the chance. – esmail Aug 11 '22 at 15:08