Wednesday, September 27, 2023

Fixing, Updating, or Removing Sound Libraries in DaVinci Resolve / Fairlight


Problem

Sometimes our sound files get moved around or possibly removed, but as of DaVinci Resolve 18.6 managing your sound library is still a bit challenging. In my case, I had files that were removed but they continued to show up in my searches, they just would not playback and were obviously unusable. 

Solution

Note: this solution requires modifying a program database in a way which could interrupt the proper functionality of your application. While I take steps to try and prevent any corruption, I admit I do not fully understand everything Resolve is doing with that database and this could have side-effects. If you find your file has been corrupted beyond repair, a clean install may be required. My results have been successful, but you are doing any of these things at your own risk.  

Resolve stores your information relating to your local sound library in a SQLite database. If for some reason your setup is different than mine (like for instance if it is being stored in Postgres), I imagine many things will translate, but it won't be exact and you will need to do the research required to handle that situation. 

The first thing you need to do is find the SQLite database where the sound information is stored. You can do this by opening the Project Manager window, and in Local Database, right-click and choose Open File Location.

The folder that opens will contain a folder called Resolve Projects, open that to find a SQLite file called SoundLib.db. Now close down DaVinci Resolve. Start by making a copy of this file! Name it something like SoundLib_bkup.db. It's good practice to never mess with the working version of something so that you can restore the working copy later if something goes awry. With your back-up file securely in place, the easiest way to edit our working database SoundLib.db is to use a visual database program like SQLiteStudio (which is free and open source) and then connecting the SQLite database. Once connected, you should see a list of tables like these on the left-hand side.


A database is a way to organize data. With SQL type databases, it is often best to think of it like spreadsheets, where one spreadsheet is a table. The tables we are looking for start with FLAsset which I assume stands for Fairlight Asset. 

If we double-click on FLAssetBaseClip table and click the Data tab at the top, we see a table (or spreadsheet) or information associated with these assets. 


Now double-click on the FLAssetBaseContainer table, then click the Data tab again to see what is in the table. You should see one or more rows. One column is called path and seems to contain all the paths Resolve is using to search for media.  Note the FLAssetBaseContainer id. This is the ID associated with individual media assets so that they can have a relationship (or association) with each other. 


For me, the path no longer valid is D:\CorrLabs Drive Backup\Video Resource\Fairlight Sound Library

Fortunately, the tables are set up with cascading actions, which means if we remove one record, it can trickle some effects down into other tables helping us clean things up. We are going to leverage this to make our job simpler. With a SQLite file backup in place, click the row you wish to delete and then click the red icon with a line through it (on hover it will say: Delete selected row). 
 

Once you click this, the row will blank out. This is a preview of the action that is about to take place. If you selected the incorrect row, you can click the red icon with a white X (rollback) on it to undo that. If you have the right row selected that you wish to continue to remove it, click the green icon with a white checkbox. This will make your change to delete this row. 

Now the FLAssetBaseFile table will have lost the container_cookie reference (which is actually the ID we noted earlier), so let's go clean those records up. Right-click on the FLAssetBaseFile table and choose Generate query for table -> SELECT.

Delete the existing query (SELECT...) and paste: 
DELETE FROM FLAssetBaseFile where container_cookie is null;

And now hit the blue play icon at the top of the query window to run it.

The Status window will give us insight into how many records were removed. 


Now you can disconnect from your SQLite database (the plug disconnecting icon near the top left), close your SQLiteStudio and launch Resolve.

The sounds associated with the old library location should no longer appear in Fairlight!



For Errors: If you ran into an error during this process, first close the SQLite editor (SQLiteStudio) and Resolve without saving anything. With those programs closed, rename the SoundLib.db file to something like SoundLib_bad.db, and rename SoundLib_bkup.db (created from before) to SoundLib.db and restart Resolve. You should now (hopefully) have a sound library state that was the same as before any of this process took place. 




 


Saturday, September 16, 2023

Driving a Max98357 with an ESP32C3 single processor arduino

Max98357

For part of a hobby project, I wanted to replace a piezo buzzer with a speaker. I have heard Arduino can drive speakers directly with PWM (never done it myself), but instead I decided to add a max98357 amp and leverage the ESP32 I2S capabilities to drive it using the Arduino Audio Tools library. 

After first connecting things up, as most people do (all GPIOs should work the same for ESP32), I went to play an audio file from littlefs. The noise produced sounded nothing like the MP3 I was trying to play. To remove some complexity, I changed my code to instead produce a sine wave using the libraries generator functions. The result of this was kind of a really crackly sine tone. One thing I noticed early on was that there was a periodic clicking/popping sound that seemed pretty consistent. I went through and switched out the amp, the Arduino, and the speaker in an attempt to figure out what was causing the problem. A larger speaker helped add some clarity to the tone, but didn't get rid of the clicking noise. I also reduced the sine wave amplitude effectively reducing its volume to make sure it wasn't something to do with peaking. My code looked kind of like this at the time:

AudioInfo info(44100, 2, 16); // sample_rate, channels, bits_per_sample
SineWaveGenerator<int16_t> sineWave(32000);                // subclass of SoundGenerator with max amplitude of 32000
GeneratedSoundStream<int16_t> sound(sineWave);             // Stream generated from sine wave
// CsvOutput<int32_t> out(Serial);
I2SStream out;  // Output via I2S
VolumeStream volume(out);
StreamCopy copier(out, sound);

The VolumeStream did not work at the moment, not sure why. Changing the 32000 value reduced the volume of the tone just fine. 

The speakers I ultimately wanted to use for this project were tiny 10mm or 15mm loud speakers, which seem to get hot after running for some time. I guessed that the crackling sound could be straining the speaker and contributing to this issue. 

Finally, after playing around with DMA buffer counts and sizes, I tried reducing the sample rate (as referenced by the author of Arduino Audio Tools blog). That seemed to help solve the crackling/popping issue.

After running the tiny speakers for a little bit with the sine wave tone, they still seem to get hot, but if I only use the speaker periodically and for short form things, I think that will work ok. 

Next I needed to get audio files playing back from littlefs, and possibly using the MP3 decoder or Orvis decoder to keep my file sizes small. We'll see how this little chip can handle loading and playing back files with decoding on top of the other processes. 

Saturday, September 2, 2023

PIO Adding a New Board for Lolin ESP32-C3 Pico

There is a sense that things are right in the world when things are just like they should be. One such instance is declaring an Arduino board that has not been done so yet. 

Fortunately, the board is fairly similar to another board, so my work was minimal. But here is what I had to do:

Add a new JSON file for the board:

C:\Users\CorrLabs\.platformio\platforms\espressif32\boards\lolin_c3_pico.json

In this file I had to update some values like name and variant. Also, I double-checked the board hardware IDs, CPU, flash, and upload settings.

The variant name is used to find the additional files used by these boards. In my case, it is just one file, pins_arduino.h, which I added here:

C:\Users\CorrLabs\.platformio\packages\framework-arduinoespressif32\variants\lolin_c3_pico\pins_arduino.h

Note the folder name matches the variant name from the JSON file before. The data for that file had to be verified by looking at the published specifications for the board.

Source:

https://gist.github.com/mcorrigan/1aec03bd57453a409494d585cb142e6d


Notes:

https://docs.platformio.org/en/latest/platforms/creating_board.html

https://docs.espressif.com/projects/esp-idf/en/v4.3/esp32c3/hw-reference/chip-series-comparison.html

https://www.espressif.com/sites/default/files/documentation/esp32-c3_datasheet_en.pdf (ESP32-C3FH4)

https://www.wemos.cc/en/latest/c3/c3_pico.html (pins)

https://mischianti.org/2023/06/12/wemos-lolin-esp32-c3-pico-high-resolution-pinout-and-specs/



The Lobster Pickleball Machine Power Chargers and Batteries

These are my personal notes. Apply at your own risk. 


Note: Although the found label on the wall wart says 13V, at least one motor and the battery are all 12V which but one motor might be 12.5VDC. To be safe, I imagine it is probably better to under-voltage a device than overvoltage.


We went to sell the Lobster Pickleball Machine and could not find the power supply.

Standard Chargers

The information is a bit tough to find online. Even the machine itself does not list the power specifications which is unusual. After a lot of searching, I finally found a video showing the specs of the standard charger. As you can see, it says it is 13VDC or 13 volts DC and 1 Amp (1000 mA).

 

13VDC and 1A w/ Barrel Connector (source: YouTube video

Standard Charger w/ XLR Connector


Specifications:
Input: 120 VAC 60Hz 16W
Output: 13VDC 1A
Model: DV-1280-5
Connector: Male 3-pin XLR or Male Barrel 5.5mm x 2.5mm (or possibly 5.5mm x 2.1mm; but 2.5mm felt snug)

Similar power supplies from many Chinese suppliers are about $15-$20 on Amazon but the reviews can range widely as to their effectiveness. At the time of writing, Lobster Sports sells the Lobster Standard XLR Charger for about $35. The website says this comes standard on all Lobster Pickleball Machines, like The Pickle, The Pickle Two, and The Pickle Champion and will work on any machine purchased since January 2009. The Lobster seems to come with both a barrel jack charging port and an XLR style connector port.  
5.5mm OD and 2.5mm Male Barrel Connector

Premium Chargers

Premium charger from Lobster Sports currently sells for about $150. 

Lobster 3-Amp Premium Charger w/ XLR Connector

Premium Charger w/ XLR Connector


As far as I can guess, the premium charger is likely 13VDC 3A, allowing the device to charge quite a bit faster. Also, the premium charger has trickle charge capabilities, which tend to be better for the health of battery and can stay plugged in all the time. The connector on these chargers seems to often feature an XLR-style male connector. One reviewer on Amazon said he had luck with a $30 similar option, the "SONEIL CHARGER 1206SX2 100-240VAC IN 12V 3A OUT 3 PIN XLR CONNECTOR POWER SUPPLY." Not sure if trickle-charge logic would make exact voltage more important. 

Specifications:
Input: 100-240 VAC ~1.5A (MAX) 50/60Hz
Output: 13VDC(?) 3A (not sure on voltage but I assume it would be the same)
Model: ?
XLR Socket Replacement Part Model #E886


Battery

The battery inside the Lobster machines is a fairly standard rechargeable battery. Lobster Sports sells it for $85 and lists it as compatible with Elite One, Elite Two, Elite Three, Elite Four, Elite Five, Elite Five LE, The Pickle Two, and The Pickle Champion. These look similar to Power Sonic batteries which end up being a bit cheaper with similar specs. 

Inside our machine, The Pickle, I found this battery, a Zeus 12v 9Ah. Lobster Sports sells this style battery for: Elite Freedom, Elite Liberty and The Pickle.

Zeus 12v 9Ah Battery from The Pickle


Specifications:
Manufacturer: Zeus (confirmed) / Power Sonic (?)
Type: Lead Acid
Amp-hour: 9Ah (maybe some are 18?)
Voltage: 12V


Motors
   
12V Feeder Motor


This server motor almost looks like it's 12.5VDC but is hard to read.



Troubleshooting (See video)

Red/Green Blinking Light on Power Supply - Faulty charger

Charger light stays green on plugging in - Battery may no longer hold a charge, and should be replaced

Double check battery terminals under the plate to ensure proper connections


Notes

https://www.lobstersports.com/products/standard-charger (product page)

https://www.lobstersports.com/products/premium-charger (product page)

https://pickleballcentral.com/3-amp-premium-charger-for-pickle-ball-machine/ (product page)

https://www.youtube.com/watch?v=WHEmS4imDBs&t=158s (machine overview)

https://www.doittennis.com/lobster/ball/tennis-machine-xlr-charger-socket-replacement-part (product page)

https://www.amazon.com/Lobster-Sports-3-Amp-Premium-Charger/dp/B000XCOF0G (product page)

https://www.youtube.com/watch?app=desktop&v=g-MubGr--Qw (troubleshooting the lobster)

https://www.lobstersports.com/products/battery-large-12-volts-elite-one-elite-two-elite-three-elite-four-elite-five-elite-five-le-and-the-pickle-two (battery)

https://www.amazon.com/Power-Sonic-Genuine-PS-12180NB-Rechargeable-Battery/dp/B00BMUEN9Q (suspected battery for some machine?)

https://www.newark.com/zeus-battery-products/pc9-12sf2/rechargeable-battery-12v-9ah/dp/13AJ3015 (the battery mine had)

https://www.lobstersports.com/products/battery-small-elite-freedom-elite-liberty-the-pickle (battery for The Pickle)

https://europe1.discourse-cdn.com/arduino/original/4X/a/4/9/a4959e12c4f50653e7ec45ce0e252f422fdf1c93.jpeg (maybe the same motor as the 12.5VDC possible?)