How to determine a track's Bit depth

I’ve just been doing some testing.
It’s correct for 8-bit, 16-bit and 24-bit.
It’s difficult to test above 24-bit due to the many places that tiny amounts of rounding can occur.

An interesting thing that I discovered during testing, is that, at least on Linux, Audacity’s White Noise is 24-bit.

I wrote a different implementation for cross-checking. My version only deals with 8 / 16 / 24 bit integer, and assumes anything else is 32-bit float.
You can find it here: A Couple of Recording Questions - #8 by steve