Is ‘complicatedly’ even a word? No matter, it is now.
Anyway, I’m going along writing Towel’s new playlist code, and I realise some of the loops I’m going to have to jump through to keep the data within the playlist structure (which is like a tree kind of thing) synchronised suitably. I’m storing some information at each node rather than recalculating it each time it needs to be accessed, because it will work out alot more efficient that way. I don’t like to think of what kind of mess it would make if I had to recalculate some of this stuff every time the song changed. This data is needed to make random track selection reasonably fair, because the nested-group concept means I need to weight the random algorithm at each level so it would be more likely to go down a branch with 16 tracks in it than stop at the current level which contains only 3 tracks. Of course, it might do that anyway, but that’s what a fair random picker is all about.
I’m a little worried that the random algorithm might work out being a bit slow, actually, but short of implementing my own TreeModel, which I’m not about to do, I can’t really do much about it and keep the playlist working the way I want to.
Anyway, for now it’s moving along. Need to add some more data items for things like the current track, so it can keep tabs on it, and the code for next-track selection of course. Then we can finally plug it into Towel’s main code and make it play music. Jonathan’s nice GStreamer backend will be doing that of course, it already works with the old playlist. In fact, the playlist code doesn’t touch it at all, save for a little bit of use of his Towel::File and Towel::Loader classes to do filetype detection when a track is added to the playlist.
Also need to work out an efficient way of loading the playlist. Ideally I need to build the tree then calculate the metadata just once, rather than with each add, so loading from playlist files will need a special code pathway… thankfully a generalisation of the current one should accomplish that.
All fun though