Hi All, I would appreciate if you could help me in following.. I have written a simple matlab code for converting sampling rate from 8KHz to 16KHz. Now I have to measure it's SNR. For this I converted both the signals to frequency domain (taking their FFTs) and then computed signal-to-noise ratio (sum of squared input spectral samples devided by sum of squared difference between the output spectral samples and the input spectral samples). With this method I am getting SNR not more than 50-60dB (even for very high filter lengths). Can you please tell me what's wrong with my method (I have seen posting mentioning that SNR should go as high as 140dB)? Or please suggest correct method. Thank you in advance. Govind This message was sent using the Comp.DSP web interface on www.DSPRelated.com
SNR computation in SRC
Started by ●September 23, 2005
Reply by ●September 23, 20052005-09-23
in article urKdnY7SWfelqaneRVn-gw@giganews.com, Govind at govind_s@conceptemsys.com wrote on 09/23/2005 12:58:> I have written a simple matlab code for converting sampling rate from 8KHz > to 16KHz. Now I have to measure it's SNR. For this I converted both the > signals to frequency domain (taking their FFTs) and then computed > signal-to-noise ratio (sum of squared input spectral samples devided by > sum of squared difference between the output spectral samples and the > input spectral samples). With this method I am getting SNR not more than > 50-60dB (even for very high filter lengths). Can you please tell me what's > wrong with my methodnot a particular good method to compute SNR. try upsampling a collection of known sine waves from 8 to 16kHz. then generate the exact same sine waves (from the same math) but at the 16 kHz rate. make sure you have your timing lined up because your SRC will have some delay. then subtract to get a difference (or error or "noise) signal and use that in your SNR computation.> (I have seen posting mentioning that SNR should go as high as 140dB)?how long is your impulse response of your LPF? to get 140, you will need about a 64 tap FIR. -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."
Reply by ●September 24, 20052005-09-24
For SRC, the SNR is strongly dependent on what the signal is. For example, for your case of 8->16kHz, a 20 Hz signal is probably going to yield a much better SNR that a 3.9kHz signal. When I evaluate an SRC algorithm, I typically look at the interpolation filter in the frequency domain and measure the stop-band attenuation. The attenuation is directly related to the level of the alias component that will be generated. So if your filter has at least 100 dB attenuation from 4khz to 8kHz, then you should get a SNR of at least 100 dB. -- Jon Harris SPAM blocker in place: Remove 99 (but leave 7) to reply "Govind" <govind_s@conceptemsys.com> wrote in message news:urKdnY7SWfelqaneRVn-gw@giganews.com...> Hi All, > > I would appreciate if you could help me in following.. > > I have written a simple matlab code for converting sampling rate from 8KHz > to 16KHz. Now I have to measure it's SNR. For this I converted both the > signals to frequency domain (taking their FFTs) and then computed > signal-to-noise ratio (sum of squared input spectral samples devided by > sum of squared difference between the output spectral samples and the > input spectral samples). With this method I am getting SNR not more than > 50-60dB (even for very high filter lengths). Can you please tell me what's > wrong with my method (I have seen posting mentioning that SNR should go as > high as 140dB)? Or please suggest correct method. > > Thank you in advance. > > Govind > > > > This message was sent using the Comp.DSP web interface on > www.DSPRelated.com
Reply by ●September 24, 20052005-09-24
Govind wrote:> > Hi All, > > I would appreciate if you could help me in following.. > > I have written a simple matlab code for converting sampling rate from 8KHz > to 16KHz. Now I have to measure it's SNR. For this I converted both the > signals to frequency domain (taking their FFTs) and then computed > signal-to-noise ratio (sum of squared input spectral samples devided by > sum of squared difference between the output spectral samples and the > input spectral samples). With this method I am getting SNR not more than > 50-60dB (even for very high filter lengths). Can you please tell me what's > wrong with my method (I have seen posting mentioning that SNR should go as > high as 140dB)? Or please suggest correct method.I outline a slightly different method in some slides here: http://www.mega-nerd.com/tmp/secret_rabbit_code.pdf This method works pretty well. I use it in the test suite for Secret Rabbit COde: http://www.mega-nerd.com/SRC/ Erik -- +-----------------------------------------------------------+ Erik de Castro Lopo +-----------------------------------------------------------+ "Python addresses true pseudocode's two major failings: that it isn't standardized, and it isn't executable." - Grant R. Griffin in comp.dsp
Reply by ●September 26, 20052005-09-26
Thanks for the reply, I have tried with upto 1000 number of LPF filter taps. I really would like to try out method you've suggested. But is it possible that the code will give different SNR for different frequencies. If yes, then how do I represent total SNR of the system. Govind>in article urKdnY7SWfelqaneRVn-gw@giganews.com, Govind at >govind_s@conceptemsys.com wrote on 09/23/2005 12:58: > >> I have written a simple matlab code for converting sampling rate from8KHz>> to 16KHz. Now I have to measure it's SNR. For this I converted boththe>> signals to frequency domain (taking their FFTs) and then computed >> signal-to-noise ratio (sum of squared input spectral samples devidedby>> sum of squared difference between the output spectral samples and the >> input spectral samples). With this method I am getting SNR not morethan>> 50-60dB (even for very high filter lengths). Can you please tell mewhat's>> wrong with my method > >not a particular good method to compute SNR. try upsampling a collectionof>known sine waves from 8 to 16kHz. then generate the exact same sinewaves>(from the same math) but at the 16 kHz rate. make sure you have yourtiming>lined up because your SRC will have some delay. then subtract to get a >difference (or error or "noise) signal and use that in your SNRcomputation.> >> (I have seen posting mentioning that SNR should go as high as 140dB)? > >how long is your impulse response of your LPF? to get 140, you willneed>about a 64 tap FIR. > > >-- > >r b-j rbj@audioimagination.com > >"Imagination is more important than knowledge." > > >This message was sent using the Comp.DSP web interface on www.DSPRelated.com
Reply by ●September 26, 20052005-09-26
Thanks to all for your kind replies. I have one more query. How much should the transition bandwidth of LPF be for say 8KHz<=>16KHz and 8KHz<=>44.1KHz? I was suggested to keep the passband cut off at 3.5KHz, because of speech bandwidth (20Hz to 3.4KHz). But I doubt it would give me good result, since I want to use the SRC for Audio and not only for Speech. Govind>Govind wrote: >> >> Hi All, >> >> I would appreciate if you could help me in following.. >> >> I have written a simple matlab code for converting sampling rate from8KHz>> to 16KHz. Now I have to measure it's SNR. For this I converted boththe>> signals to frequency domain (taking their FFTs) and then computed >> signal-to-noise ratio (sum of squared input spectral samples devidedby>> sum of squared difference between the output spectral samples and the >> input spectral samples). With this method I am getting SNR not morethan>> 50-60dB (even for very high filter lengths). Can you please tell mewhat's>> wrong with my method (I have seen posting mentioning that SNR should goas>> high as 140dB)? Or please suggest correct method. > >I outline a slightly different method in some slides here: > > http://www.mega-nerd.com/tmp/secret_rabbit_code.pdf > >This method works pretty well. I use it in the test suite for Secret >Rabbit COde: > > http://www.mega-nerd.com/SRC/ > >Erik >-- >+-----------------------------------------------------------+ > Erik de Castro Lopo >+-----------------------------------------------------------+ >"Python addresses true pseudocode's two major failings: that it >isn't standardized, and it isn't executable." >- Grant R. Griffin in comp.dsp >This message was sent using the Comp.DSP web interface on www.DSPRelated.com
Reply by ●September 26, 20052005-09-26
>>>>> "Govind" == Govind <govind_s@conceptemsys.com> writes:Govind> Hi All, Govind> I would appreciate if you could help me in following.. Govind> I have written a simple matlab code for converting sampling rate from 8KHz Govind> to 16KHz. Now I have to measure it's SNR. For this I converted both the Govind> signals to frequency domain (taking their FFTs) and then computed Govind> signal-to-noise ratio (sum of squared input spectral samples devided by Govind> sum of squared difference between the output spectral samples and the Govind> input spectral samples). With this method I am getting SNR not more than Govind> 50-60dB (even for very high filter lengths). Can you please tell me what's Govind> wrong with my method (I have seen posting mentioning that SNR should go as Govind> high as 140dB)? Or please suggest correct method. Single precision float round-off error? Ray
Reply by ●September 27, 20052005-09-27
Yes, I would imagine that the result will be different for different input frequencies. Your low pass filter probably has some "stop band ripple" such that certain frequencies are attenuated more than others. Usually, FIR low pass filters have nulls of essentially infinite attenuation (see for example the graphs here http://www.filter-solutions.com/FIR.html for an idea of what I'm talking about). If you happen to pick an input frequency that lands on a null, you will have much better results than otherwise. So then, how to specify SNR? Either pick several frequencies and give the results for each, average them, or pick the worst case value. If you plot your LPF's frequency response, you should be able to figure out the worst case. Due to these very issues, I recommended using the LPF's frequency response to evaluate the "quality" of your interpolation scheme (stop-band attenuation is the main parameter), rather than SNR computed as an error signal. The hardware sample rate conversion chips usually use stop-band attenuation and pass-band frequency as figures of merit. -- Jon Harris SPAM blocker in place: Remove 99 (but leave 7) to reply "Govind" <govind_s@conceptemsys.com> wrote in message news:W6mdnZmdof3RFareRVn-gA@giganews.com...> Thanks for the reply, > > I have tried with upto 1000 number of LPF filter taps. I really would like > to try out method you've suggested. But is it possible that the code will > give different SNR for different frequencies. If yes, then how do I > represent total SNR of the system. > > Govind > > >>in article urKdnY7SWfelqaneRVn-gw@giganews.com, Govind at >>govind_s@conceptemsys.com wrote on 09/23/2005 12:58: >> >>> I have written a simple matlab code for converting sampling rate from > 8KHz >>> to 16KHz. Now I have to measure it's SNR. For this I converted both > the >>> signals to frequency domain (taking their FFTs) and then computed >>> signal-to-noise ratio (sum of squared input spectral samples devided > by >>> sum of squared difference between the output spectral samples and the >>> input spectral samples). With this method I am getting SNR not more > than >>> 50-60dB (even for very high filter lengths). Can you please tell me > what's >>> wrong with my method >> >>not a particular good method to compute SNR. try upsampling a collection > of >>known sine waves from 8 to 16kHz. then generate the exact same sine > waves >>(from the same math) but at the 16 kHz rate. make sure you have your > timing >>lined up because your SRC will have some delay. then subtract to get a >>difference (or error or "noise) signal and use that in your SNR > computation. >> >>> (I have seen posting mentioning that SNR should go as high as 140dB)? >> >>how long is your impulse response of your LPF? to get 140, you will > need >>about a 64 tap FIR. >> >> >>-- >> >>r b-j rbj@audioimagination.com >> >>"Imagination is more important than knowledge." >> >> >> > > > > This message was sent using the Comp.DSP web interface on > www.DSPRelated.com
Reply by ●September 27, 20052005-09-27
This is a fundamental trade-off that you must decide for yourself. For the same filter length, the wider the transition band (and hence narrower the transition band), the less stop-band attenuation you will achieve. You need to decide which is more important. Of course, if you can make your filter arbitrarily long, you may be able to achieve both goals. The ideal in for example 8->44.1kHz you be a 4kHz bandwidth and infinite attenuation above 4kHz. Of course, this is not practically achievable. Also, who told you that the "speech bandwidth" is 20Hz to 3.4kHz? Sometimes the upper limit of telephone audio is specified at 3.4 kHz (or 3.3 or 3 or 3.5...), but if you have ever talked on the phone, you know that you lose a whole lot of high frequencies. It is easy (for me) to hear the difference in speech even when filtering out frequencies above 8 kHz. -- Jon Harris SPAM blocker in place: Remove 99 (but leave 7) to reply "Govind" <govind_s@conceptemsys.com> wrote in message news:Lp-dndrU7fmuEarenZ2dnUVZ_tOdnZ2d@giganews.com...> Thanks to all for your kind replies. > > I have one more query. How much should the transition bandwidth of LPF be > for say 8KHz<=>16KHz and 8KHz<=>44.1KHz? I was suggested to keep the > passband cut off at 3.5KHz, because of speech bandwidth (20Hz to 3.4KHz). > But I doubt it would give me good result, since I want to use the SRC for > Audio and not only for Speech. > > Govind > > >>Govind wrote: >>> >>> Hi All, >>> >>> I would appreciate if you could help me in following.. >>> >>> I have written a simple matlab code for converting sampling rate from > 8KHz >>> to 16KHz. Now I have to measure it's SNR. For this I converted both > the >>> signals to frequency domain (taking their FFTs) and then computed >>> signal-to-noise ratio (sum of squared input spectral samples devided > by >>> sum of squared difference between the output spectral samples and the >>> input spectral samples). With this method I am getting SNR not more > than >>> 50-60dB (even for very high filter lengths). Can you please tell me > what's >>> wrong with my method (I have seen posting mentioning that SNR should go > as >>> high as 140dB)? Or please suggest correct method. >> >>I outline a slightly different method in some slides here: >> >> http://www.mega-nerd.com/tmp/secret_rabbit_code.pdf >> >>This method works pretty well. I use it in the test suite for Secret >>Rabbit COde: >> >> http://www.mega-nerd.com/SRC/ >> >>Erik >>-- >>+-----------------------------------------------------------+ >> Erik de Castro Lopo >>+-----------------------------------------------------------+ >>"Python addresses true pseudocode's two major failings: that it >>isn't standardized, and it isn't executable." >>- Grant R. Griffin in comp.dsp >> > > > > This message was sent using the Comp.DSP web interface on > www.DSPRelated.com
Reply by ●September 29, 20052005-09-29
Hi r b-j, I am trying to compute SNR with the method you've suggested. This time I am trying upconversion of a signal from 8KHz to 44.1KHz. I have implemented a four stage SRC code in matlab (with ratios 3/2, 3/2, 7/5 and 7/4 with filter taps 414, 54, 84 and 70 respectively using remez algorithm). I multiply the output by a factor of 441 (3*3*7*7) in time domain to compensate for interpolation stage losses. The frequency response seems to be good. But still I am getting SNR not more than 30-40 DB. I am sure that I am not making a mistake in taking the delay into account. Ray had suggested to check 'Single precision float round-off error'. But I am using simple matlab floating point variables, which are by default double-precision. (Ray, please correct me if I am failing to understand your point.) Please help me out, I am very eager to see 100+DB SNR! Thank you Govind>in article urKdnY7SWfelqaneRVn-gw@giganews.com, Govind at >govind_s@conceptemsys.com wrote on 09/23/2005 12:58: > >> I have written a simple matlab code for converting sampling rate from8KHz>> to 16KHz. Now I have to measure it's SNR. For this I converted boththe>> signals to frequency domain (taking their FFTs) and then computed >> signal-to-noise ratio (sum of squared input spectral samples devidedby>> sum of squared difference between the output spectral samples and the >> input spectral samples). With this method I am getting SNR not morethan>> 50-60dB (even for very high filter lengths). Can you please tell mewhat's>> wrong with my method > >not a particular good method to compute SNR. try upsampling a collectionof>known sine waves from 8 to 16kHz. then generate the exact same sinewaves>(from the same math) but at the 16 kHz rate. make sure you have yourtiming>lined up because your SRC will have some delay. then subtract to get a >difference (or error or "noise) signal and use that in your SNRcomputation.> >> (I have seen posting mentioning that SNR should go as high as 140dB)? > >how long is your impulse response of your LPF? to get 140, you willneed>about a 64 tap FIR. > > >-- > >r b-j rbj@audioimagination.com > >"Imagination is more important than knowledge." > > >This message was sent using the Comp.DSP web interface on www.DSPRelated.com






