kmel_db
A parser and generator for Kenwood Music Editor Light databases that works under Linux.
Kenwood Music Editor Light is a Windows-only application that creates a database that is used by Kenwood car audio systems to allow searching by album, title, genre and artist. It also allows creation of playlists. I have successfully decoded the file format used for the database, and have written this application to do the same under Linux.
I have two issues with Kenwood Music Editor Light:
- I don't run Windows. I would like to be able to generate the database on the system that I use to manage my media files. This is a Linux system. As usual, the database format is not documented anywhere, so kmel_db is the result of staring at hex for some time.
- It implements playlists very poorly. Essentially you have to copy media files into a directory structure that is below where you usually place your media, and then tell the application the directory levels from which to create the playlists. This means that you now have two copies of each media file - one in the album where it belongs, and one in the playlist. I would like a more intelligent way of processing playlists.
My Kenwood car audio system only supports mp3 and wma media formats, so these formats are currently the default for my implementation. This should be easily extendable, as the library I use to read the media files (hsaudiotag3k) supports the following: mp3, mp4, wma, ogg, flac and aiff.
You'll need Python version 3 or above, and the hsaudiotag3k python package installed to run.
Database Format
The kmel_db_format.md document attempts to explain the format of the database. It might be slightly behind the code.
Generator
To generate a database, just type:
./DapGen.py /path/to/your/usb/drive
If you don't specify the path, the generator will process all mounted partitions of type FAT.
Use the '-h' option to see other options.
Current limitations:
- processes mp3 and wma only at this stage (wma not tested)
- include and exclude regular expression parsing for media types not currently implemented
- processes pls playlists only at this stage
- international characters are sorted out of order, so "Bäpa" comes after "By The Hand Of My Father" rather than after "Banks of Newfoundland"
Parser
To parse a database, just type:
./KenwoodDBReader.py -i /path/to/kenwood.dap/file
It will print copious logs, used by me to analyse the database. I may ask for this output if you want me to look into a problem.
Details
Getting FAT 8.3 filenames in Python
After much searching, I use the fcntl.ioctl function and the VFAT_IOCTL_READDIR_BOTH request code to get the 8.3 DOS names for both the file and the directory. If you find that this is not getting the right result, or there are errors produced by this function call, there is a generate_ioctl.c file that you can build and run to replace the kmeldb/vfat_ioctl.py module. This works on my Linux system, but I have no idea whether it will work on BSD or OSX.
Getting media tags
I use hsaudiotag3k to get the tags from the media files. This is a pure python package, so should be easy to install with few, if any, dependencies.