pMusic is an audio-player using a database (DB) to keep track of meta-information of your music. This is info like:
While most players depends on an external DB like Mysql or Mariadb, pMusic has its own, very simple, internal DB. Basically it is a textfile with 21 columns separated by a |, where each line contains info of one file. When reading from the DB (ie. when searching), we just grab the line(s) corresponding to our request.
To make the infra-structure simple; the DB, the sourcelist (search-result-field) and the internal file format (*.pmd), uses the exact same formating. That means, we can dump the raw output of the DB to the gui, a favorite list, or ie. to the smart-add function. This helps a lot when it comes to speed. Sometimes you might forget that pMusic is not compiled binary, but just a bash script.
GeekNote: To be technically correct, the sourcelist and *.pmd file contains only the first 15 columns of the DB format. They have no use of the last items of info.
The DB structure
Let's look at one line of my DB:
/mnt/sdb1/musikk/Tindrum - Drums Of War.mp3|Tindrum|Drums Of War|Drums of war|1|1988|Hard Rock|Live||mp3|175|04:02|117|/mnt/sdb1/musikk/Tindrum - Drums Of War.mp3|gtk-audio|2aa59ada-3dd8-40b7-878a-bb682fca7b30|479933cd-d787-4126-8315-7749ca4781a1|Tindrum|/mnt/home/pmusic storage/albumart/Tindrum - Drums Of War.jpg||,1357415329,1357417187
This line holds all info we got about this track. Instead of explaining what it all means, just open up the DB-editor found in Menu > Music sources > My Music. Here we can look at, and edit all info in the DB.
Most of this is straightforward, but 3 things might not seem logical:
Writing to the DB
pMusic allows 2 major ways to write info to the DB. Either by (1) user interaction or the default (2) silent mode.
(1) user interaction
The static way is to start the indexer (Menu > Music sources > My Music) which scans your system for audio-files and adds the info to the DB. Depending on your music collection, this might take a long time, but place all available information (ID3-tags and stream info) to the DB at once.
(2) silent mode
The default dynamic behavior is to store info as you play. When you press the Play-button, pMusic
If using mode (1), we still miss info from the web and album lists, so mode (2) will kick in anyway for missing info.
All this info must be written to the DB - but that's not straightforward - we can't just start writing...
The stack is found at $HOME/.pmusic/tmp/mymusic_stack.
The merging is done at func_index -merge_stack.
Keep the DB in shape
In addition, there are mechanisms to keep the DB in shape. When you add a file to the playqueue, pMusic checks it in func_add - functions check_source and fix_db.
If the added file is not already in the DB, ask user to scan the source directory for new music. This message shows up embedded in the main window to not disturb the user too much. It could be that we don't want to respond to this message, and that is just ok.
If the added file has its line in the DB, but not present in your system, something should probably be updated, and this message below will show up. But, if the filename is found in the DB with another path than the defined, pMusic will play the alternative source instead. Therefor, this box is not often seen in recent versions of pMusic.
The Playlist file format
I mentioned earlier the internal file format *.pmd used by ie. the favorites structure. But, for the user, the pMusic format is the *.pmu found in the save box. You can choose to save to an external format as *.m3u or *.pls, but to get the full power of pMusic, *.pmu is the recommended choice. This because it cooperates well with the DB.
*.pmu contains the same info as in the playqueue. This makes it possible to dump a *.pmu into the playqueue, while a *.m3u has to be converted. Since all information in a *.pmu is grabbed from the DB, we can quickly revert, and grab the full track-info back from the DB. This is seen when expanding a *.pmu in the sourcelist (left pane). - We see full track-info including rating calculation. When expanding a m3u/pls we only see the actual info inside the file.
When looking at the playqueue in the gui, you see 3 columns:
Length | Track title | Path
In fact there are 2 more hidden columns, and all are part of the *.pmu file:
Icon | Length | Track title | Path | ID
The Icon holds gtk-play when the play-icon is shown, else it's empty. This will of course always be empty inside a *.pmu file
The ID holds an unique id-number together with the path. This is necessary to avoid conflict when playqueue contains several instances of the same song. The ID keeps track of which of the similar songs you are playing/moving/editing.
Unlike *.m3u, the *.pmu playlist does not handle relative paths. This to stay close to the DB format. Instead pMusic will search for an alternative path if playing track is not found. The statusbar will show this information during search. Code found in func_progressbar.
The short story of the pMusic file formats is:
*.pmd mirrors the DB
*.pmu mirrors the playqueue
This is the basic structure of the pMusic data format.
Edit - Delete
No comments posted yet.