19 | | === Adafruit Volume control === |
20 | | I am controlling the volume of the MAX9744 using the CircuitPython Libraries (see [https://learn.adafruit.com/circuitpython-on-raspberrypi-linux/installing-circuitpython-on-raspberry-pi] ). |
21 | | The things that I had to do: |
22 | | ==== Install the library ==== |
23 | | while in (.venv) |
24 | | * pip3 install RPI.GPIO |
25 | | * pip3 install adafruit-blinka |
26 | | ==== Enable I2C === |
27 | | I2C is not enabled by default so run and enable I2C in the Interfacing Options |
28 | | ==== Python script ==== |
29 | | Use this script to set the initial volume to about the half (the range is 0 to 63). Create ~/bin/ada_volume.py with the following content |
30 | | * nano ~/bin/ada_volume.py |
31 | | {{{ |
32 | | import board |
33 | | import busio |
34 | | import adafruit_max9744 |
35 | | i2c = busio.I2C(board.SCL, board.SDA) |
36 | | amp = adafruit_max9744.MAX9744(i2c) |
37 | | amp.volume = 30 |
38 | | }}} |
39 | | ==== Start using systemd ==== |
40 | | Place a service file in the user directory: |
41 | | * nano ~/.config/systemd/user/myadavolume.service |
42 | | with the content |
43 | | {{{ |
44 | | [Unit] |
45 | | Description=set adafruit volume |
46 | | After=network.target |
47 | | |
48 | | [Service] |
49 | | Type=simple |
50 | | ExecStart=/home/pi/mycroft-core/.venv/bin/python /home/pi/bin/ada_volume.py |
51 | | |
52 | | [Install] |
53 | | WantedBy=default.target |
54 | | }}} |
55 | | Enable and start it: |
56 | | * systemctl --user daemon-reload |
57 | | * systemctl --user enable myadavolume |
58 | | * systemctl --user start myadavolume |
59 | | |
60 | | === Pulseaudio === |
61 | | The picroft installation does not use pulseaudio for the output of voice and other sound so the general volume control did not work |
62 | | ==== blacklist the internal bcm2835 sound card ==== |
63 | | This is for sure totally optional but I did it |
64 | | * sudo nano /etc/modprobe.d/alsa-blacklist.conf |
65 | | {{{ |
66 | | blacklist snd_bcm2835 |
67 | | }}} |
68 | | ==== force ALSA userspace to use PulseAudio ==== |
69 | | * sudo nano /etc/asound.conf |
70 | | {{{ |
71 | | # Use PulseAudio by default |
72 | | pcm.!default { |
73 | | type pulse |
74 | | fallback "sysdefault" |
75 | | hint { |
76 | | show on |
77 | | description "Default ALSA Output (currently PulseAudio Sound Server)" |
78 | | } |
79 | | } |
80 | | |
81 | | ctl.!default { |
82 | | type pulse |
83 | | fallback "sysdefault" |
84 | | } |
85 | | }}} |
86 | | ==== mycroft conf ==== |
87 | | * sudo nano /etc/mycroft/mycroft.conf |
88 | | replace: |
89 | | {{{ |
90 | | "play_wav_cmdline": "aplay -Dplughw:ArrayUAC10,0 %1", |
91 | | "play_mp3_cmdline": "mpg123 -a plughw:ArrayUAC10,0 %1", |
92 | | }}} |
93 | | with |
94 | | {{{ |
95 | | "play_wav_cmdline": "paplay %1", |
96 | | "play_mp3_cmdline": "mpg123 %1", |
97 | | }}} |
98 | | ==== additional setting in default.pa ==== |
99 | | This enables ducking and is a nice feature that the volume of music playing is turned down while Mycroft speaks instead of stopping the output. |
100 | | * sudo nano /etc/pulse/default.pa |
101 | | add to the end of the file |
102 | | {{{ |
103 | | unload-module module-suspend-on-idle |
104 | | unload-module module-role-cork |
105 | | load-module module-role-ducking |
106 | | }}} |
| 19 | [wiki:mycroft_mark-2_spotify Mycroft Mark II - Spotify using Pulseaudio] |