Hello, I'm trying to add 2 different digital waveforms together, but the 2 are sampled at different rates.. Logically, first I must resample them to another common sampling rate, but.. how should I go about it? Can I reconstruct the analog waveform and then resample at the desired sampling rate? If my priority is to preserve the frequency content, can I just simply use some sort of curve fitting to reconstruct the waveform? What sort curve fitting is best to use? What other methods can I do this? What are the considerations that I must look out for? Thanks in advance! Regards, Tanh

# NewBie Query: Resampling a digital waveform

Started by ●January 13, 2004

Reply by ●January 13, 20042004-01-13

tanh wrote:> Hello, > > I'm trying to add 2 different digital waveforms together, but the 2 > are sampled at different rates.. > > Logically, first I must resample them to another common sampling rate, > but.. how should I go about it? Can I reconstruct the analog waveform > and then resample at the desired sampling rate? > > If my priority is to preserve the frequency content, can I just simply > use some sort of curve fitting to reconstruct the waveform? What sort > curve fitting is best to use? > > What other methods can I do this? What are the considerations that I > must look out for? > > Thanks in advance! > > Regards, > TanhThere's a good resampling tutorial (and source code) here: http://www.dspguru.com/info/faqs/mrfaq.htm -- Jim Thomas Principal Applications Engineer Bittware, Inc jthomas@bittware.com http://www.bittware.com (703) 779-7770 Time flies like an arrow. And fruit flies like bananas.

Reply by ●January 13, 20042004-01-13

"Jim Thomas" <jthomas@bittware.com> wrote in message news:10082i4s5s6fv37@corp.supernews.com...> tanh wrote: > > Hello, > > > > I'm trying to add 2 different digital waveforms together, but the 2 > > are sampled at different rates.. > > > > Logically, first I must resample them to another common sampling rate, > > but.. how should I go about it? Can I reconstruct the analog waveform > > and then resample at the desired sampling rate? > > > > If my priority is to preserve the frequency content, can I just simply > > use some sort of curve fitting to reconstruct the waveform? What sort > > curve fitting is best to use? > > > > What other methods can I do this? What are the considerations that I > > must look out for? > > > > Thanks in advance! > > > > Regards, > > Tanh > > There's a good resampling tutorial (and source code) here: > http://www.dspguru.com/info/faqs/mrfaq.htmThe above is a good reference if the sample rates have a rational relationship. So, it is possible to adjust the sample rates, or one of them, to end up with the same rate on both. If this isn't the case, then you'd need to interpolate - which is the simple way of "going back to continuous" without going all the way. Interestingly, sample rate modification upward and interpolation are the same operation if the interpolation ratio is a rational fraction. If it isn't then some other method of interpolation will be necessary on one of the signals. I've often wondered how various numerical curve fitting interpolation methods affect the frequency content - haven't researched it. There must be some papers on the subject however. There are papers that develop spectral signal to noise ratio for various interpolation methods - so that approach gets to the question. Whether a wide enough variety of methods has been studied in this manner I don't know. If you had lots of time and memory you might just interpolate up to some very high rates that are close and then do some very simple interpolation on one signal. Then the maximum interpolation distance would be 1/2 a sample interval. Eventually as the sample rate gets very high, linear interpolation could be acceptable and 2nd order would probably be quite good. As to the functions used for interpolation, I wonder what happens if you use 2 sincs centered and weighted by the adjacent samples? I'd expect that to be pretty good at the edges and worst at the midpoint. At the midpoint it might take 4 or 6 or 8 or ..... I don't know how many but you could calculate it. For that matter if you used sin^3(x)/x^3 at each sample then the number of terms would be smaller because of the more rapid decay of the terms. Maybe someone else knows more about this.... Fred

Reply by ●January 18, 20042004-01-18

Fred Marshall wrote:> > "Jim Thomas" <jthomas@bittware.com> wrote in message > > > There's a good resampling tutorial (and source code) here: > > http://www.dspguru.com/info/faqs/mrfaq.htm > > The above is a good reference if the sample rates have a rational > relationship. So, it is possible to adjust the sample rates, or one ofSecret Rabbit Code is a library for sample rate conversion of audio signals. It is capable of conversion between arbitrary ratios and even time varying ratios. It is released under the terms of the GNU General Public License and is available here: http://www.mega-nerd.com/SRC/ Erik -- +-----------------------------------------------------------+ Erik de Castro Lopo nospam@mega-nerd.com (Yes it's valid) +-----------------------------------------------------------+ "In civilian equipment, such as computers, the number of components alone makes miniaturization essential if the computer is to be housed in a reasonable-sized building." Electronics Oct. 1, 1957, p. 178