FPGA Central - World's 1st FPGA / CPLD Portal

FPGA Central

World's 1st FPGA Portal

 

Go Back   FPGA Groups > NewsGroup > DSP

DSP comp.dsp newsgroup, mailing list

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-12-2009, 11:12 PM
gct
Guest
 
Posts: n/a
Default Calculating dynamic range on signed data?

I've got some signed audio data (16 bit so -32768-32767) and I'd like to
calculate a dynamic range figure for it, but obviously taking the logarithm
of a negative number is a no-no, but neither shifting the scale so
everything's positive or absolute value seem right to me. Is there a
'correct' way to do this?
Reply With Quote
  #2 (permalink)  
Old 12-12-2009, 11:24 PM
Steve Pope
Guest
 
Posts: n/a
Default Re: Calculating dynamic range on signed data?

gct <[email protected]> wrote:

>I've got some signed audio data (16 bit so -32768-32767) and I'd like to
>calculate a dynamic range figure for it, but obviously taking the logarithm
>of a negative number is a no-no, but neither shifting the scale so
>everything's positive or absolute value seem right to me. Is there a
>'correct' way to do this?


Like any estimation problem you must use some form of filtering or
ensemble averaging to get a meaningful result.

So what you want is a sliding window operation followed by a RMS
calculation. The maximum and minimum values thus exhibited as
you slide the window over your data will be its dynamic range.
The characteristics of the window/filter must "make sense" with
respect to your data.

Hope this helps.

Steve
Reply With Quote
  #3 (permalink)  
Old 12-12-2009, 11:33 PM
gct
Guest
 
Posts: n/a
Default Re: Calculating dynamic range on signed data?

>So what you want is a sliding window operation followed by a RMS
>calculation. The maximum and minimum values thus exhibited as
>you slide the window over your data will be its dynamic range.
>The characteristics of the window/filter must "make sense" with
>respect to your data.
>
>Hope this helps.
>
>Steve
>


OK so I slide a window over the data finding RMS values for each location
then find the max/min RMS values to get the dynamic range?
Reply With Quote
  #4 (permalink)  
Old 12-13-2009, 12:25 AM
Steve Pope
Guest
 
Posts: n/a
Default Re: Calculating dynamic range on signed data?

gct <[email protected]> replies to my post,

>>So what you want is a sliding window operation followed by a RMS
>>calculation. The maximum and minimum values thus exhibited as
>>you slide the window over your data will be its dynamic range.
>>The characteristics of the window/filter must "make sense" with
>>respect to your data.


>OK so I slide a window over the data finding RMS values for each location,
>then find the max/min RMS values to get the dynamic range?


Correct. To get dynamic range in dB, take 20 * log10 * max(RMS)/min(RMS) .

But beware you will not get a meaningful number if your window
is either too short or too long. This is why one cannot usually speak
of "the" dynamic range of a signal. (Or, "the" power spectral density
of a signal, but we've had that discussion before.)

Steve
Reply With Quote
  #5 (permalink)  
Old 12-13-2009, 01:16 AM
Jerry Avins
Guest
 
Posts: n/a
Default Re: Calculating dynamic range on signed data?

gct wrote:
> I've got some signed audio data (16 bit so -32768-32767) and I'd like to
> calculate a dynamic range figure for it, but obviously taking the logarithm
> of a negative number is a no-no, but neither shifting the scale so
> everything's positive or absolute value seem right to me. Is there a
> 'correct' way to do this?


The dynamic range in bits is just the largest magnitude -- + or - --
contained in the file. Remember: you can't take the log of zero, either.
It is customary to take the lowest value as 1 for just that reason.

Jerry
--
Engineering is the art of making what you want from things you can get.
ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
Reply With Quote
  #6 (permalink)  
Old 12-13-2009, 01:19 AM
Jerry Avins
Guest
 
Posts: n/a
Default Re: Calculating dynamic range on signed data?

Steve Pope wrote:
> gct <[email protected]> replies to my post,
>
>>> So what you want is a sliding window operation followed by a RMS
>>> calculation. The maximum and minimum values thus exhibited as
>>> you slide the window over your data will be its dynamic range.
>>> The characteristics of the window/filter must "make sense" with
>>> respect to your data.

>
>> OK so I slide a window over the data finding RMS values for each location,
>> then find the max/min RMS values to get the dynamic range?

>
> Correct. To get dynamic range in dB, take 20 * log10 * max(RMS)/min(RMS) .
>
> But beware you will not get a meaningful number if your window
> is either too short or too long. This is why one cannot usually speak
> of "the" dynamic range of a signal. (Or, "the" power spectral density
> of a signal, but we've had that discussion before.)


My prescription accounts for the dynamic range of the system needed to
reproduce the entire file. Other requirements will dictate different
approaches.

Jerry
--
Engineering is the art of making what you want from things you can get.
ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
Reply With Quote
  #7 (permalink)  
Old 12-13-2009, 01:25 AM
Steve Pope
Guest
 
Posts: n/a
Default Re: Calculating dynamic range on signed data?

Jerry Avins <[email protected]> wrote:

>gct wrote:


>> I've got some signed audio data (16 bit so -32768-32767) and I'd like to
>> calculate a dynamic range figure for it, but obviously taking the logarithm
>> of a negative number is a no-no, but neither shifting the scale so
>> everything's positive or absolute value seem right to me. Is there a
>> 'correct' way to do this?


>The dynamic range in bits is just the largest magnitude -- + or - --
>contained in the file. Remember: you can't take the log of zero, either.
>It is customary to take the lowest value as 1 for just that reason.


We might need to ask the OP what he means by dynamic range.

Your approach has some interesting outcomes, such as a steady
sine wave nonetheless having a huge dynamic range....

Steve
Reply With Quote
  #8 (permalink)  
Old 12-13-2009, 02:08 AM
glen herrmannsfeldt
Guest
 
Posts: n/a
Default Re: Calculating dynamic range on signed data?

Jerry Avins <[email protected]> wrote:
(snip)

> The dynamic range in bits is just the largest magnitude -- + or - --
> contained in the file. Remember: you can't take the log of zero, either.
> It is customary to take the lowest value as 1 for just that reason.


I have thought about recording on a digital recorder with the
input shorted and considering that the low end of the dynamic range.

In 24 bits it seems unlikely that it will be zero most of
the time, but maybe in 16 bits.

Instead of dynamic range I have computed the peak (positive and
negative), and RMS for recorded data as 16 and 24 bit WAV files.

With 24 bit data, I can then scale up such that all the bits
are used before converting to 16 bits. Less worry about getting
the record level exactly right, though I try not to be too low.

-- glen
Reply With Quote
  #9 (permalink)  
Old 12-13-2009, 02:19 AM
Jerry Avins
Guest
 
Posts: n/a
Default Re: Calculating dynamic range on signed data?

Steve Pope wrote:
> Jerry Avins <[email protected]> wrote:
>
>> gct wrote:

>
>>> I've got some signed audio data (16 bit so -32768-32767) and I'd like to
>>> calculate a dynamic range figure for it, but obviously taking the logarithm
>>> of a negative number is a no-no, but neither shifting the scale so
>>> everything's positive or absolute value seem right to me. Is there a
>>> 'correct' way to do this?

>
>> The dynamic range in bits is just the largest magnitude -- + or - --
>> contained in the file. Remember: you can't take the log of zero, either.
>> It is customary to take the lowest value as 1 for just that reason.

>
> We might need to ask the OP what he means by dynamic range.
>
> Your approach has some interesting outcomes, such as a steady
> sine wave nonetheless having a huge dynamic range....


Indeed. But since the reproducer needs to handle the peak and everything
down to zero output, it makes sense for reproducers. There are systems
that become unstable if the gain becomes to small. I suppose there are
some systems that go to pot is the signal becomes too small. Class B
amplifiers usually exhibit a bit of center clipping, and so the
distortion with sinewave input decreases as the signal rises to moderate
levels. It is often said that the dynamic range of CDs is 20*log(2^15) dB.

Jerry
--
Engineering is the art of making what you want from things you can get.
ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
Reply With Quote
  #10 (permalink)  
Old 12-13-2009, 02:22 AM
gct
Guest
 
Posts: n/a
Default Re: Calculating dynamic range on signed data?

>We might need to ask the OP what he means by dynamic range.
>
>Your approach has some interesting outcomes, such as a steady
>sine wave nonetheless having a huge dynamic range....
>
>Steve
>


I originally wanted the textbook definition (or an approximation thereof)
until I realized the data was signed. I'm mainly interested in picking ou
spots where the dynamic range get's compressed, ie the audio volume stay
the same but they're trying to make it sound louder by reducing dynami
range.
Reply With Quote
  #11 (permalink)  
Old 12-13-2009, 02:31 AM
Steve Pope
Guest
 
Posts: n/a
Default Re: Calculating dynamic range on signed data?

Jerry Avins <[email protected]> wrote:

> It is often said that the dynamic range of CDs is 20*log(2^15) dB.


That's the dynamic range of a channel. I interpreted this question
as being about the dynamic range of a signal.

Steve
Reply With Quote
  #12 (permalink)  
Old 12-13-2009, 02:40 AM
Jerry Avins
Guest
 
Posts: n/a
Default Re: Calculating dynamic range on signed data?

Steve Pope wrote:
> Jerry Avins <[email protected]> wrote:
>
>> It is often said that the dynamic range of CDs is 20*log(2^15) dB.

>
> That's the dynamic range of a channel. I interpreted this question
> as being about the dynamic range of a signal.


Your interpretation is probably the right one here.

Jerry
--
Engineering is the art of making what you want from things you can get.
ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
Reply With Quote
  #13 (permalink)  
Old 12-13-2009, 03:43 AM
Tim Wescott
Guest
 
Posts: n/a
Default Re: Calculating dynamic range on signed data?

On Sat, 12 Dec 2009 16:33:05 -0600, gct wrote:

>>So what you want is a sliding window operation followed by a RMS
>>calculation. The maximum and minimum values thus exhibited as you slide
>>the window over your data will be its dynamic range. The characteristics
>>of the window/filter must "make sense" with respect to your data.
>>
>>Hope this helps.
>>
>>Steve
>>
>>

> OK so I slide a window over the data finding RMS values for each
> location, then find the max/min RMS values to get the dynamic range?


Your wording worries me.

You slide the window over the data and find the RMS value for the data in
the window for each window location (yes, that's a complicated way to say
it; sorry -- sometimes it's hard to choke precision out of English).

Then you compare max/min.

--
www.wescottdesign.com
Reply With Quote
  #14 (permalink)  
Old 12-13-2009, 03:45 AM
Tim Wescott
Guest
 
Posts: n/a
Default Re: Calculating dynamic range on signed data?

On Sat, 12 Dec 2009 19:16:31 -0500, Jerry Avins wrote:

> gct wrote:
>> I've got some signed audio data (16 bit so -32768-32767) and I'd like
>> to calculate a dynamic range figure for it, but obviously taking the
>> logarithm of a negative number is a no-no, but neither shifting the
>> scale so everything's positive or absolute value seem right to me. Is
>> there a 'correct' way to do this?

>
> The dynamic range in bits is just the largest magnitude -- + or - --
> contained in the file. Remember: you can't take the log of zero, either.
> It is customary to take the lowest value as 1 for just that reason.
>
> Jerry


OTOH, you could have perfectly valid narrow band signal that's buried
well below the quantization noise yet is still recoverable.

--
www.wescottdesign.com
Reply With Quote
  #15 (permalink)  
Old 12-13-2009, 03:52 AM
Tim Wescott
Guest
 
Posts: n/a
Default Re: Calculating dynamic range on signed data?

On Sat, 12 Dec 2009 16:12:43 -0600, gct wrote:

> I've got some signed audio data (16 bit so -32768-32767) and I'd like to
> calculate a dynamic range figure for it, but obviously taking the
> logarithm of a negative number is a no-no, but neither shifting the
> scale so everything's positive or absolute value seem right to me. Is
> there a 'correct' way to do this?


What dynamic range?

In radio practice the dynamic range is the ability for a receiver to pick
out a small signal in the presence of one or more large nearby signals; a
receiver with a really large dynamic range would be one that you could
site right next to a high-power transmitter yet still hear signals from
across the world on flea-power transmitters.

Others may specify dynamic range to be the difference between the
quietest passages in a signal vs. the loudest -- I think this is what you
mean, and if it's audio then you want to shape your test to the
psychoacoustics involved.

Even with audio the term 'dynamic range' may mean something different --
a more 'radioish' use of the term would be reproduction that's so good
you can hear the valves of the oboe clacking*, or the guitarist's fingers
squeaking on the strings (or the traffic noise outside the studio, as
they found on some of the Beatles master tapes).

* Which led to an irritating fad in classical music recording for a while
-- 'sound so good you can hear the keys clacking' was supposed to mean
'when the clacking is really, really quiet', but someone with small
imagination must have said "Oh they want to hear clacking? We'll give
'em clacking". So all of a sudden you started hearing pieces where they
were obviously miking the wind players' keys, and the conductor's feet,
etc. It seems to be dying down, mercifully.

--
www.wescottdesign.com
Reply With Quote
  #16 (permalink)  
Old 12-13-2009, 08:15 PM
Steve Pope
Guest
 
Posts: n/a
Default Re: Calculating dynamic range on signed data?

Tim Wescott <[email protected]> wrote:

>Your wording worries me.


>You slide the window over the data and find the RMS value for the data in
>the window for each window location (yes, that's a complicated way to say
>it; sorry -- sometimes it's hard to choke precision out of English).


>Then you compare max/min.



That's what I intended to suggest.

Steve
Reply With Quote
  #17 (permalink)  
Old 12-13-2009, 08:42 PM
Jerry Avins
Guest
 
Posts: n/a
Default Re: Calculating dynamic range on signed data?

Steve Pope wrote:
> Tim Wescott <[email protected]> wrote:
>
>> Your wording worries me.

>
>> You slide the window over the data and find the RMS value for the data in
>> the window for each window location (yes, that's a complicated way to say
>> it; sorry -- sometimes it's hard to choke precision out of English).

>
>> Then you compare max/min.

>
>
> That's what I intended to suggest.


The OP was thrown off by the bipolar nature of audio's instantaneous
values. Dynamic range is about magnitudes, as should be clear to him by now.

Jerry
--
Engineering is the art of making what you want from things you can get.
ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to test the dynamic range of FFT? [email protected] DSP 8 01-06-2009 05:29 AM
wonder what to do with 130 dB dynamic range? DigitalSignal DSP 58 12-21-2007 05:11 PM
Dynamic Range Karthik Ravikanti DSP 2 03-02-2006 11:38 PM
dynamic range per bit aadhi DSP 148 06-10-2005 02:32 AM
FFT dynamic range question Vinod DSP 2 08-18-2003 06:18 PM


All times are GMT +1. The time now is 02:13 AM.


Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
Copyright 2008 @ FPGA Central. All rights reserved