Forums

44.1 khz to 48 khz using polyphase

Started by nomi September 24, 2005
Hi,
    I am trying to do a 44.1 khz to 48 khz resampling in Matlab, but am
coming across a few problems. For this conversion to take place the
poly phase filters come out like
480/441=(4 x 4 x 10)/(7 x 7 x 3). I have been trying to figure this
thing out on paper, like the for the first stage I get
44100 x (4/7), now as I understand it I have to take a 44.1 khz signal
upsample it by 4, apply an FIR filter with cutoff pi/7 to it, and then
downsample it to get 25.2 khz which is the output of the first stage.
But when I plot this thing on paper I get serious aliasing and
overlaps, the same is true for other stages also. I have experimented
doing different ratios, e.g, a two stage implementation i.e. 480/441=
(20/7) x (8/21). Can anyone please offer some help? And moreover, after
the signal is upsampled at the newer rate, and finally on being
downsampled it overlaps the original signal which is centered around
zero? Ant help? Thanks in advance, :-)
Nauman

First, if you want to using integer conversion ratios, as you suggest, 
you must protect the original bandwidth by never dropping below 44.1kHz 
at any stage. That means you cannot go up 4x and down 7x as your "first 
stage".

You might want to avoid a lot of the agony and use a fractional 
conversion algorithm--see JOS's nice resampling page:

http://ccrma-www.stanford.edu/~jos/resample/

In a nutshell, the basic problem with fractional sampling ratios, in 
general, when using windowed-sinc interpolation is that you can't pre-
compute a sinc table of reasonable size that will cover all 
possibilities. JOS solves that problem by using a table of sufficient 
size, and interpolating between table entries to get arbitary points on 
the sinc curve. Linear interpolation works well because the curve is 
smooth, and costs little.


In <1127542995.156498.159810@g44g2000cwa.googlegroups.com> nomi wrote:
> Hi, > I am trying to do a 44.1 khz to 48 khz resampling in Matlab, but > am coming across a few problems. For this conversion to take place the > poly phase filters come out like > 480/441=(4 x 4 x 10)/(7 x 7 x 3). I have been trying to figure this > thing out on paper, like the for the first stage I get > 44100 x (4/7), now as I understand it I have to take a 44.1 khz signal > upsample it by 4, apply an FIR filter with cutoff pi/7 to it, and then > downsample it to get 25.2 khz which is the output of the first stage. > But when I plot this thing on paper I get serious aliasing and > overlaps, the same is true for other stages also. I have experimented > doing different ratios, e.g, a two stage implementation i.e. 480/441= > (20/7) x (8/21). Can anyone please offer some help? And moreover, > after the signal is upsampled at the newer rate, and finally on being > downsampled it overlaps the original signal which is centered around > zero? Ant help? Thanks in advance, :-) > Nauman
Nigel Redmon wrote:
> In a nutshell, the basic problem with fractional sampling ratios, in > general, when using windowed-sinc interpolation is that you can't pre- > compute a sinc table of reasonable size that will cover all > possibilities. JOS solves that problem by using a table of sufficient > size, and interpolating between table entries to get arbitary points on > the sinc curve. Linear interpolation works well because the curve is > smooth, and costs little.
You can also resample directly without precomputing a table if you don't need this optimization for performance reasons. Just calculate the interpolation coefficients for each phase as needed (easier for some types of windows than others of course). Makes the interpolation code much more straightforward when the basic reconstruction algorithm is separated from the optimization scheme. IMHO. YMMV. -- rhn A.T nicholson d.O.t C-o-M
in article 20050924104019665-0700@news.linkline.com, Nigel Redmon at
earlevel@earlevel.com wrote on 09/24/2005 13:40:

> You might want to avoid a lot of the agony and use a fractional > conversion algorithm--see JOS's nice resampling page: > > http://ccrma-www.stanford.edu/~jos/resample/ > > In a nutshell, the basic problem with fractional sampling ratios, in > general, when using windowed-sinc interpolation is that you can't pre- > compute a sinc table of reasonable size that will cover all > possibilities. JOS solves that problem by using a table of sufficient > size, and interpolating between table entries to get arbitary points on > the sinc curve. Linear interpolation works well because the curve is > smooth, and costs little.
i think you can get away with a 32-tap FIR and 512 discrete fractional delays (16K word or 8K if symmetry is made use of) and get 120 dB S/N using linear interpolation. you'll need 512K x 32 to use drop-sample (or "no") interpolation with the same S/N. but if it's synchronous, i might think 160 discrete fractional delays would be okay. -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."
in article 1127585514.767102.284570@z14g2000cwz.googlegroups.com,
rhnlogic@yahoo.com at rhnlogic@yahoo.com wrote on 09/24/2005 14:11:

> You can also resample directly without precomputing a table if you > don't need this optimization for performance reasons. Just calculate > the interpolation coefficients for each phase as needed
doable for windowed-sinc and for polynomial interpoation (Lagrange, Hermite, B-spline, etc.) but i don't see how if your want to optimize SNR or image rejection performance (in which your coefficients will come out of a Parks-McClellan or firls() like algorithm). then you'll need a table. -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."
A polyphase implementation is different from a multi-stage implementation, which 
is what you are trying to do.  There isn't a big advantage to a multi-stage 
implementation for this type of conversion ratio (in fact, the code is 
significantly more complex) unless memory is extremely limited and you don't 
have sufficient processing power to calculate coefficients on the fly.  Since 
you are working in Matlab, I wouldn't think either of those limitations would 
apply.  So I would suggest a single-stage polyphase approach.

-- 
Jon Harris
SPAM blocker in place:
Remove 99 (but leave 7) to reply

"nomi" <nmafzal@gmail.com> wrote in message 
news:1127542995.156498.159810@g44g2000cwa.googlegroups.com...
> Hi, > I am trying to do a 44.1 khz to 48 khz resampling in Matlab, but am > coming across a few problems. For this conversion to take place the > poly phase filters come out like > 480/441=(4 x 4 x 10)/(7 x 7 x 3). I have been trying to figure this > thing out on paper, like the for the first stage I get > 44100 x (4/7), now as I understand it I have to take a 44.1 khz signal > upsample it by 4, apply an FIR filter with cutoff pi/7 to it, and then > downsample it to get 25.2 khz which is the output of the first stage. > But when I plot this thing on paper I get serious aliasing and > overlaps, the same is true for other stages also. I have experimented > doing different ratios, e.g, a two stage implementation i.e. 480/441= > (20/7) x (8/21). Can anyone please offer some help? And moreover, after > the signal is upsampled at the newer rate, and finally on being > downsampled it overlaps the original signal which is centered around > zero? Ant help? Thanks in advance, :-) > Nauman >
"robert bristow-johnson" <rbj@audioimagination.com> wrote in message 
news:BF5B141A.AA28%rbj@audioimagination.com...
> in article 20050924104019665-0700@news.linkline.com, Nigel Redmon at > earlevel@earlevel.com wrote on 09/24/2005 13:40: > >> You might want to avoid a lot of the agony and use a fractional >> conversion algorithm--see JOS's nice resampling page: >> >> http://ccrma-www.stanford.edu/~jos/resample/ >> >> In a nutshell, the basic problem with fractional sampling ratios, in >> general, when using windowed-sinc interpolation is that you can't pre- >> compute a sinc table of reasonable size that will cover all >> possibilities. JOS solves that problem by using a table of sufficient >> size, and interpolating between table entries to get arbitary points on >> the sinc curve. Linear interpolation works well because the curve is >> smooth, and costs little. > > i think you can get away with a 32-tap FIR and 512 discrete fractional > delays (16K word or 8K if symmetry is made use of) and get 120 dB S/N using > linear interpolation. you'll need 512K x 32 to use drop-sample (or "no") > interpolation with the same S/N. > > but if it's synchronous, i might think 160 discrete fractional delays would > be okay.
Given the fact that he was doing a mutli-stage implementation in Matlab with simple integer ratios, I think it's a pretty good assumption that it is synchronous, i.e. _exactly_ 160/147. So then 160 discrete fractional delays would be optimal.
nomi wrote:
> Hi, > I am trying to do a 44.1 khz to 48 khz resampling in Matlab, but am > coming across a few problems.
As far as I can recall, the DAT sampling frequency of 48 kHz was intentionally chosen so that it should be very cumbersome to re-sample between DAT and CD formats. It seems to have worked. Rune
"Rune Allnor" <allnor@tele.ntnu.no> wrote in message 
news:1127804628.858056.117830@g43g2000cwa.googlegroups.com...
> > nomi wrote: >> Hi, >> I am trying to do a 44.1 khz to 48 khz resampling in Matlab, but am >> coming across a few problems. > > As far as I can recall, the DAT sampling frequency of 48 kHz was > intentionally chosen so that it should be very cumbersome to > re-sample between DAT and CD formats.
I've heard that before too, but don't believe it. I've also heard an explanation about the SR being related to some existing video device's data rate. My assumption was that they evolved somewhat independently, each choosing the rate best for their application (achieving a specific recording time for a fixed capacity and utilizing existing video equipment). I don't know for sure either.
in article gJd_e.15520$SG3.6986@trnddc07, Jon Harris at
jon99_harris7@hotmail.com wrote on 09/27/2005 11:39:

> "Rune Allnor" <allnor@tele.ntnu.no> wrote in message > news:1127804628.858056.117830@g43g2000cwa.googlegroups.com... >> >> nomi wrote: >>> I am trying to do a 44.1 khz to 48 khz resampling in Matlab, but am >>> coming across a few problems. >> >> As far as I can recall, the DAT sampling frequency of 48 kHz was >> intentionally chosen so that it should be very cumbersome to >> re-sample between DAT and CD formats. > > I've heard that before too, but don't believe it.
audio engineers wanted the CDs to be 48 kHz at the beginning. they got their wish with the DATs.
> I've also heard an explanation about the SR being related to some existing > video device's data rate.
there was a device around 1980 that recorded stereo audio onto beta videotape called the Sony F1. it had 14 stereo samples (and i presume a pair of checksums or similar to make it a nice 15) in 5 NTSC horizontal lines. that's an average of 2.8 samples per line. 2.8 * 15750 = 44100. and if it's the color TV horizontal scan, 2.8 * (4.5 Mhz)/227.5 = 44056 Hz. that's where those two horrible sample rates come from. i've been told by the guy who literally designed the audio CD and its specs (Kees Schouhamer Immink) that there was no influence by the president of Sony, but the persistent urban legend is that he wanted to make sure the entire Beethoven's 9th symphony would fit onto a CD in which it would not quite if the sample rate was 48 but it did barely at 44.1 kHz. see http://www.snopes2.com/music/media/cdlength.htm and http://groups.google.com/group/rec.audio.pro/browse_frm/thread/ c4527c341b399344/3c7cc7c32ef7b403#3c7cc7c32ef7b403 (unwrap this URL) .
> My assumption was that they evolved somewhat independently, each choosing > the rate best for their application (achieving a specific recording time for a > fixed capacity and utilizing existing video equipment). I don't know for sure > either.
it's all politics. -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."