Digital filtering(upsampling) of complex sine signals (music)

Status
This old topic is closed. If you want to reopen this topic, contact a moderator using the "Report Post" button.
Do you think zero stuffing followed by low pass filtering (and that too 2 or 3 times in a row), no matter how good and precise the filter is, is capable of faithfully following the original shape of a complex sine signal, like music, that is rich in harmonic content ?

For one lonesome sine wave/tone yes I agree that it works great and the charts on the datasheets look great too, but what about music ?
Knowing what little I know about digital filtering I am just not able to accept the fact that this two-step process called upsampling(again, done 2-3 times over) can really be applied to music signals. Maybe its just in my mind. Maybe its just a difficult concept to understand (atleast to my mind) and its just a misconception that I have, but in any case, can anyone please help clear it up for me (preferably with charts and data to back it up) as to whether upsampling works for music signals or not.

Thoughts anyone ?
 
Of course it works. It is immaterial if the signal is music or speech or noise or anything else, as long as it is properly bandlimited to less than half the sampling frequency. Any college course on signal theory teaches this and there are countless textbooks. I can understand however, that these concepts may be somewhat difficult to understand for those who have never been exposed to the basics.

Although the theory is flawless, the practical implementation is not trivial. A CD-player implementation will only approximate what needs to be done to recover the audio signal from the CD. How close this approaches the ideal, depends on cost and available technology. The technology is still progressing and only now are we starting to really exploit the full quality of a good mastered CD.

Oversampling and upsampling are signal processing steps that convert the signal to higher sampling rates for easier filtering. Properly done (e.g. with high enough arithmetic precision) they are not affecting the original content of the signal, again be it sine waves, music or whatsoever. However, they make the process of postfiltering much easier.

If you go through this forum, you may find several threads that deal with these issues.
 
here's a typicaly frequency spectrum of a couple of piano keys -
I am sure other musical instruments have the same kind of freq spectra.

now lets say a stream of 44.1Khz digital data of this spectrum is sent thru a digital filter to upsample it to 352.8Khz(8x), then are you saying the spectrum of the resulting digital data stream would be exactly same ? and I dont mean by extreme DSP using a filter that costs $10000 with 10000 taps, but just those chips accessible to the common man that do 8x using 169+24+17 taps.


An externally hosted image should be here but it was not working when we last tested it.



An externally hosted image should be here but it was not working when we last tested it.
 
Javin5 hit the nail on the head.

Yes, it is possible to achieve the performance you cite with the technology specified. I am doing similar things on a $400 dev kit. I test my filters by passing MLS, a pseudorandom noise that has every frequency in it and it passes quite faithfully.

Now, whether manufacturer 'X's implementation achieves the performance is a different question all together.
 
Upsampling is just a interpolation. According to sampling theorem an ideal interpolation result is obtained by replacing each sample by a SINC function. This is just what convolution with long sinc shaped FIR does.

If in some implementation 8x upsampling is done using 169+24+17 taps, they probable have been using special halfband FIR filters, which have all even coefficients zero value. Drawback of this is a very small passband ripple.
 
ok I seem to be coming to terms with the 'complex/multiple' sines but here's really where my mental-block is about this - (hear me out, please).

To better ask my question let's take two examples of 10 seconds worth of audio data -
One is repetitive signal (say a multiple tone sine) ,
and the other is something non-repetitive - like real music.

If I understand correctly how digital a LPF works, then the newly calculated value of the sample at the output of the filter depends on some 'M' number of samples ahead of that sample. So if M=100 then the new value of sample#1 depends on the values of sample#1 thru sample#100.

Now in the repetitive signal, no matter how many samples you take(50 or 500) the batch of samples will always have the same frequency content.
Think of this as an FFT on those samples. you will always get the same fft spectrum whether you run the fft against 50 or 500 samples.

In the music signal however, I would imagine that the frequency content between say sample# 1 to 500 could be very different from the freq content of the same samples but now broken up into two batches of 1 to 250 and then 250 to 500. I mean the music content between sample# 1 to 250 could be very different from sample# 250 to 500.
Thinking in terms of FFT again, you could get a very different spectrum from samples 1 to 250 v/s samples 250 to 500.
So wouldn't using 500 samples to derive the value of the one sample give a wrong result, or atleast a result that deviates from the most accurate result ?

I realize that the rolloff of the filter depends directly on M, so too few a samples and you compromise the rolloff, too many samples and you might influence the value of the output sample by a sample that is too far away!

If thats true then how would you determine what is the optimum number of samples to send as input to the filter ? There doesn't seem to be any clear direction on that.
That's where I am stuck. Maybe I am not thinking this through correctly, if so I just need help to clear this up in my mind.
 
what is the optimum number of samples to send as input to the filter ?

...the least number necessary to meet the filter requirements. Generally, the more complex the filter, the higher order (more samples) it needs to be. A simple 6dB/octave low pass can be achieved with as little as two samples (a simple biquad) As you specify steeper slopes, more complex response you need more samples to work with.

Another factor is time-frequency duality. A small number of samples (a small time window) doesn't contain any information about low frequencies so it's hard to manipulate low frequencies with a short filter. 1Hz at 44100S/s isn't really defined until you have 44100 samples (1 cycle). This re-appears in FFTs where you need a long record length to resolve the frequencies into small bins - a 44100 sample FFT would resolve to 1Hz bins.

So wouldn't using 500 samples to derive the value of the one sample give a wrong result, or atleast a result that deviates from the most accurate result ?

Don't forget the filter coefficients. These "weights" are used to combine the different samples in a unique combination to produce the output response and typically the samples in the middle of the window have bigger weights. You can make the same filter response with 10 taps (samples) or 100 taps. The accuracy of the output sample would be the same in each case but the coefficients would be different.
 
percy said:
In the music signal however, I would imagine that the frequency content between say sample# 1 to 500 could be very different from the freq content of the same samples but now broken up into two batches of 1 to 250 and then 250 to 500. I mean the music content between sample# 1 to 250 could be very different from sample# 250 to 500.

According to Parsevals theorems, the frequency content from 1 to 500, is sum of those two patches.

Lets take example with 10 tap halfbandfilter. Halfband filter has a property that every other coeff is zero except the middle one. These are very commonly used in upsamling.

1st filter output
halfband filter: 0.04 0.00 -0.16 0.00 0.62 1.00 0.62 0.00 -0.16 0.00 0.04
input sequence: 0 x1 0 x2 0 x3 0 x4 0 x5 0
output (dot product): x3

2nd filter output
halfband filter: 0.04 0.00 -0.16 0.00 0.62 1.00 0.62 0.00 -0.16 0.00 0.04
input sequence: x1 0 x2 0 x3 0 x4 0 x5 0 x6
output: 0.04*x1 -0.16*x2 +0.62*x3 +0.62*x4 -0.16*x5 +0.04*x6

First we see that original samples are not being touched.
When calculating the "interpolated" sample, I find it quite logical that also equal amount of "future" taps are accumulated. The reason for accumulating almost infinite number of samples, becomes from time-frequency duality.
There are no samples that are too far in past or future. The filter
weights are getting smaller, further the sample is. With 169 nonzero taps you easily reach -100dB stopband rejection.
 
so if the length of the filter kernel is say 116 points then the new value of the current sample being processed would be recalculated by applying the filter coeficients to 58 sammples on either side of that sample, right ? And the diminishing filter coeficients determined by the sinc function on either side of the center would act as "weights", correct ?

For now I am referring to the online version of the book - The Scientist and Engineer's Guide to DSP by Steven Smith.
More specifically Ch.16 which deals with Windowed-Sinc Filters - http://www.dspguide.com/CH16.PDF
I guess it would help to look at simple yet real/practical algorithms for such a filter.
Can anyone point me into that direction ?
 
well, no. The 58 samples ahead of the current sample are in the future and don't exist yet.;)
at least for real time systems.
The output sample is usually calculated by summing the coefficient products of the most recent 116 samples - this is why all digital filters have delay.

A simple filter would be one that averages all the samples. It's fairly intuitive that this would tend to reduce the amplitude of high frequencies. As the filter length increases the low pass roll off frequency lowers.

If you're going to get into this you should start using MATLAB or equivalent. And keep reading!
 
Well, the online book by Smith that you cite is as good as any I've read. There are the pivotal works by Oppenheim & Shafer, Hamming and others. Rorabaugh has some good general overview books.

Anything published in the AES is worth reading.

But really, nothing tells you how to do what you specifically want to do. For that you have to start doing it. MATLAB is good because it provides an excellent debug safety net. The Mathworks website and MATLAB central forum and code library is just a wealth of information.

http://www.mathworks.com/matlabcentral/

Start playing with the math and post your peculiar discoveries here. There's a lot of geeky math types here that love this stuff (a heady goal I myself aspire to!)

<edit> oh, and the help menu in MATLAB is an education in itself. I learned a much from just reading the MATLAB tutorials & function descriptors.
 
Status
This old topic is closed. If you want to reopen this topic, contact a moderator using the "Report Post" button.