Help - Search - Members - Calendar
Full Version: foo_diskwriter with cuesheet generation
Hydrogenaudio Forums > Hosted Forums > foobar2000 > 3rd Party Plugins - (fb2k)
Synthetic Soul
Following this, this and this, I give you this.

Diskwriter with cuesheet generation for single file output.

I have added a new checkbox to the "Output directory" group: "Create cuesheet for single file". If selected an accompanying cuesheet will be created when you choose "Convert" > "Run conversion, single file output".

If your image has the path "C:\My Music\myfile.flac" the cuesheet will have the path ""C:\My Music\myfile.flac.cue".

At the moment only TITLE and PERFORMER values are populated. I would like to eventually extract other global meta data, like DATE and GENRE.

If all files have the same "album artist" that will be used as the global PEFORMER. If not, and they all have the same "Artist", that will be used. If they all have differing artist values "Various Artists" will be used.

If all files have the same "album" that will be used as the global TITLE. If not, the command will not be used. I'd like to revert to the playlist name but I need to work out how (anyone want to give me a neat little function for returning the current playlist name as a string8?).

The cuesheet is in ANSII format, but the code can easily be updated to allow for UTF-8. I have ripped some rather nice looking io routines from musicmusic's Text Writer plugin, and this allows for easily switching the encoding type. I have added a credit to musicmusic in the files ripped from him - I hope that is adequate. NB: I haven't used any code from foo_cuesheetcreator - working on that component just gave me the knowledge to feel brave enough to attempt this update.

Unless the foobar development team take my request on board for Converter in 0.9 I will obviously attempt to make the same updates to Converter when the 0.9 SDK is available.

Edit: 2005-07-08 : Updated link to 2.1.2 (see post #6 *)

Edit: 2005-12-06 : Updated link to 2.1.4 - previous versions were using LF, not CRLF
Peter
This may not be simple to port to 0.9 because large parts of the diskwriter were simply rewritten. Thanks for your initiative anyway.
I'll look into re-implementing this myself at some point.
Synthetic Soul
That would be absolutely superb.

Thank you for both your interest and support. I was so worried that you may rip into me for screwing with diskwriter. blush.gif I have made every effort to ensure that I haven't compromised its core, but I'm very aware of the potential to cause you trouble with some incompetent work.

I seem to have obsessed about this topic for a while now, but it just makes so much sense to me. If you are merging tracks into one file an accompanying cuesheet can be just so useful.

The additional features I have in mind are:
  • Possible ability to select UTF-8 as encoding. I was hoping I could do this by analysing whether UTF-8 was required or not, depending on the contents of the cuesheet (i.e.: ANSII would always be used where possible, with UTF-8 only being used where required)
  • Setting the album as the playlist name if not all track's album tags match. I don't really have an alternative to this (apart from leaving the TITLE command out completely, as current)
  • Any additional meta data shared by all tracks to be output as global REM statements, e.g.: REM DATE 2005 or REM GENRE "Progressive Rock". I can't see a reason to output any track-level REM commands, but I may be wrong
Synthetic Soul
QUOTE(Synthetic Soul @ Jul 3 2005, 01:00 PM)
anyone want to give me a neat little function for returning the current playlist name as a string8?

This seems to be the only way I can see:

CODE
string8 get_current_playlist_name() {
   string8 tmp;

   playlist_switcher * g_switcher = playlist_switcher::get();
   if (g_switcher)
       g_switcher->get_playlist_name(g_switcher->get_active_playlist(), tmp);

   return tmp;
}


Does that cause a shiver down anyone's spine, or does that look OK?
Peter
Nothing wrong with that code. There are more complicated reasons why API itself doesn't do this (cross-DLL-safety with different compilers/runtimes).
Synthetic Soul
OK, I don't seem to be getting much free time at the moment so I've uploaded 2.1.2.

I've managed to tick off two items from my list above.
  1. The cuesheet will be encoded as ANSII by default. However, if the tags require it (i.e.: they have characters that are not available in the ANSII character set) the cuesheet will be saved in UTF-8 format. This seems the neatest solution to me - best compatibility where possible, but no data lost.
  2. If all tracks do not have the same album name the playlist name will be used as the top level TITLE value (cuesheet album).
I still want to be able to get it to write GENRE and DATE (etc.) tags as well, but I just don't know when I can do it yet, so here's 2.1.2 in case I never do.

I think one of the best things to come out of this is that 0.9 (or 1.0) may have this feature built-in.

Thanks once again to zZzZzZz (and musicmusic for a really nice io class).

Edit: 2005-12-06 : Updated link to 2.1.4 - previous versions were using LF, not CRLF
jaybeee
Many thanks for this Synthetic Soul.
Synthetic Soul
I've only just noticed that 0.9 beta 6 has the Convert option "Convert to single file with cuesheet or chapters".

Hoorah!

Thanks once again to zZzZzZz and the rest of the foobar team. I'm chuffed to have a suggestion taken onboard.

I need to test it a little more to see how the meta data works. I have noted so far that if all tracks are from the same album the album name and album artist name are recorded, with no track artist value recorded. If tracks are from separate albums (with separate performers) album and album artist are missing, but track artist is recorded. This all seems to make sense. My limited testing has however highlighted a minor bug in both 0.8.3 and 0.9 when loading cuesheets with "incomplete" meta data.
Peter
As you've noticed correctly, current 0.9 cuesheet parser is very old. It will be rewritten before final release, it's complete pain to fix or add new features as it is now.

You might also want to see what happens when encoding singlefile+chapters MP4, though per-chapter tagging is currently non-functional (limitation of old MP4 tagging spec, hopefully soon to change).
Synthetic Soul
QUOTE(zZzZzZz @ Jul 22 2005, 01:21 PM)
As you've noticed correctly, current 0.9 cuesheet parser is very old. It will be rewritten before final release, it's complete pain to fix or add new features as it is now.

Excellent. Thanks for the response.

QUOTE(zZzZzZz @ Jul 22 2005, 01:21 PM)
You might also want to see what happens when encoding singlefile+chapters MP4, though per-chapter tagging is currently non-functional (limitation of old MP4 tagging spec, hopefully soon to change).

I'm intrigued. I'm not familiar with MP4 chapters, but I feel I will be soon. smile.gif


NB: To all: I see GENRE, DATE and COMMENT values will be added as top level REM statements if all tracks have the same value. smile.gif I never did get around to that...
Synthetic Soul
QUOTE(zZzZzZz @ Jul 22 2005, 01:21 PM)
You might also want to see what happens when encoding singlefile+chapters MP4, though per-chapter tagging is currently non-functional (limitation of old MP4 tagging spec, hopefully soon to change).

Ha ha - it took me a while to work out why I was only getting one file. I guess I forgot what I was supposed to be testing.

I see from testing with 0.8.3 also that the ALBUM and ARTIST meta data are stored as tags, while the TITLE and TRACKNUMBER info must obviously be stored in the chapter (stored in the MP4's udta atom... whatever that is).

Before I could test I had to find out what chapters were, which lead me to MP4BOX. I see from my tests with MP4Box's -chap switch that you specify a chapter number (tracknumber) and name (title) for each chapter.

That's cool.

So, as things stand, you are currently limited to TITLE and TRACKNUMBER at track level, but any tag at album/file level. So no good for VA albums, but fine for most things.

Thanks for the education. smile.gif

This kinda begs the question though - if chapters for MP4, maybe a CUESHEET tag for lossless files? I guess I'd rather the external CUE and the option to embed though...
Peter
It already writes embedded cuesheets where supported (APE, FLAC, WavPack).

Tracknumbers for MP4 chapters aren't stored at all (assumed identical to chapter index).

There is a new MP4 tagging standard being worked on, with full support for per-chapter tags, and will be most likely supported by final 0.9 release if not earlier.
Synthetic Soul
QUOTE(zZzZzZz @ Jul 22 2005, 04:46 PM)
It already writes embedded cuesheets where supported (APE, FLAC, WavPack).

biggrin.gif Thought of everything didn't you?

NB: I've just noticed "Utils" > "Edit cuesheet" and the cue_embedded info item. Looks like I need to play around a bit more. I guess I've been testing the betas with MPC and MP3 mainly.

QUOTE(zZzZzZz @ Jul 22 2005, 04:46 PM)
There is a new MP4 tagging standard being worked on, with full support for per-chapter tags, and will be most likely supported by final 0.9 release if not earlier.

Definately seems like I need to get up to speed with MP4.

Edit: And now I've just noticed "Utils" > "MP4 chapters" with cuesheet import. happy.gif
Synthetic Soul
OK, I have made what I hope to be my final changes to Diskwriter. Version 2.1.3.

I thought I may as well, as (a) I don't like to leave things unfinished, and (b) If 0.9 stays as 2000-/XP-only there may be a user base that stay with 0.8.3. The source is included, as it always has been, so that anyone can continue developing it.

Following 0.9's lead, I have implement the facility to store global GENRE, DATE and COMMENT values as REM statements. So, if all tracks have the same GENRE (etc.) that will be recorded for the cuesheet. No track level values are recorded.

My original intention was to loop through all meta data for each track and record any meta tag that matched for every track. Also, to possibly store any unmatching tags at track level. However, I haven't had time to do that and implementing it for just GENRE, DATE and COMMENT at top/album level was nice and easy.

I have also rejigged the preferences dialogue, to provide more options, as I know how frustrating it is if things don't work quite how you'd like.

Here's a screen grab (showing default values):

user posted image

Explanation for each checkbox:

Create cuesheet
Check this to create an accompanying cuesheet when converting using "Run conversion, single file output". If unchecked, a cuesheet will not be created, and the other checkboxes will be disabled.

ASCII output only
Check this and the cuesheet will always be output in ASCII format, irrespective of the content. If unchecked, as per 2.1.2, cuesheets will generally be saved in ASCII format - but if the meta data contains characters that are unavailable in the ASCII character set the cuesheet will be saved in UTF-8 format instead.

Revert to playlist name
Check this and the playlist name will be used as the album name if not all tracks have the same ALBUM meta tag (as per 2.1.2). If unchecked, no album name will be recorded if not all tracks have the same ALBUM meta tag. Obviously, if all tracks do have the same ALBUM meta tag, that album name will always be used as first choice.

Use quotes
Check this and REM values will be quoted, e.g.: REM GENRE "Progressive Rock". If unchecked, REM values will not be quoted, e.g.: REM GENRE Progressive Rock.

Edit: 2005-12-06 : Updated link to 2.1.4 - previous versions were using LF, not CRLF
Jun-Dai
Thank you, Zhang Ziyi, I mean Synthetic Soul. Your component is as useful to me as foobar2000 itself.
Synthetic Soul
QUOTE(Jun-Dai @ Mar 13 2006, 09:27 AM)
Thank you, Zhang Ziyi, I mean Synthetic Soul.
biggrin.gif

Thank you for your interest. Bear in mind that this functionality is inbuilt in foobar 0.9 now, with the added benefit of embedding cuesheets for lossless files and additional meta data support (my component will only add GENRE, DATE and COMMENT but, contrary to my post above, I believe that foobar 0.9 will transfer other tags also).
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.