How to fix DaVinci Resolve audio issues on Ubuntu 20.10

Hello πŸ‘‹,

To fix audio issues on a fresh install of DaVinci Resolve 18 on my Ubuntu 20.10 PC I did the following things:

1. List all the available sound cards

cat /proc/asound/cards
 0 [NVidia         ]: HDA-Intel - HDA NVidia
                      HDA NVidia at 0xfc080000 irq 94
 1 [AI1            ]: USB-Audio - RODE AI-1
                      RODE Microphones RODE AI-1 at usb-0000:2d:00.3-1.3, full speed
 2 [Generic        ]: HDA-Intel - HD-Audio Generic
                      HD-Audio Generic at 0xfc400000 irq 96
 3 [U0x46d0x81b    ]: USB-Audio - USB Device 0x46d:0x81b
                      USB Device 0x46d:0x81b at usb-0000:2d:00.3-1.4, high speed

List all the available sound cards a chose a default. I like playing audio though my headphones when editing and the headphones are connected to my USB Audio Interface RODE AI-1, this is what I want to use as the default card.

2. Set the default card for Alsa

To set the default card I’ve created a new file /etc/asound.conf and pasted the following contents into it:

   defaults.pcm.card 1
   defaults.ctl.card 1

The number 1 represents the number of the default sound card, in my case it is:

 1 [AI1            ]: USB-Audio - RODE AI-1
                      RODE Microphones RODE AI-1 at usb-0000:2d:00.3-1.3, full speed

After it’s set, reload alsa with: sudo alsa force-reload

3. Start DaVinci Resolve 18 and restart pipewire

Each time you start DaVinci Resolve 18 you may need to run the following command in order to get audio working:

systemctl restart –user pipewire

Note: DaVinci Resolve can’t play AAC audio files on Linux.

Note: Your audio may stop working outside DaVinci resolve while editing and after closing it, to fix it run the above command again.

4. If this breaks your audio on other software

Remove /etc/asound.conf file and restart Alsa & Pipewire. We need to wait for an official fix. 😦


Thanks for reading! I hope you’ll find this useful.

Happy hacking! 🦾

envsubst – Substitute Variables for Environment Variables

Hi πŸ‘‹,

Introduction

In this short article I want to showcase a nice and useful Linux command.

The comand πŸ₯ envsubst πŸ₯. In short it Substitutes the values of environment variables.

It’s great for populating configuration files with values from environment variables, a common operation for developers containerizing their applications.

Example Usecase

Let’s say we are containerizing an application and we have the following file configuration.yaml, and we want to modify the values of the environment field and the log_level field without adding the additional complexity of mounting the configuration.yaml file into the container/pod.

configuration:
  server: "the-app"
  environment: "production"
  log_level": "info"

To change the values of the environment and loglevel fields we create a configuration-template.yaml like so:

configuration:
    server: "the-app"
    environment: "$ENV_ENVIRONMENT"
    log_level": "$ENV_LOGLEVEL"

Then we run eventsubt to substitute the configuration values:

export ENV_ENVIRONMENT=stagging
export ENV_LOGLEVEL=trace

envsubst < configuration-template.yaml > configuration.yaml

The resulting configuration.yaml file will contain:

configuration:
    server: "the-app"
    environment: "stagging"
    log_level": "trace"%  

Conclusion

The envsubst command enables us to write configuration files with placeholders that will be replaced with actual values from the environment variables. Before being aware if this command I always thought that I have to somehow parse the files, substitute variables dynamically, ensure that the substitution didn’t change the file format or break something. Now I just envsubst .

Thanks for reading and happy dev-ing! πŸ–₯οΈπŸ§‘β€πŸ’»

envsubst help

Usage: envsubst [OPTION] [SHELL-FORMAT]

Substitutes the values of environment variables.

Operation mode:
-v, –variables output the variables occurring in SHELL-FORMAT

Informative output:
-h, –help display this help and exit
-V, –version output version information and exit

In normal operation mode, standard input is copied to standard output,
with references to environment variables of the form $VARIABLE or ${VARIABLE}
being replaced with the corresponding values. If a SHELL-FORMAT is given,
only those environment variables that are referenced in SHELL-FORMAT are
substituted; otherwise all environment variables references occurring in
standard input are substituted.

When –variables is used, standard input is ignored, and the output consists
of the environment variables that are referenced in SHELL-FORMAT, one per line.

Report bugs in the bug tracker at https://savannah.gnu.org/projects/gettext
or by email to bug-gettext@gnu.org.

A custom HomeKit accessory with Python

Hi πŸ‘‹,

In this short article I want to showcase how I implemented a custom HomeKit accessory with python.

My Home Assistant’s SD card died πŸͺ¦ a few days ago and the support for GPIO based sensors will be removed in newer releases. This makes it unsuitable for my needs, while giving me the perfect opportunity to try other things.

To continue monitoring temperature and humidity in my home I’ve built a custom HomeKit accessory with HAP Python.

The Sensor

A BME680 air quality sensor is used to monitor temperature and humidity. It is connected to the PI according to the following diagram:

The communication with the Pi is done using the I2C protocol. If you want to use I2C in your own setup, it has to be enabled using raspi-config, as it doesn’t come enabled by default.

# Execute
sudo raspi-config
# Then select Interfacing options->I2C and enable it.

Connection can be tested with the following command:

sudo apt-get install build-essential libi2c-dev i2c-tools python-dev libffi-dev git
/usr/sbin/i2cdetect -y 1
pi@raspberrypi:~ $ i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:                         -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- 76 -- 

It will output the address that the sensor is using, in our case the 0x76 I2C address.

The Code for the Accessory

You can browse the full code for the accessory and bme680 sensor in my git repo.

To run the program, clone the repository and ensure that you’re running it under the pi user, otherwise you will need to change some things.

cd /home/pi && git clone git@github.com:dnutiu/bme680-homekit.git && cd bme680-homekit
sudo apt-get install libavahi-compat-libdnssd-dev
pip3 install -r requirements.txt

Verify that the program works by running python3 main.py. Running it the first time will prompt you to add the accessory to the Home app. If you miss this step you can repeat it by deleting the accessory.state file located in pi’s home directory and by running the program again.

After you’ve verified that it works, you can setup a systemd service to run the accessory’s python script when the PI boots

Copy the bme680-homekit.service to /etc/systemd/system and check that the service is running.

sudo cp bme680-homekit.service /etc/systemd/system
sudo systemctl status bme680-homekit

If you want to run this under another user rather than the pi, you’ll need to tweak the bme680-homekit.service file.

Congratulations for making it this far! πŸŽ‰

You can browse more code examples in the HAP-Python repository.

Thanks for reading and have fun! πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’» βš™οΈ

How to connect Ethernet devices to WiFi via WDS

Hi πŸ‘‹,

In this blog post I will show you how to connect an Ethernet only device to Wi-Fi using an extra router and the WDS functionality. I initially wanted to install the TP Link Archer T4U WiFi adapter driver on my Ubuntu 20.04 PC but unfortunately the driver is no longer supported.

Since I really needed high internet speed for my PC, I decided to connect it via an Ethernet cable and buy another TP-Link router to use in WDS mode.

WDS mode allows routers to communicate with one another without using wires.

βš™οΈ The configuration of the WDS router is as follows. I left the operation mode in Router Mode.

Then, I navigated to Network -> LAN and set the IP address to 192.168.0.2. Because my old router had the IP address of 192.168.0.1.

The next step would be to navigate to Wireless -> WDS. Click survey and select the SSID of your root router. If the WDS bridging is successfully you should see a Connected message βœ….

Finally, go to Network -> DHCP Server and disable it. All these operations should be performed on the router that you want to bridge, not the root router! πŸ•ΈοΈ

Now that your router has a WDS bridge to the root router, you can connect your PC to it via an Ethernet cable and place it next to your PC. A brand new 5GHz Wi-Fi adapter might have the same price πŸ’° as a new router πŸ€‘, and to be honest unless you’re doing some penetration testing I don’t see the need of a WiFi adapter.

Thanks for reading and happy hacking! 🐧