Re: question about sampling rate

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Grace Baldonasa wrote:
> /*
> * convert a sampling rate into our full speed format (fs/1000 in Q16.16)
> * this will overflow at approx 524 kHz
> */
> inline static unsigned get_usb_full_speed_rate(unsigned int rate)
> {
> return ((rate << 13) + 62) / 125;
> }
> 
> I have no clue as to why rate was shifted by 13 then added by 62 then
> divided by 125.

The parameter is in Hz.  To convert to the number of samples per USB
frame, we have to divide by 1000.  To convert to a 16.16-fixed-point
number, we have to multiply by 2^16.  This would result in "rate *
0x10000 / 1000".  Factoring out 8 yields "rate * 0x2000 / 125".  The
multiplication by a power of two can be replaced by a bitwise left
shift.  The "+62" prevents the division from rounding down.


HTH
Clemens


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Alsa-devel mailing list
Alsa-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/alsa-devel

[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux