Author Topic: Subsong names in plugins  (Read 1991 times)

saga

  • Posts: 2642
Subsong names in plugins
« on: 14 Oct '20 - 18:07 »
Some module formats allow subsongs to have their own names. If I take e.g. a Cue sheet for a FLAC file and split it into individual playlist entries, they all have the correct subsong names. But how can this be achieved with plugins? The GetTag function appears to be agnostic for which subsong the tags should be retrieved, and furthermore it seems to be called before the correct subsong is selected. Does the plugin API support this at all at the moment?

Ian @ un4seen

  • Administrator
  • Posts: 24940
Re: Subsong names in plugins
« Reply #1 on: 15 Oct '20 - 16:13 »
The plugin's GetTags function should return the current subsong's tags, but the GetFileInfo function can return tags for each subsong if it doesn't include the XMPIN_INFO_NOSUBTAGS flag in the return value. Each subsong's tag block should end with a double-null. For example, "filetype\0IT\0title\0song1\0\0filetype\0IT\0title\0song2\0\0" for 2 IT file subsongs with title "song1" and "song2".

saga

  • Posts: 2642
Re: Subsong names in plugins
« Reply #2 on: 15 Oct '20 - 20:27 »
I have now removed XMPIN_INFO_NOSUBTAGS from my GetFileInfo implementation and when I split a file into its subsongs, they are displayed fine in the playlist. However, I think there is an issue when switching between different subsongs:
If I play the first subsong, SetPosition is called with the correct subsong number, followed by GetTags, so its name is retrieved and displayed correctly.
If I now select the second subsong from the playlist and play it, SetPosition is called with the correct subsong index but GetTags isn't. If I double-click the playlist entry again, however, GetTags is called again.
If I play a completely unrelated file inbetween, GetTags is always called and the subsongs are displayed correctly. Could there be an issue when playing two subsongs from the same file one after another?

Also, if the subsongs are not separated, GetTags appears to be only called when playback is started, but not when playback advanced to the next subsong, so the first subsong's name remains to be displayed in the title bar.

Ian @ un4seen

  • Administrator
  • Posts: 24940
Re: Subsong names in plugins
« Reply #3 on: 16 Oct '20 - 14:33 »
When a new subsong starts with different tags (or any other time the tags change), the plugin can request a refresh of the tags by calling the XMPFUNC_IN:UpdateTitle function with track=NULL. XMPlay should then call the plugin's GetTags function to get the tags and update the title display. Let me know if you see it still not getting updated.

saga

  • Posts: 2642
Re: Subsong names in plugins
« Reply #4 on: 16 Oct '20 - 19:07 »
It seems like GetTags won't be called in this case for formats supported by XMPlay internally; e.g if I try to switch subsongs of an IT file played by xmp-openmpt, GetTags won't be called after calling UpdateTitle, but for some other module format not supported by XMPlay it is called as you describe. Apart from this, I think I got everything working.

EDIT: There is one more thing... If GetTags is called as a response to UpdateTitle, this will also update the song name in the playlist. Is there a way to have a song title for the entire file that is independent of the sub song display? And if GetFileInfo returns tags for all subsongs, is there also a way to include such a "file title" in addition to the individual subsong titles? Some module formats allow to have subsong names in addition to a file title, just like the TITLE tag of Cue sheets.
I tried calling UpdateTitle with a specific subsong name, but this seems to apply the title without any title formatting chosen by the user, so e.g. the artist information is lost.
« Last Edit: 16 Oct '20 - 19:30 by saga »

Ian @ un4seen

  • Administrator
  • Posts: 24940
Re: Subsong names in plugins
« Reply #5 on: 19 Oct '20 - 17:31 »
It seems like GetTags won't be called in this case for formats supported by XMPlay internally; e.g if I try to switch subsongs of an IT file played by xmp-openmpt, GetTags won't be called after calling UpdateTitle, but for some other module format not supported by XMPlay it is called as you describe. Apart from this, I think I got everything working.

Do you happen to have overridden tags on the file ("Override" enabled in Track Info)? XMPlay won't update the tags in that case.

EDIT: There is one more thing... If GetTags is called as a response to UpdateTitle, this will also update the song name in the playlist. Is there a way to have a song title for the entire file that is independent of the sub song display? And if GetFileInfo returns tags for all subsongs, is there also a way to include such a "file title" in addition to the individual subsong titles? Some module formats allow to have subsong names in addition to a file title, just like the TITLE tag of Cue sheets.
I tried calling UpdateTitle with a specific subsong name, but this seems to apply the title without any title formatting chosen by the user, so e.g. the artist information is lost.

Yes, XMPlay will update the playlist entry with the refreshed tags. And a title that doesn't affect the playlist entry can be set via UpdateTitle but it won't use XMPlay's title formatting. I think the only way to currently have a separate file and subsong titles is to use a cue sheet. It is possible for a plugin to provide a cue sheet in a "cuesheet" tag in its GetTags reply, but GetSubSongs will need to return 0/1 for that to be used, ie. subsong seeking/separating would be based on the cue positions rather than using XMPIN_POS_SUBSONG. I'm not sure that would be precise enough in your case?

Perhaps another option is to put the file's title in the "album" tag?

saga

  • Posts: 2642
Re: Subsong names in plugins
« Reply #6 on: 21 Oct '20 - 21:26 »
Quote
Do you happen to have overridden tags on the file ("Override" enabled in Track Info)? XMPlay won't update the tags in that case.
Ah, the tags for that file were indeed overriden. Do you think it would be possible to have a working subsong display even for files with overridden tags? From my understanding of the XMPlay library format, subsong names cannot be stored in the library anyway, so it seems like it doesn't make much sense to not accept any subsong updates even when tags are overridden. I think (at least with modules) a common case for overriding tags would be to add add missing song artist information, but this shouldn't prevent the subsong display from working.

And indeed, using cue sheets probably won't work due to all the quirks with module song length calculation.
Maybe UpdateTitle("songname") could be modeified so that it only replaces the current song title in the title display and keep using the regular formatting string? Or would that break any existing plugins? If that would be a problem, maybe the plugin could indicate through a flag that it would like to use this alternative mode for UpdateTitle.

Or yet another alternative - can the playlist entry not simply always just show the name of the first subsong (unless the subsongs were split into separate entries, of course)? It seems a bit strange and confusing that the playlist display gets updated based on which subsong I play.

Ian @ un4seen

  • Administrator
  • Posts: 24940
Re: Subsong names in plugins
« Reply #7 on: 23 Oct '20 - 14:42 »
I don't think the UpdateTitle behaviour can be changed too much for compatibility reasons, but I will look into having a tag refresh (UpdateTitle with NULL) update the playlist entry (and stored tags) only when the first subsong is playing (only the title display is updated if another subsong is playing). Would that let you achieve what you want?

A tag refresh can be useful if tags become available after the file is opened (eg. at the end of a download), so don't want to totally remove the ability to update the playlist entry.

saga

  • Posts: 2642
Re: Subsong names in plugins
« Reply #8 on: 23 Oct '20 - 16:42 »
With the current concept of no separate subsong titles and main title, I think that update should do the trick. In the long run, it would be great if plugins could provide those two separately though, like with cue sheets.

Ian @ un4seen

  • Administrator
  • Posts: 24940
Re: Subsong names in plugins
« Reply #9 on: 27 Oct '20 - 16:36 »
Here's an update for you to try:

   www.un4seen.com/stuff/xmplay.exe

When refreshing tags (UpdateTitle with NULL) in a file with subsongs, it will only update the playlist entry's tags if the first subsong is playing. For other subsongs, only the title display should be updated. Let me know if you see any problems with it.

Regarding having separate main and subsong titles, would that be so that you can combine them in the title display? If so, the way it works with cue sheets is that the main "TITLE" value is used as the album tag for title formatting purposes. Perhaps you could do the same in your case with GetTags?

saga

  • Posts: 2642
Re: Subsong names in plugins
« Reply #10 on: 8 Nov '20 - 12:18 »
Sorry for the late reply, I finally found some time to test the changes. I think the new UpdateTitle behaviour is useful as it is.

Quote
Regarding having separate main and subsong titles, would that be so that you can combine them in the title display?
The main idea of what I want to achieve is that you have e.g. a game soundtrack, and the main title as displayed in the playlist would be something like "Author - Game Title", but of course the first  subsong's name in that file is probably not going to be "Game Title" but rather "Menu Music" or something like that. Right now the only way to achieve that is by overriding the library information in XMPlay. Since some module formats (and other VGM formats) do support both a file title and subsong titles at the same time, it would be great if XMPlay could somehow display both of them without the user having to edit the information manually.

Maybe there could be an additional XMPIN_FLAG_* value that indicates that the plugin will return an additional subsong which is not actually playable, and this additional subsong will contain the metadata for playlist / library display. For backwards compatibility, this additional subsong should probably be the last one in the subsong array and report a length of 0 seconds.