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

saga

  • Posts: 2430
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: 23037
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: 2430
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: 23037
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: 2430
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: 23037
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?