我如何在Raspberry Pi上进行声音传输

你好

最近,我需要通过覆盆子将声音传输到音频系统,我想分享自己的调音经验。

步骤0。准备

我们需要:

  • 直臂;
  • Raspberry Pi(如果没有Wi-Fi或蓝牙的Raspberry Pi,我们会购买合适的);
  • 5V 2A充电器,用于为Raspberry Pi供电;
  • 最低8GB SD卡。

步骤1.安装

1.转到raspberry网站上的下载部分,然后下载Raspbian(非精简版)

2.解压缩档案

3.格式化SD卡:

  • 删除所有分区(Mac-磁盘实用程序,Windows-创建和格式化,Linux-gparted);
  • 创建1个主要部分。

4.1我们写入USB闪存驱动器(Windows):

  • 下载Win32DiskImager程序;
  • 在Win32DiskImager中打开Raspbian映像;
  • 选择介质的字母;
  • 单击写入。

4.2我们写入USB闪存驱动器(Mac / Linux):

  • 下载Etcher程序;
  • 在Etcher中打开Raspbian图像;
  • 选择一个运营商;
  • 点击Flash。

5.我们拉出SD卡并将其插入计算机,然后打开唯一的部分(应称为BOOT)。 在此处创建一个ssh文件。

6.将SD卡插入Raspberry Pi

步骤2.设定

1.找出我们的Raspberry Pi的IP地址

2.通过SSH连接到它。 我更喜欢腻子

3.登录,登录:pi,密码:raspberry

4.我们将其写入控制台

sudo apt-get upgrade sudo apt-get install bluez pulseaudio-module-bluetooth python-gobject python-gobject-2 bluez-tools sudo usermod -a -G lp (   - pi) 

5.我们写这个

 sudo nano /etc/bluetooth/audio.conf 

然后进入文本编辑器 在题词[一般]下添加

 Enable=Source,Sink,Media,Socket 

点击Ctrl + O,Ctrl +X。

6.接下来,我们规定:

 sudo nano /etc/pulse/daemon.conf 

在这里,我们正在寻找字符串“ resample-method = speex-float-3”。 如果不是这一行的开头; -添加它。

之后,我们进入

  resample-method = trivial 

再按一次Ctrl + O Ctrl + X

7.我们再次规定:

 sudo nano /etc/bluetooth/main.conf 

在这里,我们可以通过编辑“名称”行将设备名称更改为其他任何名称(如果此行是#,则将其删除,然后编辑我们希望其看起来类似于“ Name= ”的Name=

接下来,查找字符串“ Class ”,如果它位于#我们将其删除之前,则使它像这样

 Class=0x20041C 

8.自动启动

1.在/etc/init.d/中创建OnBluetooth文件(sudo nano /etc/init.d/OnBluetooth)。 进入他
写这个:

 #!/bin/bash #Start systemctl service sudo systemctl start bluetooth sleep 1 #Start bluetoothctl with discoverable and pairable options echo -e 'power on\ndiscoverable on\npairable on \t \nquit' | bluetoothctl 

2.用konosl写

  chmod 755 /etc/init.d/OnBluetooth 

3.写入控制台

  update-rc.d OnBluetooth enable 

9.选择音频输出的位置。 为此,我们规定了sudo raspi-config ,然后转到“声音高级”并选择所需的那个。 之后,单击完成。 做完了!

步骤3.连接

蓝牙连接立即可用,现在是时候建立Internet连接了。

对于Windows:

●在方便的地方下载并解压缩归档文件
●编辑audio.bat文件:

  1. 您的IP更改为ip您的树莓派
  2. 用户名更改为从树莓派登录
  3. 我们将密码更改为树莓派登录名的密码

●启动

步骤4.验证。

  • 打开Raspberry PI
  • 我们将音频系统或耳机连接到在raspi-config中选择的端口。
  • 打开手机上的蓝牙或打开计算机上的文件
  • 打开音乐
  • 欢喜

结论


我希望至少有人对本文有用。 谢谢您的关注。

Source: https://habr.com/ru/post/zh-CN427453/


All Articles