Kyma Forum
  Tips & Techniques
  Fractional Delays

Post New Topic  Post A Reply
profile | register | preferences | faq | search

next newest topic | next oldest topic
Author Topic:   Fractional Delays
David McClain
Member
posted 23 February 2002 04:18         Edit/Delete Message   Reply w/Quote
I just finished some experiments here in the creation of fractional delays. I found some very interesting things about this, which apparently SSC has also found.

First of all the VariableDelay sounds do not ever produce factional sample delays, even with interpolation enabled. Apparently, interpolation is meant to smoothly change over gross delay values by single sample steps.

What I found in my experiments was that using linear interpolation inside of a delay element for producing sub-sample fractional delays is not a very good idea after all. The delay blocks have only the present and previous input samples with which to compute the fractional sample value. This is very coarse information compared to the Wavetable resolution used by oscillators and the results are prone to a form of amplitude modulation, depending on the value of the fraction of a delay being sought.

When half-sample delays are sought, the best approach seems to be the use of an FIR filter with an even number of taps, whose values are the Sin(x)/x function windowed by something like a Kaiser window. This produces approximate Sinc interpolation which is the best one can hope for with band-limited signals.

Every time I turn around, I find that SSC has anticipated my results. They have some very sharp people working on the Kyma system!

- DM

IP: Logged

dennis
Member
posted 05 March 2002 07:39         Edit/Delete Message   Reply w/Quote
Very interesting, David. You might enjoy this:
ftp://download.intel.com/design/perftool/cbts/appnotes/ap822/upsample.pdf
as a different approach. I haven't heard the result and unfortunately, the paper is kind of sketchy on hard data. (I'd like to see a spectral display of the result, at least.)

And yes! Those Kyma developers are some of the sharpest folks around! An amazing product!

IP: Logged

David McClain
Member
posted 05 March 2002 20:13         Edit/Delete Message   Reply w/Quote
Hi, thanks... I'll check it out.

But along the topic of fractional sample period delays, a bit more digging on my part showed that single-pole all-pass filters fit the bill quite nicely here. These have nearly constant delay at the lowest frequencies and can be implemented, simply by moving the location of the pole, to produce arbitrary fractional sample period delays.

These filters are frequently used, as it turns out, to allow waveguide synthesis algorithms to achieve arbitrary tunings. Such algorithms are the Karplus-Strung algorithm for plucked strings, implemented with feedback through long delay lines. Without an all-pass filter in the feedback loop these algorithms would be restricted to discrete tunings at the high frequency end, making their successive pitches too widely spaced. Placing a simple 1-pole allpass filter inline with the delay allows the tunings to be arbitrarily finely spaced.

A simple 1-pole APF has the transfer function

H(z) = (alpha + 1/z)/(1 + alpha/z)

where alpha is a real number 0 < alpha < 1, and its value is the location of the pole along the negative real axis of the Z-domain.

In terms of difference equations, this becomes simply

y[n+1] = alpha * x[n+1] + x[n] - alpha * y[n]

making it very easy to implement in Kyma.

I tried these out and they work remarkably well at the lowest frequencies. Above about half-Nyquist they start to depart from their design delays and become less useful. But for us that is above 12 Khz, so who cares?

To select a value of alpha for a specified fractional delay, use the formula

alpha = sin( pi * (1 - delay)/Fsamp)/sin(pi * (1+delay)/Fsamp)

where Fsamp is your system sample rate (e.g., 44100 Hz, or 48000 Hz, etc.) and delay is a value between 0 and 1 expressing the desired fractional sample delay.

- DM

[BTW, at sample rates like 48 KHz its value is so large compared to delay that you could as well use the approximation

alpha = 1 - 2*delay/(1+delay)
]

[This message has been edited by David McClain (edited 05 March 2002).]

IP: Logged

David McClain
Member
posted 06 March 2002 00:16         Edit/Delete Message   Reply w/Quote
Ahh yes, Dennis,

Upsampling by interpolation. I am quite familiar with this technique and I studied its artifacts several weeks ago for my professional work.

The act of simple linear interpolation can be viewed as a convolution of the input data with a triangular window spanning 2 samples width. The spectral result of such a convolution is to multiply the signal specrum by a Sinc^2 function (Sinc(x) = Sin(pi*x)/(pi*x)), instead of the desired rectangular function enclosing only the baseband spectrum. This Sinc^2 function has ripples at all frequencies beyond baseband and hence introduces alias artifacts from the adjacent island spectra on either side of your baseband spectrum. (the act of sampling is to produce an infinite series of replications of your signal spectrum).

Using a higher order polynomial like this paper suggests, as with cubic spline fitting, which I was doing, increases the attenuation of these aliasing sidebands making the signal result closer to what you would get with a rectangular spectral window. But there will still be aliasing effects.

However, when investigating the desirable size of wavetables versus number of bits of sample resolution, I found that in the case of Kyma with their 24 bits of resolution and 4096 element wavetables, the aliasing artifacts introduced by their use of linear interpolation is down around -100 dBFS or so. So it is hardly noticeable, and for all practical purposes there is no need to use higher order interpolation. (Again, I'll bet the SSC folks already knew that!)

But I will say, that my experience with the Intel folks has shown them to be remarkably knowledgeable about signal processing too. In fact I routinely use their Signal Processing Library (SPL) and Math Kernal Library (MKL) (and both free for the asking!). These are excellent implementations of very fast algorithms, many of them hand crafted for maximum speed in the presence of multiple CPU's.

Using the SPL, for example, I am able to perform 10 successive large (e.g., 1024-4096 element FFT's) per block of audio on live audio at sustained streaming rates of over 200 KHz stereo (= 400 KHz audio) on a 500 MHz PIII. Even my old 350 MHz PII performs at around 190 KHz stereo. And I don't think that any of these routines are using the MIMD streaming extensions. These are all 32-bit floating point calculations in my case (24-bit audio mantissas).

So if you need to write any C code for signal processing, I highly recommend these Intel libraries.

Cheers,

- DM

IP: Logged

David McClain
Member
posted 06 March 2002 00:29         Edit/Delete Message   Reply w/Quote
... and I should point out...

The act of sampling audio at very high rates is such as to move these island replica spectra further apart, making it even more feasible to get good results with simple techniques like linear interpolation. The audio frequencies of interest continue to reside at the very low end of these spectra, and by spreading the replicas further apart, the aliasing occurs with ever smaller amplitudes since the Sinc^2 function decays as 1/F^2.

Hence, despite all the controversy surrounding the desirability of moving to 96 KHz or even 192 KHz, (and I maintain nobody hears well enough to need these higher frequencies -- so the reason is not related to hyper-hearing) the disirability stems more from the fact that you get better results from simple signal processing techniques.

So, yes, there is reason to move eventually to 96 KHz or 192 KHz sample rates, but it has little to do with the inherent quality of sound.

- DM

IP: Logged

David McClain
Member
posted 06 March 2002 00:47         Edit/Delete Message   Reply w/Quote
Here's a pop quiz for the mathematically inclined...

Why do we pretend that all signals are composed of sines and cosines, as we do whenever we talk about "spectra" of sound? We never hear pure sines or cosines in nature... We could as well, decompose sound into Tchebyshev polynomials, Legendre polynomials, or any of an infinite variety of other kinds of functions. So why use sines and cosines?

Answer: Because the complex exponential, of which sine and cosine are components, is an Eigenfunction of the convolution operator! So what? Well, every measurement we make is a convolution. Even the act of hearing sound is a convolution.

Send a sine wave into a filter and you get a sine wave out, at exactly the same frequency -- Eigenfunction! Linear filters only modify the amplitude and phase, but not the frequency. Filtering is a convolution operation too.

This simple fact is often overlooked by many highly experienced signal processing experts. They know it intuitively, but probably never stopped to think about it.

Decomposing sound into Eigenfunctions of the convolution operator is a very important technique for ascertaining the effects of any measurement. Do a convolution on a Tchebyshev polynomial and you won't get a replica of the input coming out of the convolution. Spectrum analyzers based on Tchebyshev polynomials wouldn't provide much in the way of usable information for the audio pro seeking to filter out that bothersome high frequency spur. But using sinewaves provides this useful information that we all take for granted -- because they are Eigenfunctions of the convolution operator.

- DM

IP: Logged

David McClain
Member
posted 06 March 2002 01:41         Edit/Delete Message   Reply w/Quote
...and by the way, Dennis, or anyone else, I can provide you with a graph of the spectrum of the results of higher order or even linear interpolation. Just drop me a note and I will e-mail you a document with the graph.

- DM

IP: Logged

pete
Member
posted 06 March 2002 07:32         Edit/Delete Message   Reply w/Quote
Re Your Pop quiz
I did ask myself why use sine/cos waves when tring to decoding sound.
I'm afraid I don't know what a Tchebyshev polynomials or Legendre polynomials are or what a Eigenfunction is.
But on spite of that I've came to a conclusion which may or maynot be the same as you have said, or a conclusion that may be incorrect altogether. I would like your opinoin.

When we are tring to decode sound ,what we are realy looking for is repeating patterns among a mix of many different repeating patterns. It would be imposiable to search for a pattern when we don't even know what the pattern we are looking for looks like.
But we know that every repeating pattern can be made up of a well defined and related set of sine/cos waves and whats just as important is that that pattern can be expressed in terms of those sines phase , amplitude and pitch exclusively. That is you could not make that repeating pattern out of any other combination of sines regardless of there phase , amplitude and pitch.
So if we now search the mix of patterns for a known pattern (sine/cos) as a first stage we can then regroup them after wards to find the repeating patterns we were looking for.
For a continuous sound there is only one solution to the combination of sines (pitch ,phase and amplitude) that represnt the mix.
Sine/cos waves are the only wave forms that have all of these properties.
You could represent the pattern mixture in terms of square waves of various widths but you wouldn't be sure that you are extracting components of only one of the patterns in the mix.

This is all asuming that the sound we are analizing is continuous but there still isn't a way to brake down none continuous sound without having to use presumptions or opinoins of some sort.

pete

IP: Logged

David McClain
Member
posted 06 March 2002 11:29         Edit/Delete Message   Reply w/Quote
quote:
Originally posted by pete:
Re Your Pop quiz
...
You could represent the pattern mixture in terms of square waves of various widths but you wouldn't be sure that you are extracting components of only one of the patterns in the mix....

pete


Pete, you have put your finger on the essence of what I was saying right here! See, you do have an intuitive understanding of it. You probably never bothered to phrase it in mathematical terms, but instead, just used your understanding to craft wonderful sounds.

Since I am far below your level of talent, I make up for it in life by becoming a scientist, and probing these minutiae to ridiculous depths. In the end we both contribute what we can. Too bad we can't have it all, eh?

Cheers,

- DM


[This message has been edited by David McClain (edited 06 March 2002).]

IP: Logged

dennis
Member
posted 07 March 2002 08:37         Edit/Delete Message   Reply w/Quote
Very thought-provoking. And thanks for the info on "single-pole all-pass filters". Time for more Kyma-play!

And please send me some spectrum graphs of linear interpolation results. ( dennis@mail.worldserver.com ). Thanks!


You wrote:
"Since I am far below your level of talent, I make up for it in life by becoming a scientist, and probing these minutiae to ridiculous depths. In the end we both contribute what we can. Too bad we can't have it all, eh?"


Truly, the Kyma seems to be one of these "art and science convergence vortices" (to coin a phrase). Incredible depth for both!


IP: Logged

tuscland
Member
posted 04 August 2005 03:10         Edit/Delete Message   Reply w/Quote
quote:
Originally posted by David McClain:
I just finished some experiments here in the creation of fractional delays. I found some very interesting things about this, which apparently SSC has also found.

Hi David,

You said the Delay prototype did not any fractional delay.
Where can I find the module that implements a fractional delay?


Thanks for your help,
Camille

IP: Logged

pete
Member
posted 04 August 2005 06:18         Edit/Delete Message   Reply w/Quote
Hi Camille

I think David is not quite right. I am prety sure it does do fractional delays by interpolation. A simple experiment will prove the point . Get two delays both being fed by the same signal and both feeding a mixer on the output. Then set both the max delays to 4 samp and the feedbacks to 0. Then set the delay in one of them to !Delay1 and set !Delay2 in the other . Set the scale in one of them to 1 and the scale in the other to -1. Now when you play the sound, if the two delays are the same you will get nothing. If you slowly move only one of the delays then sound will gradualy start to come through. If there were no fractional delays the sound would change in four destinct steps and would not change gradualy.

There is another oddity with the delay that may have looked like it wasn't doing fractional delays and that is that, if the "SmoothDelayChanges" is ticked then the actual delay can slowly gets closser and closser to the selected delay but some times doesn't fully get there. Also at the time of this original posting I think the option of turning off the "SmoothDelayChanges" was not there so it would have been very difficult to see exacly what was going on.

I could be totaly wrong and my old experiments may have been missleading me. If this is the case then I can tell you that the MultiTapDelay module in petesDSPmodules does do fractional delays, but it doesn't do any smoothing of any kind. You could use just one of the taps to get a fractional delay but it is a prossesor expensive way of doing it.

Another posiability is that the delay module has been updated since this posting and that at that time it didn't do fractional delays.

David is well switched on and I've learned not to dought his word lightly. So it's quite possiabe that I am telling you a load of rubbish, but this may act as a starting point to find out whats realy going on.

Hope it helps in some way

Pete.

P.S. It seems that the word "Interpolation" can have two different meanings amounting to the samilar but quite different things.

First.
It could mean that given a position between two known points you can calculate the single value of this new point. This would be used to transform a signal at one sample rate to a signal at a slightly different sample rate and this is what would be needed to output fractional delays. I misunderstood the interpolation control in the "Level" module as this, and didn't clock the true value if it.

Second.
It could mean that given two known points you could calculate a quantity of points to form a streight line between them. This would be used to fill in the gaps left between a 1 Khz control rate signals and smooth it up to sample rate, avoiding buzzing in an output. This is what was ment by interpolation in the "Level" module.

IP: Logged

tuscland
Member
posted 04 August 2005 13:22         Edit/Delete Message   Reply w/Quote

PetesDSPModules9-12-03.kym


fractionaldelaytests.kym

 
Hello Pete,

Thanks for your answer.
I actually need a fractional delay because I would like to implement a flanger, and I would like to compare one that does not has fractional delay and one that has.

Attached in a sound file with 2 sounds.
They implement the test you suggested with 2 different methods. The first one uses the DelayWithFeedback prototype, built in Kyma. The second one uses the MultiTapDelay in your prototypes.

By the way, for those who are interested, I have also attached a version of your prototypes organized within collections. It is more convenient when you use the sound browser. If you choose File->Open and select "Custom Prototypes" as the file type, you can replace the system strip by the system prototype PLUS Pete's DSP Modules, which is very convenient. The collections are suffixed with "Pete's ####" (where ### is the name of the collection) so that you can quickly go to those prototypes and distinguish them from the built-in ones.

Now, about the tests:
I found that the Kyma Delay has not fractional precision. You have in effect 4 steps. If I choose the SmoothDelayChanges, I have a feeling of fractional change, but it is wrong : The interpolation doesn't have definite positions, it really is a smoothing.

The MultiTapDelay shows it is a fractional delay because the changes between the delay scale values are progressive, and when using the SpectralAnalyser, I can see the resulting filter in action.
One odd thing: If I use a hot-variable in the Delays field, it doesn't do fractional delay. I had to use a fixed delay amount in the Delays field, and use the TapDelayScale with a hot-variable instead.

In the MaxDelay fields, I had to use 4 samp + 1 = 5 samp in order to have the correct behaviour at extreme values (0 or 1).

So it seems like David is right!
But you were also right about the SmoothDelayChanges option.

Concerning the meaning of Interpolation, I don't really understand, and like you I tend to interpret it as two different meanings. If I read the documentation, I don't get the difference between Interpolation and SmoothDelayChanges.

A last word about your DSP modules: they rock!!!
But I'd like to know what is the last version. It seems like I found a newer version in the forum than in the Tweaki. Is it possible to put the lastest versio there?

Thanks again!

Best Regards,
Camille

[This message has been edited by tuscland (edited 04 August 2005).]

IP: Logged

pete
Member
posted 04 August 2005 15:37         Edit/Delete Message   Reply w/Quote

PetesFlanger.kym

 
Hi Camille

The Problem with trying to make a flanger using the delay module is that it needs to have a smooth delay change but also needs to change a large amount over a very short time period. If you don't select "smoothDelayChanges " in the delay module then the delay will change in steps, once every 1 ms (1khz). If you do select "smoothDelayChanges " the rate of change is limited to no more the 2 samples change for every sample in time. This is so that no data gets mist out and stops the fizzing sound. This also means that you cannot change the delay very fast, which is what flangers need. The old flanger machines did in fact have that fizzing sound that the delay module was trying to avoid.

So I have made a new delay out of a sample player and a wave shaper and I've used petes DSP modules to Index them at full sample rate so as to avoid the 1ms steps.

With this I have ticked the interpolate in the wave shaper, and this gives you the fractional delays you were talking about but I don't think that this has made all that much of a difference.

As far as revisions of the DSP modules very little has changed. I only changed one module but I think the new one you found, is where SSC had improved the aficiantcy of one or two of them. I wrote them when I just started on DSP code and I've now improved quite a bit so I will revisit them some time and make them better but all my spare time at the moment is taken up with trying to improve on the cross filter. (which may not work so don't hold your breath).

Any way hope this flanger helps with what you are trying to do.

BTW if someone wants to post it on tweaky they can, but I just don't have the time at the mo

Thanks Pete.

IP: Logged

SSC
Administrator
posted 04 August 2005 16:30         Edit/Delete Message   Reply w/Quote
In the DelayWithFeedback module:

Delay time is: (Delay * DelayScale) rounded to the nearest integer sample

When SmoothDelayChanges is checked:
*Change* in delay time is made slowly and smoothly from previous to current delay time
If Linear Interpolation is also checked, then the smoothly changing delay is fractional and *not* rounded to the nearest integer (otherwise it is rounded)

So for fractional delays (during a change) you must have BOTH SmoothDelayChanges AND Linear Interpolation checked. It will always arrive at an integer-sample delay as the terminal value.

IP: Logged

pete
Member
posted 04 August 2005 17:55         Edit/Delete Message   Reply w/Quote
Hi SSC

But is it pos to have a fast moving change that settles on a fractional delay?

pete

IP: Logged

tuscland
Member
posted 04 August 2005 18:15         Edit/Delete Message   Reply w/Quote
In my example using the Kyma delay, when I set both Interpolation to Linear and check SmoothDelayChanges, I can hear that the delay change is fractional, but it seems like the final value is a integer sample value.

That means when I change the Delay1 or Delay2 fader, I don't get the expected result which is the ability to have a intermediate value between two samples.

It only happens in a short time during which the delay value goes from the initial integer value to the next integer value, smoothly.

SSC, can you confirm that?

IP: Logged

SSC
Administrator
posted 04 August 2005 19:20         Edit/Delete Message   Reply w/Quote

SSCFlanger.kym

 
The DelayWithFeedback module will always settle on an integer number of samples delay. It is this way so that the "resting" case does not filter the signal, only delays it. (For example, if you ask for 5.5 samples delay, linear interpolation will give you the average of a 5 sample and a 6 sample delay; the resulting signal has a 5.5 sample delay, but it is low pass filtered.)

There is a limit to the speed of the delay changes: it permits a maximum of an octave shift up, but for flanging you should never get close to this limit. (Attached to this note is a Sound that mimics Pete's flanger but uses the DelayWithFeedback module.)

IP: Logged

David McClain
Member
posted 05 August 2005 12:10         Edit/Delete Message   Reply w/Quote
...even if it did do interpolation to get fractional delays, this would still not be correct because of the artifacts introduced by interpolation. [I suspect that's what you mean by low-pass filtering. Interpolation is a kind of sloppy low-pass filtering.]

The only way to achieve fractional sample delays is by means of the AllPass filter. And even then, these fractional delays are accurate only for frequencies well below the Nyquist frequency. Indeed, all group delays approach zero as we approach the Nyquist frequency.

For a good (not-too-mathematical) discussion of this topic, refer to Ken Steiglitz's book "A Digital Signal Processing Primer" in chapter 6 where he discusses the use of an AllPass Filter in the feedback path of a delay element, used to obtain more accurate tunings in the upper registers of a plucked-string waveguide synthesizer. You need the fractional delays especially when the period of a pitched tone is only a few samples long. At these pitches, the tuning becomes too coarse with unit increments in delay.


[This message has been edited by David McClain (edited 05 August 2005).]

[This message has been edited by David McClain (edited 05 August 2005).]

IP: Logged

tuscland
Member
posted 07 August 2005 03:30         Edit/Delete Message   Reply w/Quote
Hi David,

By the way, I was just thinking about when you described how an AllPass filter is made :

y[n+1] = alpha * x[n+1] + x[n] - alpha * y[n]

By looking at this series, I can't help thinking about the approximation of a line, an interpolation in other words. You said that a one pole AllPass filter is better than doing just interpolation.

Could you please explain me the differences between an AllPass filter and a raw interpolation?

Thanks a lot for your writings on this forum, I've learned a lot !
Camille

IP: Logged

SSC
Administrator
posted 07 August 2005 12:11         Edit/Delete Message   Reply w/Quote
Delay interpolation is implemented as:

y[n] = (1-beta)*x[n] + beta*x[n-1]

where beta is the fractional time delay (in samples). This is the same as saying that the delayed value is found on a line that connects one sample to the next. For example, beta = 0.5 (a one-half sample delay) would be found by taking the value exactly half way between successive samples.

This interpolation formula exactly describes a one-zero lowpass filter (its response at DC is 1 and at Nyquist is 1-2*beta) with the desired delay over much of the spectrum (high frequencies are not delayed the correct amount when beta is close to zero or one).

The allpass filter that David describes can be thought of as two successive filters:

y[n] = x[n] + alpha*x[n-1]

and

z[n] = y[n] - alpha*z[n-1]

The first filter is quite similar to the interpolation filter above, and also has a lowpass response (it is a one-zero filter whose response at DC is 1+alpha and at Nyquist is 1-alpha). The second filter is a highpass filter (it is a one-pole filter whose response at DC is 1/(1+alpha) and at Nyquist is 1/(1-alpha)).

The lowpass and highpass filters have inverse magnitude response (so the result is flat or allpass), but the phase responses do not cancel (which is the delay characteristic that we want). The delay through the allpass filter depends on frequency quite a lot, with high frequencies delayed a quite a bit differently from the low frequencies.

Linear interpolation has the advantage that low and high frequencies are delayed about the desired amount, but the entire signal is lowpass filtered (the filtering is worst for a 0.5 sample delay). The allpass filter has the advantage that the signal is not filtered, but the components of the signal are dispersed (different frequencies have different delays).

IP: Logged

David McClain
Member
posted 11 August 2005 19:45         Edit/Delete Message   Reply w/Quote

APFComparisons.zip

 
Wow, that was a wonderfully lucid explanation! Many thanks SSC!

For those who are interested, I have attached a PDF showing some graphs of the phase and phase delay of these simple 1-pole/1-zero APF's.

My earlier statement about the phase response going to zero at Nyquist was incorrect, as you can see. The phase delay actually approaches one unit sample delay at Nyquist, regardless of the intended delay. And you can also see how the desired delay is accurate for frequencies well below the Nyquist frequency. It appears from the graphs that respectable accuracy is obtained everywhere below 40% of Nyquist, or 20% of the sample frequency.

I should do an example showing how an interpolation scheme behaves, but for now, just realize that there is a kind of Sin(x)/x envelope applied to the amplitude respose for simple linear interpolation, where the amplitude is down by about 30% at the Nyquist frequency. By contrast, all of the APF's have absolutely flat amplitude response over the entire frequency range. I don't know for sure, but it would seem to me that the phase response of a linear interpolator would be a kind of wavy curve that stays roughly centered all the way out to the Nyquist frequency. We'll see for sure once I run the SigLab plots....

[I had to Zip the PDF to make this web site accept the upload. There is only one file in the Zip file, and it is a PDF file.]

- DM

[This message has been edited by David McClain (edited 11 August 2005).]

IP: Logged

David McClain
Member
posted 11 August 2005 20:47         Edit/Delete Message   Reply w/Quote

interpolationstudy.pdf.zip

 
... here is the same kind of graph collection for the case of simple linear interpolation as described above by the SSC moderator.

Thinking more clearly about interpolation, the envelope of the amplitude response is a (sin(x)/x)^2 envelope, and as you can see from the first graph, the amount of amplitude attenuation depends strongly on parameter beta, being absolutely the worst at Nyquist for the case beta = 0.5.

Surprisingly (to me!) the phase responses are not wavy lines... I should have expected that. But as you see, the phase delay exhibits interesting properties. For values of beta = 0, 0.5, and 1, the phase delay is absolutely constant with frequency. For values of beta between 0 and 0.5, it gradually dips toward zero delay at Nyquist. And for beta between 0.5 and 1 it gradually increases toward unit delay at Nyquist.

Again, for frequencies below about 40% of Nyquist the phase delay appears reasonably accurate, and glancing at the amplitude response, for those same frequencies, the amplitude response is not too bad either.

I see also, that I was incorrect about declaring that only APF's can produce the desired fractional delays. I stand corrected, and illuminated...

Contrary to SSC's statement about dispersion, it appears that both the simple APF and linear interpolation will produce some degree of dispersion. [Am I wrong about this?]. Dispersion results from group delay variations with frequency. And group delay is related to the slope of the system phase response. Only when that phase response is a straight line (constant slope) will there be no dispersion.

[Quite frankly, I am surprised by this result for interpolation, and quite skeptical... Linear interpolation represents a kind of FIR filter and (I thought) it is known that FIR filters are linear phase systems. So this result makes me question the veracity of my measurement technique... Anybody?]

[No, this result is correct... so I am surprised today on several counts. Linear interpolation has a frequency dependent phase response that is not linear with frequency except at special values for beta. The system transfer function is H(z) = beta + (1-beta)/z, and since z varies along the unit circle as z = Exp[i 2 Pi f/fs], this clearly has non-constant phase slope. The phase should be something like

phase[f] = Atan[(beta Sin[2 Pi f/fs])/((1-beta)+ beta Cos[2 Pi f/fs])]

and this has non-constant slope except when beta = 0, 0.5, and 1.0. Hmmm...

Okay, this result falls back to the difference between symmetric and asymmetric FIR filters. Symmetric FIR filter are linear phase systems, have constant group delay, and hence zero dispersion. But asymmetric FIR filters do exhibit frequency dependent phase variations that are not linear and so they can exhibit dispersion.

I first saw this kind of result several years ago when an "Audio Speaker Expert" was using half-windows to window his measurement data. That represents an asymmetric FIR filtering operation and the result produces complex valued spectra with a non-constant complex factor. In other words, the spectra are not simply multiplied by a linear phase ramp. I thought at the time, and I still do, that this is an oddball technique fraught with measurement artifacts....]

- DM


[This message has been edited by David McClain (edited 11 August 2005).]

[This message has been edited by David McClain (edited 11 August 2005).]

IP: Logged

SSC
Administrator
posted 12 August 2005 10:36         Edit/Delete Message   Reply w/Quote
"Okay, this result falls back to the difference between symmetric and asymmetric FIR filters. Symmetric FIR filter are linear phase systems"

Correct.

By the way, if people are asking themselves "What is a symmetric FIR filter?", think of an FIR filter as a "multi-tap delay line":

Y(t) = (a0 * X(t)) + (a1 * X(t-1)) + (a2 * X(t-2)) + .. + (an * X(t-n))

where t is the current time, (t-1) is one sample in the past, etc. And the coefficients (the "a" values) are like the amplitude faders on each tap. Y is the output, and X is the input signal.

A symmetric filter is one in which the coefficient values are the same in reverse--sort of like a palindrome. In other words:

a0 = a(n-1), a1 = a(n-2), etc.

It might be fun to reason through why it is that symmetric coefficients (or palindromic fader settings on a multi-tap delay line) would result in a constant delay over all frequencies. (In other words, no matter what the frequency of the input, the output delay is the same.)

Maybe we should start with a 3-tap delay line and explain why this would have a constant delay no matter what the frequency of the input. Also, how long is that constant delay? (Remember, these are single sample delays so you won't hear them as 3 separate delays.)

IP: Logged

David McClain
Member
posted 12 August 2005 12:59         Edit/Delete Message   Reply w/Quote
...yes, apart from algebraic reasons... I'd like to hear about this too! I love learning in this manner, tying these concepts back to logical reasoning.

[BTW... that half-sample delay achieved through interpolation is a symmetric FIR with a half-sample delay. In fact, any symmetric FIR with an even number of taps will exhibit an integral plus a half sample delay.]

[ Interesting... a completely antisymmetric FIR, like our old friend the Hilbert Transform filter, produces not a constant delay, but a constant phase shift at all frequencies (in the ideal case). And so an asymmetric FIR -- partly symmetric and partly anti-symmetric produces the oddball kind of dispersive results we have seen above...

Well... not quite... the AntiSymmetric filters produce the same kind of fixed overall delay, independent of frequency, plus a quarter cycle phase shift. In other words, the phase shift is not arbitrary.]

- DM


[This message has been edited by David McClain (edited 12 August 2005).]

[This message has been edited by David McClain (edited 12 August 2005).]

IP: Logged

SSC
Administrator
posted 12 August 2005 14:19         Edit/Delete Message   Reply w/Quote

interpvsallpass.pdf.zip

 
[diversion back to the delay versus frequency plots]

Here is another version of the drawings that David has posted showing the delay versus frequency for the interpolation case (blue) versus the allpass case (red). These plots were generated mathematically by evaluating the phase response of the difference equations.

An ideal fractional delay would have horizontal lines, indicating that the delay for all frequencies is identical. As you can see, in both the allpass and the interpolation cases, low frequencies are delayed by the correct amount, but higher frequencies do not have the desired delay. However, the delay values for interpolation are closer to horizontal lines (the ideal, constant delay).

The interpolation fractional delay is less dispersive but interpolation also colors the spectrum (which the allpass fractional delay implementation does not do).

[This message has been edited by SSC (edited 12 August 2005).]

IP: Logged

David McClain
Member
posted 12 August 2005 16:23         Edit/Delete Message   Reply w/Quote
Very nice comparison!

Here is a case where multirate processing could really shine. If we had the ability to upsample the audio streams by as much as 8x or 16x, then we could get reasonably close (0.1 samp) to fractional delays which would be constant at all frequencies. Then we would have to downsample again, offset by the fractional delay shift amount.

Of course upsampling/downsampling implies some form of "interpolation" which is usually obtained by way of low pass filtering.

[all we need is another 10x speedup in the Capy!, eh?]


- DM

[This message has been edited by David McClain (edited 12 August 2005).]

[This message has been edited by SSC (edited 12 August 2005).]

IP: Logged

David McClain
Member
posted 13 August 2005 21:16         Edit/Delete Message   Reply w/Quote
Answers to quizzes?

Having thought about this for a day now, I have the following observations:

1. Consider an odd-number of FIR taps, symmetric about the central value. Choose that central value as a reference point, and the delay that occurs at that point as the delay of the filter.

2. Any arbitrary sinewave at any point in time can be decomposed into a cosine (symmetric about the reference point), and a sine (anti-symmetric about the reference point).

3. Since all the coefficients of the FIR are symmetric about the reference tap, the sum of products of those coefficients with the cosine portion survive to produce some value, while the sum of products with the sine portion cancels out.

4. This occurs, regardless of frequency.

5. Hence (?) the delay associated with a symmetric FIR filter is constant with frequency(?).

-----------------
By extension... a completely antisymmetric FIR filter produces the same amount of delay but selects out the sine portion instead of the cosine portion. So perhaps an IQ phase shifting network could be build from other forms of anti-symmetric FIR filters aside from the approximations to a Hilbert transform.

I suspect that the Hilbert transform approximations do the very best at being all-pass in character over the widest possible frequency range, and that any other form of antisymmetric FIR will not exhibit constant gain with frequency as well as the Hilbert Transform filters.

But perhaps there are occaisions where shaped frequency response in an IQ transformer would be desirable?

- DM

[ Oh yes... I never forget a challenge, and about 3 years ago, Carla posed the question about beats being related to the simple superposition of two sinewaves very closely spaced in frequency -- as opposed to my saying that the nonlinearities of human hearing cause the beats.

Of course Carla was correct. In order to hear the nonlinearly produced beats, you would have to (A) have high amplitude signals, and (B) those beats would have to be above 20 Hz in order to be audible in this way.

In fact, if you simply combine two Kyma Oscillators into a mixer and place them 0.1 Hz apart, then you can even watch the DSP Status window and see the output level beating at the 10 sec period. And so this beating occurs (A) without even the presence of a human ear, and (B) occurs at arbitrarily low amplitudes.]

-----------------------
The Question marks in point (5) above were put there because I was not convinced of this argument myself...

So now, refering to the prior discussion about using averaging, we can look at the delays induced by each tap. In the case of 3 taps, there is the delay for the central tap alone. There are also two identically gained delays that average to this central delay due to the taps on either side of the middle tap. By extension this can be applied to any odd-length FIR, with symmetrically spaced equal value taps causing an average delay equal to all the other symmetrically spaced taps. And this occurs regardless of frequency.

It is easy to extend this to even number of taps, where the central delay is midway between the two taps at the center of the filter.

Now this explanation is more convincing to me...

- DM

[This message has been edited by David McClain (edited 13 August 2005).]

IP: Logged

Sylvain KEPLER
Member
posted 14 August 2005 06:48         Edit/Delete Message   Reply w/Quote
Hi David,

A simple question [before printing out the posts and read all of them carefully (seems interesting)]..what would be the use of these fractional delays when making sounds ??....

IP: Logged

David McClain
Member
posted 16 August 2005 12:00         Edit/Delete Message   Reply w/Quote
Hello Sylvian,

You need fractional delays when you are attempting to create a waveguide synthesizer (a la Karplus-Strong). The delay corresponds to the resonant length of the waveguide.

The problem with fixed incremental (single sample increments) delays is that at higher frequencies the tuning becomes too coarse.

For example, with a sample rate of 48 KHz, the A6 (three octaves above A440) has a period of 13.63 samples, while the next note, A#6 has a period of 12.87 samples.

If you were to use only fixed sample-incremental sample delays, then your tuning would become 46 cents flat for A6 if you use 14 samples delay, and the next note A#6 would become similarly flat at 13 samples.

In order to bring the tuning scale back in line with expectations, you need fractional delays in the waveguide instrument. And that's where these two techniques (all-pass filter, or interpolation) lend themselves.

- DM

[This message has been edited by David McClain (edited 16 August 2005).]

IP: Logged

Sylvain KEPLER
Member
posted 16 August 2005 14:51         Edit/Delete Message   Reply w/Quote
Thank you David, very interesting stuff...so I'll read carefull all the posts by now. I allow myself to follow up with that wiki definition of the waveguide synthesis, so it will avoid me awkwardly paraphrase what it's a bout..and that will be usefull for people who will need to look into the problem basis. That link may be of some interest as well :
http://ccrma-www.stanford.edu/~jos/swgt/swgt.html

PS : What would be the next interesting stuff ...why not looking into the implementation of Navier-Srockes equations with Kyma (and shallow water waves btw) as a start point to new ways of making sounds ...

******
waveguide synthesis :

Digital waveguide synthesis is the synthesis of audio using a digital waveguide. Digital waveguides are efficient computational models for physical media through which acoustic waves propagate. For this reason, digital waveguides constitute a major part of most modern physical modelling synthesizers.

A basic one-dimensional digital waveguide (likely of a string) with a rigid termination on one end (left) and a frequency-dependent attenuating filter at the other (right).A lossless digital waveguide realizes the discrete form of d'Alembert's solution of the one dimensional wave equation as the superposition of a right-going wave and a left-going wave,

y(m,n) = y + (m − n) + y − (m + n)
where y + is the right-going wave and y − is the left-going wave. It can be seen from this representation that sampling the function y at a given point m and time n merely involves summing two delayed copies of its travelling waves.

Digital waveguide models are therefore comprised of delay lines to represent the geometry of the waveguide, digital filters to represent the frequency-dependent losses and dispersion in the medium, and often include non-linear elements. Losses incurred throughout the medium are generally consolidated so that they can be calculated once at the termination of a delay line, rather than many times throughout.

Although waveguides such as a acoustic tubes may be thought of as three-dimensional, because their lengths are often much greater than their cross-sectional area, it is reasonable and computationally efficient to model them as one dimensional waveguides. Membranes, as used in drums, may be modelled using two-dimensional waveguide meshes, and reverberation in three dimensional spaces may be modelled using three-dimensional meshes.

Digital waveguide synthesis was developed by Julius O. Smith III and represents an extension of the Karplus-Strong algorithm. Stanford University owns the patent for digital waveguide synthesis and signed an agreement in 1989 to develop the technology with Yamaha.

An extension to DWG synthesis of strings made by Smith is commuted synthesis, wherein the excitation to the digital waveguide contains both string excitation and the body response of the instrument. This is possible because the digital waveguide is linear and makes it unnecessary to model the instrument body's resonances after synthesizing the string output, greatly reducing the number of computations required for a convincing resynthesis.

******

Karplus-Strong string synthesis

Karplus-Strong string synthesis is a method of physical modelling synthesis that loops a short waveform through a filtered delay line to simulate the sound of a hammered or plucked string or some types of percussion. This is a subtractive synthesis technique based on feedback.

How it works ?

A short excitation waveform (generally of length L samples), often a burst of noise, is output and simultaneously fed back into a delay line L samples long.
The output of the delay line is fed through a filter. The gain of the filter must be less than 1 at all frequencies, and the filter is usually a first order lowpass filter (as pictured).
The filtered output is simultaneously mixed back into the output and fed back into the delay line.

Tuning the string

The period of the resulting signal is the period of the delay line plus the average group delay of the filter; the frequency, as usual, is the reciprocal of the period. The required delay D for a given fundamental frequency F1 is therefore calculated according to D = Fs/F1 where Fs is the sampling frequency.

Digital delay lines are available only with lengths that are whole-number multiples of the sampling period. In order obtain a fractional delay, interpolating filters are used with parameters selected to obtain an appropriate group delay at the fundamental frequency. Either IIR or FIR filters may be used, however FIR have the advantage that transients are suppressed if the fractional delay is changed over time. The most elementary fractional delay is the linear interpolation between two samples (e.g., s(4.2) = s(4)·0.8 + s(5)·0.2). If the group delay varies too much with frequency, harmonics may be sharpened or flattened relative to the fundamental frequency.

A demonstration of the Karplus-Strong algorithm can be heard by downloading the following Vorbis file. The algorithm used a loop gain of 0.98 with increasingly attenuating first order lowpass filters. The pitch of the note was A2, or 220 Hz.

Karplus-Strong #1, F1 = 220Hz
Holding the period (= length of the delay line) constant produces vibrations similar to those of a string or bell. Increasing the period sharply after the transient input produces drum-like sounds.


Refinements to the algorithm

Julius O. Smith III and others realized that the Karplus-Strong algorithm was physically analogous to a sampling of the transversal wave on a string instrument, with the filter in the feedback loop representing the total string losses over one period. Generalization of the algorithm lead to digital waveguide synthesis, which could also be used to model acoustic waves in tubes and on drum membranes.

[This message has been edited by Sylvain KEPLER (edited 16 August 2005).]

IP: Logged

David McClain
Member
posted 17 August 2005 14:37         Edit/Delete Message   Reply w/Quote
Navier-Stokes!!?

(That's typically a 2-D or 3-D PDE and requires a grid-based computation. Not sure how you'd extract sound from the results. Any suggestions? Talk about challenging!!! Heh!)

- DM

IP: Logged

Sylvain KEPLER
Member
posted 18 August 2005 01:44         Edit/Delete Message   Reply w/Quote
...David, always dreamt of making 'waves' in FFT : Time, Amplitude and frequency...let's throw a coin in the FFT and make a wish... That might be challenging indeed

IP: Logged

David McClain
Member
posted 20 August 2005 16:54         Edit/Delete Message   Reply w/Quote
Hmmm... one of the disappointing things about randomly generating spectral coefficients in the FFT -- it can certainly be done -- is that the vast majority of the FFT coefficients address extremely high frequencies. Hence the sounds tend to be quite squeaky and obnoxious sounding.

A better approach would be to work in the Bark bands but this entails some complicated interpolation among the FFT cells. The lowest bands are the ones of most interest. And so going back to the FFT, depending on how long your window is, probably the first 20 coefficients are the most useful to play with. That covers all the way from DC to 2 KHz at FFT lengths of 1024, or 4 KHz for 512 cells. Messing with the higher ones tend to be really disappointing...

- DM

IP: Logged

RobRayle
Member
posted 29 October 2005 16:49         Edit/Delete Message   Reply w/Quote

FractionalDelayKarplus-Strong.kym

 

There's a simple implementation of a micro-delay in Kyma
attached here & also on the Tweaky. It works reasonably
well - test it by pitch-bending higher & higher notes until
discontinuities in the pitch-bend show up.

Question: how do you make better use of the higher-order allpass
filters? Increasing the order of the allpass filter can increase
the micro-resolution of the delay, but increasing order (samples) of
the filter comes at expense of decreased resolution in the sample
accurate delay in these models. How do you pack *just* the micro
(in-between samples) part of the delay into multiple samples
(higher order) of the allpass filter & make the math come out right?
In Kyma, that is ...

IP: Logged

SSC
Administrator
posted 30 October 2005 11:17         Edit/Delete Message   Reply w/Quote
You could cascade a DelayWithFeedback Sound (with Feedback set to zero) followed by the allpass filter. The delay would give you integer number samples of delay and the allpass filter gives you the fractional sample delay (fine tuning).

I think that you would want to use lower order allpass filters rather than higher order filters. The higher the order the more the phase shift changes with frequency (this will cause different frequencies to be delayed by different amounts).

See FractionalDelay.kym at http://www.symbolicsound.com/cgi-bin/bin/view/Share/Sounds#Effects_Processing for an example of this.

[This message has been edited by SSC (edited 30 October 2005).]

IP: Logged

RobRayle
Member
posted 30 October 2005 20:16         Edit/Delete Message   Reply w/Quote

FractionalDelayKarplus-Strong.kym

 

Here's the revised version of the Kyma prototype that answers that question - I figured it out after sleeping on it. Higher order allpass filters do indeed give you greater precision - notice that the fourth order allpass filter gives you continuous pitch bending at higher pitches than the third.

The third order filter is the lowest order that works properly. The second order filter hits a boundary condition when the fractional portion of the delay goes to zero.

Now that we've got this tool we can really flange, simulate Leslies, & do other cool stuff with physical models.

IP: Logged

RobRayle
Member
posted 31 October 2005 19:12         Edit/Delete Message   Reply w/Quote

Back in August of this year, Pete wrote:
"The Problem with trying to make a flanger using the delay module is that it needs to have a smooth delay change but also needs to change a large amount over a very short time period."

The microdelays I have posted with the last mail & on the tweaky allow this. You can get arbitrarily fast smooth transitions in delay time, no clicks, provided you use a high enough order allpass filter.

Of course, an instantaneous smooth transition in delay time will require an infinite order filter - so that's impossible.

But you can get an arbitrarily large smoot delay-delta provided you have the DSP for it.


IP: Logged

RobRayle
Member
posted 02 November 2005 18:54         Edit/Delete Message   Reply w/Quote

Whoops, maybe I barked too soon. I tried the delay on some generic
audio samples (virtue) & it has some pretty bad clicking/artifacts
unless interpolation is on in the sample-accurate delay.


IP: Logged

All times are CT (US)

next newest topic | next oldest topic

Administrative Options: Close Topic | Archive/Move | Delete Topic
Post New Topic  Post A Reply

Contact Us | Symbolic Sound Home

This forum is provided solely for the support and edification of the customers of Symbolic Sound Corporation.


Ultimate Bulletin Board 5.45c