Changes between Initial Version and Version 1 of mycroft_mark-2_sound


Ignore:
Timestamp:
04/12/20 08:57:52 (4 years ago)
Author:
admin
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • mycroft_mark-2_sound

    v1 v1  
     1=== Adafruit Volume control ===
     2I 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] ).
     3The things that I had to do:
     4==== Install the library ====
     5while in (.venv)
     6* pip3 install RPI.GPIO
     7* pip3 install adafruit-blinka
     8==== Enable I2C ===
     9I2C is not enabled by default so run and enable I2C in the Interfacing Options
     10==== Python script ====
     11Use 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
     12* nano ~/bin/ada_volume.py
     13{{{
     14import board
     15import busio
     16import adafruit_max9744
     17i2c = busio.I2C(board.SCL, board.SDA)
     18amp = adafruit_max9744.MAX9744(i2c)
     19amp.volume = 30
     20}}}
     21==== Start using systemd ====
     22Place a service file in the user directory:
     23* nano ~/.config/systemd/user/myadavolume.service
     24with the content
     25{{{
     26[Unit]
     27Description=set adafruit volume
     28After=network.target
     29
     30[Service]
     31Type=simple
     32ExecStart=/home/pi/mycroft-core/.venv/bin/python /home/pi/bin/ada_volume.py
     33
     34[Install]
     35WantedBy=default.target
     36}}}
     37Enable and start it:
     38* systemctl --user daemon-reload
     39* systemctl --user enable myadavolume
     40* systemctl --user start myadavolume
     41
     42=== Pulseaudio ===
     43The picroft installation does not use pulseaudio for the output of voice and other sound so the general volume control did not work
     44==== blacklist the internal bcm2835 sound card ====
     45This is for sure totally optional but I did it
     46* sudo nano /etc/modprobe.d/alsa-blacklist.conf
     47{{{
     48blacklist snd_bcm2835
     49}}}
     50==== force ALSA userspace to use PulseAudio ====
     51* sudo nano /etc/asound.conf
     52{{{
     53# Use PulseAudio by default
     54pcm.!default {
     55  type pulse
     56  fallback "sysdefault"
     57  hint {
     58    show on
     59    description "Default ALSA Output (currently PulseAudio Sound Server)"
     60  }
     61}
     62
     63ctl.!default {
     64  type pulse
     65  fallback "sysdefault"
     66}
     67}}}
     68==== mycroft conf ====
     69* sudo nano /etc/mycroft/mycroft.conf
     70replace:
     71{{{
     72   "play_wav_cmdline": "aplay -Dplughw:ArrayUAC10,0 %1",
     73   "play_mp3_cmdline": "mpg123 -a plughw:ArrayUAC10,0 %1",
     74}}}
     75with
     76{{{
     77   "play_wav_cmdline": "paplay %1",
     78   "play_mp3_cmdline": "mpg123 %1",
     79}}}
     80==== additional setting in default.pa ====
     81This enables ducking and is a nice feature that the volume of music playing is turned down while Mycroft speaks instead of stopping the output.
     82* sudo nano /etc/pulse/default.pa
     83add to the end of the file
     84{{{
     85unload-module module-suspend-on-idle
     86unload-module module-role-cork
     87load-module module-role-ducking
     88}}}