## Topic: Is it possible to stretch 16 bits symmetrically? (Read 25364 times)previous topic - next topic

0 Members and 1 Guest are viewing this topic.
• giro1991
Is it possible to stretch 16 bits symmetrically?
##### 13 April, 2014, 03:40:51 PM
Hello all,

Odd question but is it possible to stretch 16 bits file outward symetrically to 32bit, instead of padding?

Perhaps with addition of upsampling at the same time could generate a new wave entirely in the digital 'realm'.
Like an artifical re-creation of the wave.

Thoughts welcome.

Cheers

EDIT, is fixed / floating point precision related to this?

• Nick.C
• Developer
Is it possible to stretch 16 bits symmetrically?
##### Reply #1 – 13 April, 2014, 04:21:19 PM
Odd question but is it possible to stretch 16 bits file outward symetrically to 32bit, instead of padding?

Padding with 16-bits moves the existing 16-bit samples 16-bits apart, i.e. multiplies them by 65536. Is that not stretching?
lossyWAV -q X -a 4 -s h -A --feedback 1| FLAC -5 -e -p -b 512 -P=4096 -S- ~= 320kbps

• xnor
• Developer
Is it possible to stretch 16 bits symmetrically?
##### Reply #2 – 13 April, 2014, 04:22:10 PM
16-bit signed: -32768 to +32767.
Example: a value of 8 (binary 1000) is -72.25 dB below full scale.

32-bit signed: -2147483648 to +2147483647.
Example: a value of 8*65536 = 524288 (binary 1000 0000 0000 0000 0000) is -72.25 dB below full scale.

Anything other than multiplying by 65536 (the 16 extra bits = 2^16) will result in distortion.
In binary, a multiplication by 2 is just shifting all bits to the left by one bit. Multiplying by 2^16 is equivalent to shifting all bits to the left 16 times.

edit: The extra 16 bits just add extra dynamic range.
Think of it this way: if you don't multiply the values you get the same signal at 32 bits but a very low level. Above the original values you then have 16 empty bits for extra dynamic range.
"I hear it when I see it."

Is it possible to stretch 16 bits symmetrically?
##### Reply #3 – 13 April, 2014, 04:44:50 PM
I know that for unsigned integers, the simplest way to stretch a lower number of bits to a higher number of bits while maintaining the full range is to duplicate the higher bits into the low bits. For 16-bit to 32-bit, you'd just duplicate the entire 16 bits. This method is frequently used in image processing, where it is important that the range of color is not reduced during upsampling.

This method is slightly incorrect for signed values, which are typical of 16-bit audio. I never did work out if there was an easier way, but you could achieve the correct results by converting to unsigned, upsampling, and then converting back to signed.

If the destination format is floating-point, then it's even easier: convert the number to a float, then divide by 32767.

However, I would choose to zero-pad in order to upconvert. It is mathematically correct for both signed and unsigned, and some lossless codecs (including FLAC, which I typically use) have specific optimizations to compress the padding.

I don't know of any algorithms that would help "regenerate" the lower bits, but I do know that there is not much sense in trying if the audio is already 16-bit to begin with.

• saratoga
Is it possible to stretch 16 bits symmetrically?
##### Reply #4 – 13 April, 2014, 05:15:07 PM
This question doesn't make sense, but probably ordinary zero padding is what the OP is asking for.

• db1989
• Global Moderator
Is it possible to stretch 16 bits symmetrically?
##### Reply #5 – 13 April, 2014, 06:08:29 PM
edit: The extra 16 bits just add extra dynamic range.
Think of it this way: if you don't multiply the values you get the same signal at 32 bits but a very low level. Above the original values you then have 16 empty bits for extra dynamic range.
Whereas if you do shift/0-pad, you get the signal at the same level but with more room for finer details in the new lower bits.

• Martel
Is it possible to stretch 16 bits symmetrically?
##### Reply #6 – 14 April, 2014, 04:54:45 AM
Perhaps with addition of upsampling at the same time could generate a new wave entirely in the digital 'realm'.
Like an artifical re-creation of the wave.
You can't get any more information about the original wave than what was in the original digitized waveform. No amount of upsampling/upconverting is going to re-introduce information lost during digitization of the original signal.
What you call "an artifical re-creation of the wave" is actually done in a digital-to-analogue converter and results in a "perfectly smooth" analogue wave. Only frequencies above half of the original sampling frequency are missing and quiet components might drown in the quantization noise. But all this was already lost, the best you could do is somehow make up the missing information (empirical/statistical modelling) but this is never going to be perfect (the precise information is lost).

If you convert a 44.1kHz/16bit waveform of a 1kHz sine wave to 192kHz/24bit, it will appear "smoother" (i.e. it will have more samples, there will be sample values using all 24 bits) but no additional information will be actually created.
IE4 Rockbox Clip+ AAC@192; HD 668B/HD 518 Xonar DX FB2k FLAC;

• giro1991
Is it possible to stretch 16 bits symmetrically?
##### Reply #7 – 14 April, 2014, 11:09:27 AM
... you could achieve the correct results by converting to unsigned, upsampling, and then converting back to signed.

If the destination format is floating-point, then it's even easier: convert the number to a float, then divide by 32767.

I don't know of any algorithms that would help "regenerate" the lower bits, but I do know that there is not much sense in trying if the audio is already 16-bit to begin with.

Yes, this is my main curiosity.
Consider computer graphics for example, edges in games are jagged by default, then it is up to another (independant) algorithm to smooth out edges. Likewise for images.

From that smooth edge produced you can always go back to the orginal by reversing surely.

What you call "an artifical re-creation of the wave" is actually done in a digital-to-analogue converter and results in a "perfectly smooth" analogue wave."

Forget "digital filters" found on hardware for time being.
Smoothness in the dsp realm is what would like to acheive, if input is 16, obviously you need to down convert to 16bit for playback, what what i'm interested in though is the stage between, which exists only in the computational realm, a signal to 'work with'.

I am aware you can't add details from the original session/track of course, but that is not my curiosity..

I notice foobar pipeline is 32bit float internal, If I were to enable an up sampler for example, I wonder if the wave is zero padded or in fact a genuine wave spanning the enire 32bit realm or whther or not I need to infact sign and unsign in between, with the additonal samples of course.

• giro1991
Is it possible to stretch 16 bits symmetrically?
##### Reply #8 – 14 April, 2014, 11:12:36 AM
It may be odd question but reciprocal thinking is healthy.

• pdq
Is it possible to stretch 16 bits symmetrically?
##### Reply #9 – 14 April, 2014, 11:29:11 AM
It may be odd question but reciprocal thinking is healthy.

That may be, but until someone here actually understands what you are trying to ask, you may not get any satisfactory answers.

• saratoga
Is it possible to stretch 16 bits symmetrically?
##### Reply #10 – 14 April, 2014, 11:31:36 AM
Resizing an image is analogous to resampling audio, not zero padding.

• pdq
Is it possible to stretch 16 bits symmetrically?
##### Reply #11 – 14 April, 2014, 11:45:16 AM
If you resize an image to increase the number of pixels, it becomes closer and closer to being continuous, but no matter what, it still consists of pixels.

This is not the case with audio. The reconstruction filter that follows digital-to-analog conversion creates a true, continuous, analog signal with no "steps".

• Martel
Is it possible to stretch 16 bits symmetrically?
##### Reply #12 – 14 April, 2014, 11:59:13 AM
Have you ever thought about why computer games take a considerable performance hit from enabling anti-aliasing? It's not just some cheap soften or edge-detection (un-informed algorithm) applied to the image. The graphics card is actually calculating more information about the image. It's not just up-converting the aliased base resolution image (without AA).
IE4 Rockbox Clip+ AAC@192; HD 668B/HD 518 Xonar DX FB2k FLAC;

• drewfx
Is it possible to stretch 16 bits symmetrically?
##### Reply #13 – 14 April, 2014, 12:00:52 PM
Assuming you are trying to generate a new and different sounding (distorted) waveform and aren't trying to "add detail" or something like that to the original, it is of course possible.

• [JAZ]
Is it possible to stretch 16 bits symmetrically?
##### Reply #14 – 14 April, 2014, 05:25:07 PM
like saratoga said, the analogy with resizing an image is actually equivalent to resampling, and resampling is perfectly possible with audio.

The correct analogy is color bit depth.  You cannot get a 24bit color image out of a 8bit image, just like you cannot get a 24bit sound file out of an 8 bit sound file. The "noise" (lack of precision) is maintained.

On Audio, I thought once of a method to "kill" the noise floor, but my (lack of) knowledge, and some limitations that I've read about point that it could produce unwanted results. Basically, it would be to try to apply the "noise gate" idea in the frequency domain. I.e. audio->frequency, zero frequencies below a determined dB range, frequency -> audio.
I had this idea when listening to some low bitrate (bad quality) MP3 files out of Vinyl. Since there weren't enough bits, the encoder was removing part of the background noise (not only because of the filter).

• giro1991
Is it possible to stretch 16 bits symmetrically?
##### Reply #15 – 15 April, 2014, 12:50:17 PM
Glad hear this regarding that analogy.  I am a not a proffesional in this subject so bear with me.
I do not believe waveshaping is what I'm after.
It surprises me that I cannot find a dsp that quantizes to 32bit to create this fanatical wave.
I did find a "crusher" which can output 24bit (not sure if this is it, but it appears to work below).
24 is enough but surely 32bit would be easier to compute from 16bit?

Most application pipelines are 32/64bit float but never involve this 'spreading' because it is presumed 9/10 users have a well implimented DAC on the end to do alll this fiddle, which I am trying to acheive myself.

I'm certain a 32bit quantizer would be beneficial if used with a upsampler, to generate a signal.
Cant help but notice Quantize and quantum are alike - picture the digital 'realm'I picture it like this in my head, though not as many waves.

This is the closest I got to below, though only 24bit, and the results through mobo output improved considerably in the treble tregion, I even applied a steep filter at 10k (like the Asus One does!) and the highs differed very little which really surprised me, though I am doing this through rubbish portable speakers, the result is definately pleasant compared to default mobo dac.
So much so it makes me wonder how they are even classed as safe for manufacture because the highs are litterally deafening.

I was reading the application of a 14bit dac from the 80's to get an idea and noticed the clever use of a ramp like dither applied towards the end of the spectrum to keep SNR low and slow roll off to aid output in a way I can not explain technically (which is what makes CDPs sound how they do, it essentially a DSP priot to dac).

There is also this same ramp shape on the geektronic dsp and can be made to to oscilate with the speed notch.

I know to some people on this forum this is not news, but for laymen like myself it would very interesting to experiment with a 32 bit quantizer, if one exists.

• saratoga
Is it possible to stretch 16 bits symmetrically?
##### Reply #16 – 15 April, 2014, 12:56:40 PM
Glad hear this regarding that analogy.  I am a not a proffesional in this subject so bear with me.
I do not believe waveshaping is what I'm after.
It surprises me that I cannot find a dsp that quantizes to 32bit to create this fanatical wave.

On a typical PC, almost all DSP effects will be quantized at 32 bits because they use 32/64 bit processors.  Beyond what you already have, I do not understand what you are expecting to find.

• giro1991
Is it possible to stretch 16 bits symmetrically?
##### Reply #17 – 15 April, 2014, 01:08:04 PM
The way I picture it,
bit depth is vertical definition and
sample rate is horizontal definition.
surely, stretching bitdepth (however acheived) would allow more definition... and you could technically keep adding definition, (not from the original source of course) but definition in the quantum realm.

EDIT: as opposed to padding with zero's which im certain is what pieplines do.

• giro1991
Is it possible to stretch 16 bits symmetrically?
##### Reply #18 – 15 April, 2014, 01:18:56 PM
edit: The extra 16 bits just add extra dynamic range.

Perhaps in a playback sense yes, but isnt dynamic range just a measure that exists otherwise in the digital realm?

• saratoga
Is it possible to stretch 16 bits symmetrically?
##### Reply #19 – 15 April, 2014, 02:09:26 PM
EDIT: as opposed to padding with zero's which im certain is what pieplines do.

They're exactly the same thing.  One and the same.

And yes, internally everything you're processing is running at 32 bit or higher, so this is being done for you already.

• db1989
• Global Moderator
Is it possible to stretch 16 bits symmetrically?
##### Reply #20 – 15 April, 2014, 02:16:12 PM
Multiplying a.k.a. shifting a.k.a. padding with 0s is stretching the sampling points.

0 becomes 0. 1 becomes 2. 2 becomes 4. And so on.

Quote
I am a not a proffesional in this subject so bear with me.
You donâ€™t need to be a professional to think about this for a few seconds and realise that what you want is already being done and your alternative hypothetical methods are nonsensical.

• [JAZ]
Is it possible to stretch 16 bits symmetrically?
##### Reply #21 – 15 April, 2014, 05:39:58 PM
I should start by saying that I haven't understand half of your post, so this is an advise.

Said that, you are still confusing concepts. Audio is one dimensional. 2D Graphics are two dimensional. 3D graphics are three dimensional.  Or said it in other words, at one point in time, audio has only one value, graphics have an X/Y or X/Y/X coordinate (depending on 2D or 3D).

As I said before, you should not think on audio bitdepth as a "vertical", or "Y" coordinate. It is comparable to color depth, not to any coordinate.

When audio is sampled, it is sampled at a constant speed. This gives it some properties which translate in preserving frequencies up to half its samplerate (strictly lower than). With adequate algorithms, the samplerate can be changed while maintaining all the frequencies (depending on the filter slope used, and always being the highest one to preseve, less than double the samplerate).

But while the time is strictly defined and constant (and even when it isn't, and there's jitter, most of the time it can be safely ignored), the same isn't true for the value we store for that time. We quantize to a discrete amount of values, determined by the bit depth used.

Say we record 33.40, 44.15, 25.90.  But when writing the file, we need to store 33, 44 and 26.  The difference between the real value and the value stored is not only a numerical difference, but also part of the audio that will be reproduced. The correct term is quantization distortion.
This distortion will be present in the audio, is correlated to the signal, and isn't nice.
To avoid the correlation, which is what makes it bad, a process called "dither" is applied, which means that, instead of quantizing based on the recorded value, a noise signal is added before quantizing (which can be of different kinds, and desirably shaped so that more noise is present in the upper frequencies, to improve the lower ones).

So now, this noise+signal+quantization is going to become only signal by which means exactly?

Edit:  Just to make it clear... What i am saying is that audio bit depth cannot be improved. As it has been said, when increasing the bit depth, the usual method is zero-padding. It's the safest bet. One can also add noise at the next bit, but adding noise on all new bits is useless.

Edit2: It just occurred to me that the other concept that you might think when talking about stretching isn't what you expect. If you expand the 16bits, so that they are evenly distributed on a 24bit signal, or 32bit signal, what you have achieved is volume boosting it. But since 24 or 32bit have the same 0dBFS, what you end with is a more silent file, with the opposite effect of a DSP compressor.

• xnor
• Developer
Is it possible to stretch 16 bits symmetrically?
##### Reply #22 – 16 April, 2014, 08:51:53 AM
The way I picture it,
bit depth is vertical definition and
sample rate is horizontal definition.
surely, stretching bitdepth (however acheived) would allow more definition... and you could technically keep adding definition, (not from the original source of course) but definition in the quantum realm.

EDIT: as opposed to padding with zero's which im certain is what pieplines do.

Well kinda, see [JAZ]'s post above.

At each sampling interval you measure the current value, for example 0.472392 and then you quantize to 16 bits 0.472392 * 32768 = 15479[.341056]. The decimal places cannot be stored so you get a quantization error.

This error is irreversible.
If you resample to a higher sample rate all you do is interpolate between existing points (that all have quantization errors).
If you increase the bit depth you get exactly the same signal with some empty (wasted) bits.

Higher bit depth makes sense when you do processing. If you quantized back to 16 bits after each processing step you would potentially accumulate a lot of errors.

Perhaps in a playback sense yes, but isnt dynamic range just a measure that exists otherwise in the digital realm?

Put simply, increasing dynamic range is all that extra bits do. You can only make use of this though, if the original signal uses that dynamic range or even exceed it.
"I hear it when I see it."

• dhromed
Is it possible to stretch 16 bits symmetrically?
##### Reply #23 – 16 April, 2014, 09:30:42 AM
surely, stretching bitdepth (however acheived) would allow more definition

You're confusing stretching a value across a new range, with "stretching" the bits that represent that value.

Say, the maximum 4-bit value is:

1111

And then you "stretch" it across 8 bits, according to your idea:

10101010

It's no longer the maximum! It's just a random value. You just distorted the signal. Good job.

11110000

We don't know anything about those lower 4 bits. That information does not exist. At all. Therefore we can't make them 1111 as well.

• DVDdoug
Is it possible to stretch 16 bits symmetrically?
##### Reply #24 – 16 April, 2014, 03:18:19 PM
Quote
Is it possible to stretch 16 bits symetrically?, instead of padding with zero's?
I have another simple analogy for you -

If you convert dollars to cents, it gets "padded with zeros".

If you convert meters to millimeters, it gets "padded with zeros".

Remember we are starting out with integers,  so you can't start-out with \$111.25 and get 11125 cents.  If you start with \$111 you get 11100 cents...  Two more zeros with no more information.

Now once you've converted to pennies, you can start keeping track of changes, deposits, withdrawals, interest, etc., with more precision.  But with 32-bit audio it's sort-of like keeping track of 1/1000th or 1 millionth of a penny...  Too small to worry about...