Where does the B2 store the load sequence of CDs?

333 views
Skip to first unread message

Mark Fishman

unread,
Apr 10, 2019, 1:47:10 PM4/10/19
to Brennan Forum
How does the B2 know what was loaded first? OK, if a b2db file exists, I can sort of see that it just tacks new stuff on the end -- although that's obviously harder than just writing a completely new file, since it has to compare what's on the disk with what's already listed in the file in order to avoid duplication or missing items -- but if I just delete the b2db file and run Scan Disk shouldn't it write a completely new file?

I just tested this. I replaced the b2db file that had all my stuff listed with the "empty" one from the SD card, that says there are 0 albums. Then I rebooted (Settings, Maintenance, Reboot). The B2 front panel said I had 0 albums loaded.

Then I ran Scan Disk. All the music was found, and a new b2db file was written. It's exactly the same size as the previous one -- I saved a copy -- and it has all the same entries in the original sequence. (diff proves the old and new b2db files are exactly the same.)

WTH?? Where did the B2 keep track of what order the CDs were loaded, once I had removed the b2db file? Why didn't it find the artists and albums in the order of a directory listing?

Really, the information had to be kept somewhere, outside the b2db file, to persist through this process.

Daniel Taylor

unread,
Apr 10, 2019, 4:38:11 PM4/10/19
to Brennan Forum
 Hmmm... Good question.  I don't really know.  But I wonder if the order comes from how the files are stored on the hard disk.  I know Windows File Explorer will sort things for you in alphabetical order.  But it will also sort by Date Modified.  That information is kept on the hard disk. 

Mark Fishman

unread,
Apr 10, 2019, 8:30:44 PM4/10/19
to Brennan Forum
It is possible that the behavior is an artifact of the FAT32 filesystem used in the B2. Brennan claim that they use FAT32 because Windows doesn't natively read ext4, which avoids answering the question of why they don't use NTFS.

NTFS sorts directory entries on-disk; FAT32 and ext4 do not. For the most part, a FAT32 or ext4 filesystem will keep directory entries in the order of their creation (not necessarily the same order as creation date or time). Usually people notice this if they have a music player (or a car audio system) that doesn't sort but plays files in the order that they were put onto a USB stick.

There are some utilities to sort a FAT32 directory, including fatsort on Linux, and DriveSort on Windows. I'm going to experiment some more. Rearranging the actual sequence on disk might be useful.

PMB

unread,
Apr 11, 2019, 3:33:01 AM4/11/19
to Brennan Forum
Hi Mark,

I think I'm correct in saying that Martin used FAT32 for the B2 so the files would be compatible with the JB7. Many JB7 owners have since bought B2s and wanted to transfer their music collection.

I'll ask Martin to explain when he is back next week.

Paul
Brennan Support.

AndyC

unread,
Apr 17, 2019, 4:30:33 PM4/17/19
to Brennan Forum
Hi Mark,

Every hard disk drive (HDD)includes a table of all the files on it, and the one in your b2 is no exception. In the b2, this table is the File Allocation Table or FAT (as in 'FAT32') and it records where every track can be found physically on the HDD (which sector etc.). Your b2 uses its own internal database of all the tracks on the HDD - it's called b2db (or b2 data base). It uses this file for pretty much everything related to playing your music - Random Play picks a random track in this database and plays it, simply pressing PLAY makes your b2 play every single track on your HDD in the order they appear in the b2db etc. I think of it as the Master PlayList.

The track info in the FAT and the b2db SHOULD be the same for your b2 to find all your music and play it. Every time you rip a CD, b2 adds the album and tracks to the end of b2db - and the HDD does the same to the FAT. Effectively it's a record of the order in which you ripped them.

However, if you need to use Scan Disk to remake b2db because it has been damaged or deleted or just for general housekeeping, your b2 scans the HDD and builds the new b2db from the FAT on the HDD, the order now being simply the order the tracks happen to be stored on the HDD. This order ends up pseudo-random after a while. The nett effect is that Scan Disk scrambles the original 'as ripped' order and this is the order you see in the central window of the UI when you click either the Artist, Album or Track toggle buttons.

If you now want to alphabetically sort these, go to Settings>Sorting and turn it on. All 3 lists on the UI are now alphabetically sorted. This doesn't change the b2db at all, it simply means the b2 sorts the data on the fly before displaying it. Turn Sorting off and ithe UI display returns to the original b2db order.

Personally, I leave Sorting off and use a program I wrote for my Windows PC to actually sort the order of the information in the B2db into alphabetical order but with the ability to, for example, force the UI to display each artist's albums in chronological rather than alphabetical order. Sure, a PlayList could do this but having dozens, even hundreds, of Playlists gets a bit unwieldy. This program isn't for everyone but if you'd find it useful, please try it. It's a free download from these links -







Dennis Lefebvre

unread,
Aug 26, 2019, 12:53:21 PM8/26/19
to Brennan Forum


On Wednesday, April 17, 2019 at 4:30:33 PM UTC-4, AndyC wrote:
.... Every time you rip a CD, b2 adds the album and tracks to the end of b2db - and the HDD does the same to the FAT. 

Do we know how often b2db is fully rewritten? At the very beginning is a line stating the total number of albums or tracks (I forget which). This suggests that when an album is ripped the names cannot simply be appended to the end of the file., the first line must also be updated. Likewise, if an album or track is edited or deleted, changes would need to be written to the middle of the file. I am wondering if the "read only" errors are actually some problem with the SD card keeping up with frequent rewrites of b2db and associated temporary files?

Chris A

unread,
Aug 27, 2019, 4:01:14 AM8/27/19
to Brennan Forum
My observation is probably not relevant, but I note that when I look at my B2 in Windows File Explorer via NAS, it shows up as NTFS rather than FAT32.

PMB

unread,
Aug 27, 2019, 5:10:35 AM8/27/19
to Brennan Forum
Hi Dennis,

My understanding is the B2 runs Scan Disk at every power up, so effectively b2db is rebuilt during the boot up routine.

Paul
Brennan Support.

PMB

unread,
Aug 27, 2019, 5:15:29 AM8/27/19
to Brennan Forum
Hi Dennis,

Also meant to say - those who leave the B2 constantly powered should maybe force a Scan Disk periodically to update the b2db and keep things in sync.

Paul
Brennan Support.

AndyC

unread,
Aug 27, 2019, 3:16:10 PM8/27/19
to Brennan Forum
Sorry to disagree with you, Paul, but b2 does not rebuild the b2db file at every boot up. There isn't time - Scan Disk takes 30 seconds or more and the file counter is displayed to show progress. This doesn't happen on boot up.

Assuming you have an HDD, all the music files are stored in its (twin) File Allocation Table(s) in an Artist>Album>Track folder structure. The HDD is after all just a laptop HDD & laptops can't work without the HDD telling them what's stored on them via the FAT. Scan Disc causes b2 to delete the b2db file, read the FAT and build a new b2db file. (The main reason for this no doubt is that it's a lot quicker to access the b2db file in dynamic memory to find music than to read the FAT on the HDD.) 

When you add music by ripping a CD or via a USB stick, the FAT updates automatically (this is an internal HDD operation) and b2 also UPDATES its b2db file. It doesn't completely rebuild it, it just adds the new info on the end and updates the album count in the header. This is why you can always easily find the most recently ripped CD by selecting Browse Albums and rotating the knob one click anticlockwise to play the last album in b2db, which is the one you just ripped.

b2 manipulates the b2db file during normal usage by, for example, changing file types when compression is running, but it doesn't rebuild the whole file. Only Scan Disk does this, I believe. 

(Before running Scan Disk, it's also worth running Settings>Maintenance>Cleanup first to tidy up the FAT and remove any debris such as Empty albums etc.)

I actually use the b2's commands to download and upload the b2db file onto a USB stick to manipulate the order the music naturally plays in to suit my preferences. (For example, by reordering any given artist's albums chronologically.) This requires great care as if the contents of b2db don't match the contents (but not the order) of the FAT than b2 may well crash and Scan Disk will be needed. Once I have my new b2db file loaded, it is used by b2db aqt every boot up until the next Scan Disk and any newly ripped CDs are just added on the end.

Hope this helps..Andy

Dennis Lefebvre

unread,
Aug 27, 2019, 3:35:21 PM8/27/19
to Brennan Forum


On Tuesday, August 27, 2019 at 3:16:10 PM UTC-4, AndyC wrote:
... Scan Disk takes 30 seconds or more and the file counter is displayed to show progress

I suppose this depends on the number of tracks. We only have about 7,500 tracks and Scan Disk takes about 3 seconds to complete (480 GB SSD model). 

Daniel Taylor

unread,
Aug 27, 2019, 4:00:28 PM8/27/19
to Brennan Forum
Andy,
Good info.  Thanks.  I believe you are right.

I've thought a little about getting the B2 to list albums by an artist in chronological order.  If you prepend [1], [2], etc to each album folder's name, the B2 will put it in chrono order for you, and you won't have to mess around with the b2db file.

PMB

unread,
Aug 28, 2019, 4:35:12 AM8/28/19
to Brennan Forum
Hi Andy C,

Thank you for the info.

Paul
Brennan Support.

AndyC

unread,
Sep 1, 2019, 6:28:00 AM9/1/19
to Brennan Forum
Thanks for the replies, guys.

Dennis, my b2 takes exactly 60 seconds for Scan Disk to log 20,000 tracks. Yours is much quicker (about 6 times faster) because it has an SSD not a slower 2TB HDD like mine and maybe your b2 is newer than mine - Brennan are continually using the latest (& faster) Raspberry Pis in their production so maybe my 3+ year old machine is a bit long in the tooth now!!

Reference alphabetical sorting of tracks, Daniel, yes you can turn this on easily by clicking the A-Z button on the UI. There is however a big downside to this - it just sorts all the albums alphabetically irrespective of the Artist. Therefore, whilst each artist's listing shows his/her albums in the correct order, it doesn't play that way. If you play the 1st album right through, b2 does not then play the 2nd album by that artist, it plays the 1st Album by the next artist in the list!

Some users are happy with this and that's fine. However I prefer my b2 to actually play the albums by the same artist in the correct order. To do this, I know of no other way than to play around with b2db. That's why the b2 is so great, you can use it straight out the box or you can extensively customize it if you wish. A brilliant product, sometimes challenging but just great at what it does.

Andy
Reply all
Reply to author
Forward
0 new messages