Any opinions on the easiest way to convert an audio track to a higher sample rate? Mostly likely x2 or x4. It occurred to me that it could be done with FFT, then 'resample' but it seems like there should be a simpler method. I do realize that there will be no gain in fidelity or harmonic content.
Convert to higher sample rate
Started by ●April 13, 2014
Reply by ●April 13, 20142014-04-13
On Sunday, April 13, 2014 6:52:34 PM UTC+12, B wrote:> Any opinions on the easiest way to convert an audio track to a higher > > sample rate? Mostly likely x2 or x4. It occurred to me that it could > > be done with FFT, then 'resample' but it seems like there should be a > > simpler method. I do realize that there will be no gain in fidelity > > or harmonic content.Up-sample. You insert 1 zero between samples and then filter - in all the books. When you have a fractional conversion it is slightly more complicated but quite straight forward.
Reply by ●April 13, 20142014-04-13
Hi,
FFT is IMHO the most straightforward way.
The Matlab / Octave function below will do the job (td is the signal, n the
desired number of samples)
function td = td2td_noncausalResampler(td, n)
nOld = numel(td);
realFlag = isreal(td);
if n == nOld
return;
end
fd = fft(td);
if n > nOld
n1 = ceil(nOld / 2);
n2 = nOld - n1;
fd = [fd(1:n1), zeros(1, n-nOld), fd(end-n2+1:end)];
else
n1 = ceil(n/2);
n2 = n - n1;
fd = fd([1:n1, end-n2+1:end]);
end
td = ifft(fd * n / nOld);
if realFlag
td = real(td);
end
end
_____________________________
Posted through www.DSPRelated.com
Reply by ●April 13, 20142014-04-13
On 4/13/14 8:30 AM, mnentwig wrote:> Hi, > > FFT is IMHO the most straightforward way.oh, c'mon. upsample a 5 minute song from 48 kHz to 96 kHz in a straightforward manner with the FFT. that might be interesting. -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."
Reply by ●April 13, 20142014-04-13
On 13.04.14 08.52, B wrote:> Any opinions on the easiest way to convert an audio track to a higher > sample rate? Mostly likely x2 or x4. It occurred to me that it could > be done with FFT, then 'resample' but it seems like there should be a > simpler method. I do realize that there will be no gain in fidelity > or harmonic content.Place zeros in between and apply a low pass filter with high stopband attenuation at the higher sampling rate but with a cutoff frequency slightly above the Nyquist frequency of your original sampling rate. Depending on your phase response requirements a simple IIR filter should do the job. If you need linear phase in the pass band you should consider a FIR filter with a good window function like Blackman-Harris. You still don't need a very large filter Kernel because the highest frequency to pass is your original Nyquist frequency and the lowest one to cut is at least twice as much. Marcel
Reply by ●April 13, 20142014-04-13
On 2014-04-13 23:16, Robert Scott wrote:> On Sun, 13 Apr 2014 15:46:12 +0200, =?ISO-8859-1?Q?Marcel_M=FCller?= > <news.5.maazl@spamgourmet.org> wrote: > >> Place zeros in between and apply a low pass filter with high stopband >> attenuation at the higher sampling rate but with a cutoff frequency >> slightly above the Nyquist frequency of your original sampling rate. >> > > Wouldn't it be better to duplicate each sample and then low pass > filter? Inserting zeroes between each sample will introduce a large > component at the lower sample rate, which places more demands on the > low pass filter. Duplicating each sample will not introduce nearly as > much higher frequency content that needs to be filtered. Or better > yet, in between each sample insert the average of the neighboring > samples. You still need to low pass filter, but the filter has much > less work to do, and therefore can be a less critical filter.In both cases you've less high frequency content, but you shape the spectrum in a way requiring a more careful design of the low-pass filter. For example, a value repetition results in a spectrum modulated by a sync (sample-and-hold filter), so the low-pass filter should account the 13dB (I think) loss (in band) and, hence, have a corresponding *peaking*. bye, -- piergiorgio
Reply by ●April 13, 20142014-04-13
On Sun, 13 Apr 2014 21:16:55 +0000, Robert Scott wrote:> On Sun, 13 Apr 2014 15:46:12 +0200, =?ISO-8859-1?Q?Marcel_M=FCller?= > <news.5.maazl@spamgourmet.org> wrote: > >>Place zeros in between and apply a low pass filter with high stopband >>attenuation at the higher sampling rate but with a cutoff frequency >>slightly above the Nyquist frequency of your original sampling rate. >> >> > Wouldn't it be better to duplicate each sample and then low pass filter? > Inserting zeroes between each sample will introduce a large component > at the lower sample rate, which places more demands on the low pass > filter. Duplicating each sample will not introduce nearly as much > higher frequency content that needs to be filtered. Or better yet, in > between each sample insert the average of the neighboring samples. You > still need to low pass filter, but the filter has much less work to do, > and therefore can be a less critical filter.If you view the operations in the frequency domain, the zero-insertion method replicates the original spectrum exactly, as many times as there are zeros inserted (so if you go up 4x you have 4x the bandwidth, and four identical spectra, with three of them shifted). The sample- replication, on the other hand, introduces significant frequency shaping, with a honkin' big null at Nyquist and its harmonics. In the end analysis, the "replicate samples" method is essentially the same thing as the "insert zeros" method followed by a boxcar filter. That, in turn, means that the "replicate samples" method is really just the "insert zeros" method with the boxcar filter imposed on the designer. So you can always get the effect of the "replicate samples" method in the "insert zeros" method, but you can't always get the reverse. -- Tim Wescott Control system and signal processing consulting www.wescottdesign.com
Reply by ●April 13, 20142014-04-13
On 4/13/14 4:35 PM, Tim Wescott wrote:> On Sun, 13 Apr 2014 21:16:55 +0000, Robert Scott wrote: > >> On Sun, 13 Apr 2014 15:46:12 +0200, =?ISO-8859-1?Q?Marcel_M=FCller?= >> <news.5.maazl@spamgourmet.org> wrote: >> >>> Place zeros in between and apply a low pass filter with high stopband >>> attenuation at the higher sampling rate but with a cutoff frequency >>> slightly above the Nyquist frequency of your original sampling rate. >>> >>> >> Wouldn't it be better to duplicate each sample and then low pass filter? >> Inserting zeroes between each sample will introduce a large component >> at the lower sample rate, which places more demands on the low pass >> filter. Duplicating each sample will not introduce nearly as much >> higher frequency content that needs to be filtered. Or better yet, in >> between each sample insert the average of the neighboring samples. You >> still need to low pass filter, but the filter has much less work to do, >> and therefore can be a less critical filter. > > If you view the operations in the frequency domain, the zero-insertion > method replicates the original spectrum exactly, as many times as there > are zeros inserted (so if you go up 4x you have 4x the bandwidth, and > four identical spectra, with three of them shifted). The sample- > replication, on the other hand, introduces significant frequency shaping, > with a honkin' big null at Nyquist and its harmonics.which is nice. *very* useful for audio, because nearly all of the energy in audio is in the bottom 5 or 6 octaves. hint: this fact can be put to use for designing the LPF even if you *don't* stuff with replicated samples (and zero-stuff it).> In the end analysis, the "replicate samples" method is essentially the > same thing as the "insert zeros" method followed by a boxcar filter. > That, in turn, means that the "replicate samples" method is really just > the "insert zeros" method with the boxcar filter imposed on the designer."imposed"? you might want to put it that the boxcar filter (with those nice honkin' bit nulls at n*Fs for |n|>0) is *aiding* the designer. it's all in the semantics. hint: this fact can be put to use for designing the LPF even if you *don't* stuff with replicated samples (and zero-stuff it).> So you can always get the effect of the "replicate samples" method in the > "insert zeros" method, but you can't always get the reverse.i don't get the big difference. the only difference between the two are whether or not there is a zero-order hold (which is an LTI filter) in there or not. it might affect how the other LPF is designed. the only reason i would bother to do either is if the LPF i am using to eliminate the images (which would be much better eliminated if the ZOH *was* in there) with an IIR filter. otherwise, i would just polyphase the damn thing. -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."
Reply by ●April 13, 20142014-04-13
On Sun, 13 Apr 2014 15:46:12 +0200, =?ISO-8859-1?Q?Marcel_M=FCller?= <news.5.maazl@spamgourmet.org> wrote:>Place zeros in between and apply a low pass filter with high stopband >attenuation at the higher sampling rate but with a cutoff frequency >slightly above the Nyquist frequency of your original sampling rate. >Wouldn't it be better to duplicate each sample and then low pass filter? Inserting zeroes between each sample will introduce a large component at the lower sample rate, which places more demands on the low pass filter. Duplicating each sample will not introduce nearly as much higher frequency content that needs to be filtered. Or better yet, in between each sample insert the average of the neighboring samples. You still need to low pass filter, but the filter has much less work to do, and therefore can be a less critical filter. Robert Scott Hopkins, MN
Reply by ●April 13, 20142014-04-13
Robert Scott <no-one@notreal.invalid> wrote:> On Sun, 13 Apr 2014 15:46:12 +0200, =?ISO-8859-1?Q?Marcel_M=FCller?= > <news.5.maazl@spamgourmet.org> wrote:>>Place zeros in between and apply a low pass filter with high stopband >>attenuation at the higher sampling rate but with a cutoff frequency >>slightly above the Nyquist frequency of your original sampling rate.> Wouldn't it be better to duplicate each sample and then low pass > filter? Inserting zeroes between each sample will introduce a large > component at the lower sample rate, which places more demands on the > low pass filter.Not having actually tried to design one, all the descriptions I see use zeros. I believe that the zeros are not actually generated (that is, not stored anywhere) but the filter just knows that they are there. If you do it in separate steps, then it might be different, but if you can do it in one operation, it might be different. -- glen






