Re: question about sampling rate

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

 



Hi,
 
Thank you so much. Really appreciate this. I have my last clarification to be made.
 
After computing the rate, value could be of decimal format, is it rounded off to either equal or greater than the whole number itself?
 
/>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
subs->freqmax = subs->freqn + (subs->freqn >> 2); /* max. allowed frequency */  
Q: why is subs->freqn shifted by 2
 
 subs->phase = 0;
 /* calculate the max. size of packet */
 maxsize = ((subs->freqmax + 0xffff) * (frame_bits >> 3)) >> 16;
 
Q: why subs->freqmax is added with 0xffff, then frame_bits is shifted by 3 then the whole thing shifted by 16.
 
<<<<<<<<<<<<<<<<<<<<<<<<<<<</
 
I understand that this value is used to determine the maxpacketsize, and I want to understand why is this so?
I really appreciate any help from you guys.
 
regards,
grace

 
On 7/12/06, Clemens Ladisch <clemens@xxxxxxxxxx> wrote:
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