Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Title formatting/syntax for proper bitdepth (Read 76966 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Title formatting/syntax for proper bitdepth

Hi,

I use $info(__bitspersample) or %bitspersample% to display bitdepth.
For normal 16 (or 24) files it shows 16 (or 24) in "columns" and "bottom bar" and "Text Display from JS3".
I also use @Case Output Info v1.2.1 plugin to show %output_bitdepth% which shows 32 (because my DAC is 32).
So all seems OK.
But there is one exeption - HDCD. When I play 16 bit HDCD files it shows 16 bit in Columns (before HDCD decoding), 24 bit in bottom bar (after HDCD decoding) and 24 bit in JS3 Text Display. Is there a way to display 16 bit in JS3 Text Display (before the file has been decoded by HDCD plugin)? What I want to achieve is to be able to see the real bitdepth of the file (on the Input).

Re: Title formatting/syntax for proper bitdepth

Reply #1
Try this. I don't know if it works in JS panel, but it's the right script for other places using titleformat script.
Code: [Select]
$if($strcmp(%__hdcd%,yes),16-bit,[$info(bitspersample)-bit])
Think millionaire, but with cannons.

Re: Title formatting/syntax for proper bitdepth

Reply #2
Try this. I don't know if it works in JS panel, but it's the right script for other places using titleformat script.
Code: [Select]
$if($strcmp(%__hdcd%,yes),16-bit,[$info(bitspersample)-bit])

Thank you, but this one seems not to check or measure the real bitdepth of the file but manually put a value of 16 if hdcd is present. I would like to get the real value from the file before the hdcd plugin decodes it.

Re: Title formatting/syntax for proper bitdepth

Reply #3
Ah, I misunderstood. I don't know how you'd do that. However, I'm pretty sure every HDCD-encoded track in existence is 16-bit before being decoded because it was a format based on Redbook CD Audio. Someone please correct me if I'm mistaken.

I understand wanting the value to be pulled from the file regardless of whether it will always be 16-bit for HDCD, but I don't know if it is possible with the current implementation of the decoder.
Think millionaire, but with cannons.

Re: Title formatting/syntax for proper bitdepth

Reply #4
every HDCD-encoded track in existence is 16-bit before being decoded because it was a format based on Redbook CD Audio.
That's the situation. Or at least: if you find HDCD packets in "something else", then something has happened afterwards, that likely requires "manual" review - like, it has been through a partial HDCD decoding.

(HDCD is "nonlinear PCM stored as linear PCM", but the nonlinearities happen only every now and then.)

Re: Title formatting/syntax for proper bitdepth

Reply #5
In my opinion the HDCD decoder isn't being nice because the SDK suggests using decoded_bitspersample when decoded bitdepth differs from actual bitdepth. See definition and titleformat field.
If there is interest I could modify the HDCD decoder to not mess with bitspersample and instead return data in decoded_bitspersample. But I recall @Porcus has been complaining about HDCD decoder acting stupid with actual files. If I'm going to touch this mess I want to fix nonsensical behavior too, so I'd need a sample that misbehaves.

Re: Title formatting/syntax for proper bitdepth

Reply #6
Hi,

I use $info(__bitspersample) or %bitspersample% to display bitdepth.
For normal 16 (or 24) files it shows 16 (or 24) in "columns" and "bottom bar" and "Text Display from JS3".
I also use @Case Output Info v1.2.1 plugin to show %output_bitdepth% which shows 32 (because my DAC is 32).
So all seems OK.
But there is one exeption - HDCD. When I play 16 bit HDCD files it shows 16 bit in Columns (before HDCD decoding), 24 bit in bottom bar (after HDCD decoding) and 24 bit in JS3 Text Display. Is there a way to display 16 bit in JS3 Text Display (before the file has been decoded by HDCD plugin)? What I want to achieve is to be able to see the real bitdepth of the file (on the Input).
Yes, you can alter the text of Text Display.
Rightclick on the Text Display panel, Custom text. Add a line like:

[$crlf()$if($info(hdcd),HDCD original bitdepth 16. Now playing )bitdepth $info(bitspersample)]

If you set selection mode to Follow selecxted track (playlist) you can easily follow what's happening

Re: Title formatting/syntax for proper bitdepth

Reply #7
Hi,

I use $info(__bitspersample) or %bitspersample% to display bitdepth.
For normal 16 (or 24) files it shows 16 (or 24) in "columns" and "bottom bar" and "Text Display from JS3".
I also use @Case Output Info v1.2.1 plugin to show %output_bitdepth% which shows 32 (because my DAC is 32).
So all seems OK.
But there is one exeption - HDCD. When I play 16 bit HDCD files it shows 16 bit in Columns (before HDCD decoding), 24 bit in bottom bar (after HDCD decoding) and 24 bit in JS3 Text Display. Is there a way to display 16 bit in JS3 Text Display (before the file has been decoded by HDCD plugin)? What I want to achieve is to be able to see the real bitdepth of the file (on the Input).
Yes, you can alter the text of Text Display.
Rightclick on the Text Display panel, Custom text. Add a line like:

[$crlf()$if($info(hdcd),HDCD original bitdepth 16. Now playing )bitdepth $info(bitspersample)]

If you set selection mode to Follow selecxted track (playlist) you can easily follow what's happening
I would actually add a line like this without the [ and ] brackets:
$crlf()$if($info(hdcd),HDCD original bitdepth 16. Now playing actual bitdepth 20,bitdepth $info(bitspersample))

Playing HDCD content reports 24 bits, but the first four bits are always 0 so the actual resolution is 20 bit.

Re: Title formatting/syntax for proper bitdepth

Reply #8
In my opinion the HDCD decoder isn't being nice because the SDK suggests using decoded_bitspersample when decoded bitdepth differs from actual bitdepth. See definition and titleformat field.
If there is interest I could modify the HDCD decoder to not mess with bitspersample and instead return data in decoded_bitspersample. But I recall @Porcus has been complaining about HDCD decoder acting stupid with actual files. If I'm going to touch this mess I want to fix nonsensical behavior too, so I'd need a sample that misbehaves.
@Case

I painstakingly scanned my full library with the HDCD Decoder utilities "Scan for HDCD tracks" to find all (hidden) HDCD content. After finding those files I added a tag MEDIA containing a value of HDCD to be able to identify HDCD content even when not playing.

If you decide to do some work on the HDCD decoder, may I suggest the following:

Since I already scan all files with your Truepeakscanner utility (all options enabled), it would be nice if TPS would also identify HDCD content with an added bonus of detecting %__hdcd_peak_extend%, %__hdcd_gain% and %__hdcd_transient_filter% and write four extra tags for found HDCD content?

Re: Title formatting/syntax for proper bitdepth

Reply #9
I painstakingly scanned my full library with the HDCD Decoder utilities "Scan for HDCD tracks" to find all (hidden) HDCD content.
Beware of false positives.

Re: Title formatting/syntax for proper bitdepth

Reply #10
I painstakingly scanned my full library with the HDCD Decoder utilities "Scan for HDCD tracks" to find all (hidden) HDCD content.
Beware of false positives.
Thx for the tip.

I actually only have 14 HDCD's besides Madonna stuff. All full HDCD's have been verified by checking Discogs/Musicmatch and all are valid.

The Madonna stuff (Compilations, Bootleg-Compilations and EP's) I have is kind of interesting.
Some of the EP's are fully HDCD, some mix normal CD tracks with HDCD tracks.
Discogs sometimes marks the whole EP as HDCD, which in fact also contains standard CD tracks next to HDCD tracks.
Discogs sometimes marks an EP or compilation as a standard CD, but in fact those also contains some HDCD tracks.

This EP stuff also found it's way to Compilation and Bootleg-Compilations,  so these albums also contain normal CD tracks mixed with HDCD.

Re: Title formatting/syntax for proper bitdepth

Reply #11
If there is interest I could modify the HDCD decoder to not mess with bitspersample and instead return data in decoded_bitspersample. But I recall @Porcus has been complaining about HDCD decoder acting stupid with actual files. If I'm going to touch this mess I want to fix nonsensical behavior too, so I'd need a sample that misbehaves.
An upload at https://hydrogenaud.io/index.php/topic,79427.msg957780.html#msg957780 , but you should read further in the thread.
Then I reported an issue at https://hydrogenaud.io/index.php/topic,79427.msg934501.html#msg934501 where in image+cue it would behave different depending on codec - the only way I could imagine that happen, is that it decodes a full encoded frame that crosses track boundary?

Re: Title formatting/syntax for proper bitdepth

Reply #12
I have several HDCDs. I don't know if this is the kind of thing you're looking for in a sample, but I have at least one CD where all the music is standard Redbook and the dialogue tracks are HDCD, and I think at least one of the tracks is mixed and the HDCD tag suddenly changes from no to yes as soon as the dialogue portion starts. Honestly it kinda just seems to be working properly on playback, even though the CDs are weird.

I also have some compilation CDs which have some Redbook and occasionally an HDCD track.
Think millionaire, but with cannons.

Re: Title formatting/syntax for proper bitdepth

Reply #13
I read all the links you gave, @Porcus, and a bit more.

I implemented some changes which hopefully make the decoder work better. At least my test track decodes correctly and ToolLateralusTr1First30Frames is detected as HDCD. In worst case I ruined everything and I don't really have test material.
The problem described at https://hydrogenaud.io/index.php/topic,79427.msg992798.html#msg992798 sounds like something that would absolutely need fixing.

Changes I made so far:
- Switched from 10 second buffer to two seconds and removed the delay before the process starts working.
- Removed IMO nonsensical rules that allowed HDCD detection to run on any number of channels and on random sample rates. Now only 44100 Hz 16-bit lossless stereo is processed.
- bitspersample info field isn't modified - decoded bit depth is reported in decoded_bitspersample. And I changed it to report 20 bps.
- The HDCD "no" tag now also supports values "0" and "off".
- Scanner result dialog is now dark mode aware, allows more threads, opens decoders with faster flags and does HDCD detection itself instead of reading tags (which is both slow and inaccurate).

I'd appreciate people testing if the changes broke something. Currently the test version just lives here: https://foobar.hyv.fi/foo_hdcd.fb2k-component

Re: Title formatting/syntax for proper bitdepth

Reply #14
- Removed IMO nonsensical rules that allowed HDCD detection to run on any number of channels and on random sample rates. Now only 44100 Hz 16-bit lossless stereo is processed.
Sounds sensible.
However according to https://wiki.hydrogenaud.io/index.php?title=High_Definition_Compatible_Digital#Audio_Formats , the Pacific Model Two could "encode" HDCD in all DVD-Audio formats as well. I do not know if anything such happened except by those "no HDCD features" thing.


Oh, and before I get home to testing it (that's gonna be a while though):
- bitspersample info field isn't modified - decoded bit depth is reported in decoded_bitspersample. And I changed it to report 20 bps.
Which is part of the marketing bogus of course ... (I don't think I've ever seen "18" anywhere, then that might be useful to uniquely identify it). 
- The HDCD "no" tag now also supports values "0" and "off".
Good! Can be used to distinguish out various levels of suspicion.
(Supporting value "fake" would maybe not look like neutral language, but ...)

Re: Title formatting/syntax for proper bitdepth

Reply #15
However according to https://wiki.hydrogenaud.io/index.php?title=High_Definition_Compatible_Digital#Audio_Formats , the Pacific Model Two could "encode" HDCD in all DVD-Audio formats as well.
That was news to me. I'm not sure I visited that page, but wikipedia didn't mention anything about that. I see the old press release from Microsoft mentions briefly "to compact disc and DVD audio", but all the other points about HDCD just talk about CDs. Old news article also just talks about CD use.
Can't help but mention that HDCD makes no sense in DVD Audio as the format natively supports real lossless 24-bits and high sample rates.

Re: Title formatting/syntax for proper bitdepth

Reply #16
- bitspersample info field isn't modified - decoded bit depth is reported in decoded_bitspersample. And I changed it to report 20 bps.
Hmmm, I'm not so crazy about that.

It's different from what happens with SACD/DST content. Not playing DST content shows a sample rate of 2822kHz with 1 bits per sample. Playing DST content shows the samplerate you selected in settings and 24bits per sample. So bits per sample (and sample rate) is actually changed upon playing.

I'd rather see the same behavior with HDCD. which means bits per sample for playing HDCD as it used to be 24 (or 20 which I force myself), and just publish an extra field "original_bitspersample" upon playing HDCD.

Re: Title formatting/syntax for proper bitdepth

Reply #17
However according to https://wiki.hydrogenaud.io/index.php?title=High_Definition_Compatible_Digital#Audio_Formats , the Pacific Model Two could "encode" HDCD in all DVD-Audio formats as well.
That was news to me. I'm not sure I visited that page, but wikipedia didn't mention anything about that. I see the old press release from Microsoft mentions briefly "to compact disc and DVD audio", but all the other points about HDCD just talk about CDs.

Apparently, Neil Young ... https://forums.stevehoffman.tv/threads/neil-young-harvest-dvd-a.7613/ ... but that isn't to say that any HDCD "features" were switched on.

This post mentions 48 kHz and multiples in connection with the "special mode" that was never intended to be used for final masterings (and cannot be decoded by consumer DAC chips anyway): https://www.head-fi.org/threads/hdcd-list.65414/page-39#post-12725140
... and then of course, it has happened that a "special mode" (7.5 dB) signal has been pressed to CD and released, by stupidity or other error.

Re: Title formatting/syntax for proper bitdepth

Reply #18
- bitspersample info field isn't modified - decoded bit depth is reported in decoded_bitspersample. And I changed it to report 20 bps.
Hmmm, I'm not so crazy about that.
I queried Peter's opinion after your comment. He agreed that decoded_bitspersample is the right field, also used by first party ADPCM decoding. Bitspersample reports original bit depth, the decoded_ variant reports the end result after decoding.

DSD decoder is a third party component, its behavior may not exactly be what has been intented. In my opinion reporting 1-bit DSD as 24-bit for example is a blatant lie. Reporting different sample rate is a lie too, but I recall at least with old foobar2000 there were some technical reasons to do it.

Apparently, Neil Young ... https://forums.stevehoffman.tv/threads/neil-young-harvest-dvd-a.7613/ ... but that isn't to say that any HDCD "features" were switched on.
You made me read a lot more. The mention of HDCD seems to just refer to the use of "Model Two" A/D converter, which apparently was better than most other equipment back in the day. Note that for example the disc or its booklet never claim to be HDCD: https://www.discogs.com/release/710813-Neil-Young-Harvest

This post mentions 48 kHz and multiples in connection with the "special mode" that was never intended to be used for final masterings (and cannot be decoded by consumer DAC chips anyway): https://www.head-fi.org/threads/hdcd-list.65414/page-39#post-12725140
... and then of course, it has happened that a "special mode" (7.5 dB) signal has been pressed to CD and released, by stupidity or other error.
I got the Model Two manual too and read through it. I understand "potential expense of undecoded compatibility" to mean that there can potentially be compatibility issues without decoding, so affecting non-HDCD players. Though it only makes sense if by compatibility they mean quality instead. They say it's typically only used for temporary storing for later revisement, but it doesn't claim that engineer wanting to maximize dynamic range without giving rat's ass about non-HDCD decoders is in error.

The best part about the manual is IMO the HDCD overview section:
X
Quote
16-bit Encoding
Most of the intelligence of the HDCD process has been incorporated in the Model Two HDCD
Processor, lowering the cost to implement HDCD decoding in consumer equipment. An
analog signal fed to the Processor is converted into a digital signal having a 24-bit word
length and a sampling frequency of 176.4 kHz. After decimation to 88.2 kHz, a continuous,
real-time analysis of the signal is made using DSP to determine what elements beyond the
range of conventional 16-bit, 44.1 kHz, formats are perceptually important. The analysis
uses algorithms derived from Pacific Microsonics’ research on psychoacoustics and the
mechanisms of auditory perception.
Once the perceptually important high-resolution information is identified, it is encoded
into a Compact Disc standard, 16-bit, 44.1 kHz, linear PCM signal using two methods. Part
of the information is added directly to the 16-bit signal by optimizing utilization of its
linear bits, and part is hidden in the LSB of the 16-bit signal. Over time, less than 5% of
the LSB is used for the hidden code. The encoded information is inaudible and causes no
perceptible loss of information.
It only talks about using HDCD to produce Red Book CD.

Re: Title formatting/syntax for proper bitdepth

Reply #19
(I don't think I've ever seen "18" anywhere, then that might be useful to uniquely identify it).
I often create bit depth reduced files (source always 24/96), usually target is 20 bps, which greatly helps reduce file sizes. I was wondering if there is a way to detect such files later... Some sort of an LSB analyzer. In order to be aware of such files, I consistently set a tag. But if for whatever reason the tag gets lost, I cannot detect such files.

X

Into 24 bit files with decent resolution, one could use up to 8 bits and do serious steganography in it :-D Hidden messages like "u a o philes sck", songs like "your golden cable sounds silver - ask for a refund.m4a"

Re: Title formatting/syntax for proper bitdepth

Reply #20
I often create bit depth reduced files (source always had 24), usually to 20 bps, which greatly helps reduce file sizes. I was wondering if there is a way to detect such files later... Some sort of an LSB analyzer.
For example scanning them with SoX.
Code: [Select]
sox.exe filename -n stats
Result looks like
Code: [Select]
             Overall     Left      Right
DC offset   0.000002  0.000002 -0.000000
Min level  -0.989525 -0.989525 -0.941801
Max level   0.999617  0.999617  0.970646
Pk lev dB      -0.00     -0.00     -0.26
RMS lev dB    -12.12    -12.15    -12.09
RMS Pk dB      -8.10     -8.10     -8.57
RMS Tr dB    -259.82   -259.79   -259.82
Crest factor       -      4.05      3.91
Flat factor     0.00      0.00      0.00
Pk count           2         2         2
Bit-depth      20/20     20/20     20/20
Num samples    19.1M
Length s     434.233
Scale max   1.000000
Window s       0.050
"Bit-depth" is what you need.

Re: Title formatting/syntax for proper bitdepth

Reply #21
scanning them with SoX.
Code: [Select]
sox.exe filename -n stats
Argh, the obvious solution. It works, thx. Will put that into foo_run.
@Case, wouldn't that "real bit depth detection" be nice to have in your Truepeak Scanner? Which already is more than just a peak analysis tool...

Re: Title formatting/syntax for proper bitdepth

Reply #22
- bitspersample info field isn't modified - decoded bit depth is reported in decoded_bitspersample. And I changed it to report 20 bps.
Hmmm, I'm not so crazy about that.
I queried Peter's opinion after your comment. He agreed that decoded_bitspersample is the right field, also used by first party ADPCM decoding. Bitspersample reports original bit depth, the decoded_ variant reports the end result after decoding.
Fine, I changed my code accordingly.

Please consider the other part of my earlier request:

Since I already scan all files with your Truepeakscanner utility (all options enabled), it would be nice if TPS would also identify HDCD content with an added bonus of detecting %__hdcd_peak_extend%, %__hdcd_gain% and %__hdcd_transient_filter% and write four extra tags for found HDCD content?

It's peak and gain related so would fit nicely in the TPS imo.

Proposed tagnames:
TRUEPEAKSCANNER_HDCD_ENABLED
TRUEPEAKSCANNER_HDCD_PEAK_EXTEND
TRUEPEAKSCANNER_HDCD_GAIN
TRUEPEAKSCANNER_HDCD_TRANSIENT_FILTER

and for the heck of it

TRUEPEAKSCANNER_HDCD_DECODED_BITSPERSAMPLE

Re: Title formatting/syntax for proper bitdepth

Reply #23
@Case
your component seems to work properly on hdcd files - musicwise.
As for titleformatting/syntax for bitdepth it changed few things.
What I actually wanted to achieve (and did not write explicitly in my first post) was to have 3 infos:
1. bitdepth of the file
2. bitdepth after being decoded
3. bitdepth on the output device
The first shown in Columns, the second in bottom bar and all three in JS Text display.
With your new version of hdcd component I get always 16 bit on the bottom bar for HDCD files - so it stopped showing decoded bitdepth and shows file bitdepth.

In JS Text Display use:
bitspersample
decoded_bitspersample - it shows 20 bit for HDCD but it shows nothing for any other files - it would be great to make it show the same info as bitspersample if those values are equal (why it shows info only when they are not?)
bitspersample_extra - it never showed me anything - why??? What is the purpose of this function?
and your output component.

So for "standard" files I would get ex. 16 (file), 16 (decoded), 32 (output) or 24/24/32 and for hdcd it would be 16/20/32.

I use bitspersample in bottom bar - it used to show 24 bit for hdcd, now it's 16. So I put decoded_bitspersample - it shows 2- bit for hdcd but nothing for other files.
I know I can do "if hdcd show decoded_bitspersample or else show bitspersample" but that would again be "hardcodding" and not reading/measuring from the actual audio-chain.
The new aproach in the bottom bar (showing 16 bit for hdcd) is inconsistent with ex. SACD which shows 2,82 if I use Native DSD or 192 (or other chosen frequency) if I change the plugin to PCM output.

So my questions are:
1. is it possible to make "decoded_bitspersample" always show actual data after decoding and not only if the output is different than the input? Or in other words it would revert to "bitspersample" if there is no difference.
2. what is "bitspersample_extra" - why doesn't it show anything?

Edit. is there any way to make your output component show dsd?





Re: Title formatting/syntax for proper bitdepth

Reply #24
@Case, wouldn't that "real bit depth detection" be nice to have in your Truepeak Scanner? Which already is more than just a peak analysis tool...
I'll think about it. It is true that it's not just a peak scanner anymore, though it has always been loudness-centered. It started its life as true peak scanner to complete ReplayGain scanner. Bit depth doesn't affect loudness, but it could be considered related as it does affect SNR.

Since I already scan all files with your Truepeakscanner utility (all options enabled), it would be nice if TPS would also identify HDCD content with an added bonus of detecting %__hdcd_peak_extend%, %__hdcd_gain% and %__hdcd_transient_filter% and write four extra tags for found HDCD content?
I'm not a fan of this idea at least at the moment. Or do you not mean bundling HDCD decoder, just detecting values from those info fields? What would you think to save in the tags, just "yes" or "no" that the effects are used?