python-tidal icon indicating copy to clipboard operation
python-tidal copied to clipboard

Understanding formats

Open GioF71 opened this issue 1 year ago • 5 comments

Hello @tamland, I am trying to put quality "badges" to album lists in my tidal plugin for upmpdcli. Mostly, what I have done works, but there are some cases that puzzle me. For example when trying to play the latest album by Mark Knopfler, which come (unsurprisingly) in three versions:

https://listen.tidal.com/album/355472560 (no particular tags as far as I understand) https://listen.tidal.com/album/355473696 (tagged as "max") https://listen.tidal.com/album/355473675 (tagged as "max")

I have added the following code to pkce_example.py:

# 355472560 <- atmos in media_metadata_tags <- but it plays @192kHz
# 355473696 <- max<- but it plays 16bit/48kHz, I expected 24bit/192kHz or 16bit/44.1kHz
# 355473675 <- max <- plays 24bit/192kHz as expected

def print3(name: str, f, arr):
    print(f"{name}: [{f(arr[0])}] [{f(arr[1])}] [{f(arr[2])}]")


one_deep_river: list[Album] = list()

odr_1 = session.album("355472560")
odr_2 = session.album("355473696")
odr_3 = session.album("355473675")

one_deep_river.extend([odr_1, odr_2, odr_3])

print3("Type", lambda x: x.type, one_deep_river)
print3("Explicit", lambda x: x.explicit, one_deep_river)
print3("AvRelDt", lambda x: x.available_release_date, one_deep_river)
print3("Copyright", lambda x: x.copyright, one_deep_river)
print3("PrNum", lambda x: x.universal_product_number, one_deep_river)
print3("RelDate", lambda x: x.release_date, one_deep_river)
print3("TRelDate", lambda x: x.tidal_release_date, one_deep_river)
print3("Cover", lambda x: x.cover, one_deep_river)
print3("AudioQuality", lambda x: x.audio_quality, one_deep_river)
print3("AudioModes", lambda x: x.audio_modes, one_deep_river)
print3("MMTags", lambda x: x.media_metadata_tags, one_deep_river)

And the output (select parts) puzzles me a lot, in particular the array with both LOSSLESS and HIRES_LOSSLESS

AudioQuality: [LOW] [LOSSLESS] [LOSSLESS]
AudioModes: [['DOLBY_ATMOS']] [['STEREO']] [['STEREO']]
MMTags: [['DOLBY_ATMOS']] [['LOSSLESS', 'HIRES_LOSSLESS']] [['LOSSLESS', 'HIRES_LOSSLESS']]

Can you help interpret the results?

Thanks a lot

GioF71 avatar Apr 12 '24 18:04 GioF71

Hello @GioF71.

Each album is available in multiple formats, as you have pointed out.

355472560 is atmos, as stated in the fields you've listed (I. E. low quality, atmos audio mode)

The two remaining albums, I believe are either MQA (355473696 ) or FLAC lossless (355473675) . Each album has either a lossless or a hires_lossless (max) quality available. You should be able to confirm this by selecting between the two albums, eg. If you have a dac that reports MQA playback.

tehkillerbee avatar Apr 12 '24 20:04 tehkillerbee

Unfortunately I don't have a MQA-enabled dac. In fact that would have made things easier to understand. So, only looking at the metadata, there is no way to know which one is really hi_res_lossless and which one is mqa, am I right? Well I suppose that mqa is on its way out so it's probably an issue that is going to disappear in some time.

Does this sound correct to you?

GioF71 avatar Apr 12 '24 20:04 GioF71

So, only looking at the metadata, there is no way to know which one is really hi_res_lossless and which one is mqa, am I right?

Not directly but I believe >24 bit will never be MQA.

I just tested this, and 355473696 isn't MQA (Just 16bit/48kHz FLAC) while 355473675 is "actual" HI_RES, as you pointed out. Perhaps the real reason this track is classed as Hi res is since the sample rate is > 44.1kHz, as it is technically higher than CD quality?

tehkillerbee avatar Apr 12 '24 20:04 tehkillerbee

yes the problem is only that I cannot in every situation use the 24bit information (from stream info) because I would get paywall errors (429). Yes true 24bit I believe it's superior to mqa! :-)

GioF71 avatar Apr 12 '24 20:04 GioF71

Actually after I implemented an algorithm that uses those media_metatada_tags, I see there are lots of "MQA" albums, even if they play as normal hires and they are always 24bit. This one from Mark Knopfler looks quite an exception being only 16bit/48kHz... Thank you for your help!

GioF71 avatar Apr 13 '24 09:04 GioF71