• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Setting volume levels?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Setting volume levels?


  • Subject: Re: Setting volume levels?
  • From: Howard Moon <email@hidden>
  • Date: Thu, 26 Jun 2003 13:09:44 -0700

On Thursday, June 26, 2003, at 03:08 PM, Jim Dolan wrote:

If I run the following code - why do I get different values in the last line?

It does not matter what value I feed in, I always get something less? I
thought maybe it was ramping but the value always seems to be less than, no
matter which direction I change the volume to.

<snip>

Volume: 0.590000 0.586691

That's because 0.59 cannot be represented exactly in memory. It's called rounding error, and it has nothing to do with the Core Audio specific calls you made. Remember that memory is binary, so only powers of 2 (including negative powers of 2, such as 0.25, or 2e-2) can be represented exactly. Instead, a binary approximation of the desired decimal value gets stored. What you see in the printf statement is a decimal representation of the actual binary number that got stored when you *tried* to set the value to 0.59. You should see the same behavior if you simply assign the value to one variable, assign that variable's value to another variable, and then printf the second variable.

-Howard
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Setting volume levels?
      • From: David Duncan <email@hidden>
References: 
 >Re: Setting volume levels? (From: David Duncan <email@hidden>)

  • Prev by Date: Re: Revised: Audio Unit Guidelines 2.0
  • Next by Date: Re: Setting volume levels?
  • Previous by thread: Re: Setting volume levels?
  • Next by thread: Re: Setting volume levels?
  • Index(es):
    • Date
    • Thread