Algorithms for modulated delay

DSP, Plugin and Host development discussion.
RELATED
PRODUCTS

Post

SMH wrote: I'm not taking it personally, but you're being quite rude to people trying to help you, who you might also notice are all telling you the same thing.
Would you mind telling me when? Sure, I pointed out problems, but I cannot find a single moment where I was rude, anyhow. Just if you have a spare moment, please tell me, it would be cool to know, I find people often have very different ways to communicate after all.
Vojtech
MeldaProduction MSoundFactory MDrummer MCompleteBundle The best plugins in the world :D

Post

Accidental double post
Last edited by DNAdisaster on Tue Jun 27, 2017 6:07 am, edited 1 time in total.

Post

MeldaProduction wrote:Repeating here: MDelayMB, just tried it, square wave modulation to the delay line, zipper free
I think there was a misunderstanding here. From your original post I got the impression that were trying to improve sound quality, but from this it sounds like you just want a more efficient way to do what you've already accomplished. Is that right?

In any case, I am confused about this statement:
MeldaProduction wrote:Now, I must misunderstand something - imagine you have a 20 seconds delay at one point, let's round it to a million samples. The user then changes the delay (slowly :) ) to 100ms (say 4000 samples). So at this point resampling as I understand it would mean that the output buffer, lets say 1024 samples, would actually need to be processing 250k samples.
I don't understand the last sentence here. The delay line's job is to remember the original input samples and then simply barf them out some T seconds later, right? Of course, you will likely end up needing to output a sample that is in between the ones you recorded, which is why the delay needs to perform some sort of interpolation. But why would decreasing T require more samples be involved? Maybe I'm missing a more subtle point.

Post

when move more sample i think it is unhearable when the play pointer suddenly move 4 sample and all samples that are skip are add in a average interpolation. Cd error correction do same way. if a block can not read it average last samples, and repeat it. clicks are very good hearable so should avoid, but if high frequency suddenly skip is not hearable
win 10 64 22H2 intel i5 8600K (6*3.6 GHZ) 32 GB Ram

Post

Thanks for the response folks.

DNADisaster: Actually, I was more like specifying both algorithms I know of, plus their problems. I sort wonder if there isn't something I missed. I think the whole confusion in this topic comes from the fact, that I had sort of bad experiences with the interpolating method, which apparently everyone is using. But it's true that in my plugins it is just very easy to make physically impossible jumps. And I like to make it work with it anyways :). I personally like the delay line stretching, but as I said despite it sounds nearly perfect imho, it can take a lot of CPU when modulated while the delay line is very long. On the other hand when nothing is modulated, there is even no interpolation needed, so it's deadly fast.
Anyways I wondered if there isn't some "classic" algorithm, that I missed for all these years for some reason :D, that would be some kind of compromise, or even better, an ultimate solution :D.

magicmusic: I think 4 samples is usually fine, but it quite depends on the actual audio. Things are often reaaaally audible with sine waves for example, and some synths often remind these. Anyways the thing is, while 4 samples is fine, the jumps may be way bigger. And the delay stretching works well with that, but the damn CPU :D... I need to come up with some optimization, but I'm currently partly out of ideas :D. Not giving up yet though! :D
Vojtech
MeldaProduction MSoundFactory MDrummer MCompleteBundle The best plugins in the world :D

Post

The standard way to envisage a delay is as a tape moving at a fixed speed past a write head, and some time later past a read head. The normal way to adjust the delay is to move the read head nearer to or further from the write head. This introduces a pitch shift if the delay is smoothly adjusted, as the read head is moving more or less quickly through the waveform that was recorded earlier. A step change in the position of the read head is not physically realistic but could easily be modelled - it would introduce a discontinuity in the waveform being read. Potentially a modulated delay might be seen as a series of step changes which would produce a series of discontinuities, perceived as zipper noise. One solution would be to smooth the modulation signal so the read head moves continuously rather than jumping.

However the solution that I think MeldaProduction is imagining is, rather than moving the read head to a different place on the tape, the section of tape between the read and write heads is stretched or compressed so that it still fills the gap between the heads after the read head has moved. The tape then continues to move at its original speed. This avoids C0 discontinuities (but not C1) , but the whole of the stretched/compressed section of tape is pitch-changed depending on how far the read head moves relative to the delay time.

Whilst this would work in the sense that you'd end up changing to the desired delay, I think that stretching the tape (which equates to resampling the delay buffer) at each step of a modulation will be rather expensive. Moving the read head through the delayed stream is a lot cheaper and closer to a mechanical model. Limiting slew rate reduces zippering. If you don't allow the delay to increase faster than unity (i.e. increasing delay from t to t+dt always occurs over an interval of more than dt) then you don't even have to worry about reading buffer data that you no longer possess.

Post

Exactly!!

The problem was when I was doing what you are describing, that I really needed to slow things up far to much for what I wanted to avoid the zipper noise. But yeah, I was doing something a bit extreme :D.
Vojtech
MeldaProduction MSoundFactory MDrummer MCompleteBundle The best plugins in the world :D

Post

Ok, if you are keen to explore the 'stretchy tape' model, I think you could do this without resampling the whole buffer every time the delay changes.

Imagine starting with a delay of 1000 samples, which we want to increase to 5000 samples using the stretchy tape model. The 1000 samples in the buffer would be stretched out (resampled) to 5000 samples, and then read back one sample at a time. Each tick in the resampled buffer would represent 1/5 of a tick in the original buffer. It would take 5000 ticks before unstretched data appeared at the read head and the pitch returned to normal.

But you could have exactly the same effect if, at the start of the jump modulation, you extend/pad your buffer size to 5000 samples (no need to initialise the new memory). Then for the next 5000 ticks you move the read head further from the write head by 4/5 tick each tick - so after 5000 ticks it would have moved 4000 ticks further away. But because the buffer is also filling at one sample per tick, you are effectively stepping through the original 1000 samples at 1/5 sample per tick, exactly as before only without resampling. After the 5000 ticks have passed, you stop moving the read head backwards, and the pitch returns to normal, just as in the stretchy case.

I guess, since you will be interpolating samples for 5000 ticks, you could say that you have spread the cost of resampling the buffer over that period.

Now, if the delay changes again during the period when you are 'reading the stretched tape', (say after 2000 sample) you will have complications because some of the tape will have been stretched once and some twice - you will have to keep track of where the changes occur so you can change the speed at which the read head is moving. But at least in principle it can be done without resampling the buffer every time. :)

Post

you mean stretching but keep frequency constant. when increase for a very short time the readout speed, in that way, that it get only upto 3 cent in frequency higher, maybe can sound good. mostly simulate more singers sing or a good double tracking of guitar this can give better results. when speedup is so fast that it go over 3 cent transpose this give out of tune results, but if faster or slower speed is only do for short time this is maybe unhearable and produce no flanging or phaser effects
win 10 64 22H2 intel i5 8600K (6*3.6 GHZ) 32 GB Ram

Post

Nice idea kryptonaut. You make me realize that the "in a way ideal" delay line stretching is nearly 50% similar to the classic interpolation algo. So essentially to do what I want we have to make the delay have 3 states:
a) There is no stretching being performed at the moment and the delay again becomes "memory transfers", which are obviously superfast.
b) The delay length has been increased -> we can just increase the buffer size and keep it "undefined" and do the interpolation trick you said. Here it is necessary to make the "head" speed "perfect", which may be challenging especially if the delay line is constantly moving.
c) The delay length has been decreased -> we need to downsample it, moving average should do it, and since 1 sample per input equals at least 1 sample being "fed from the delay line" it is fine to keep the delay buffer intact. Again there will be the problem with keeping everything working when the delay line is constantly moving.

Interesting! That should keep the CPU requirements minimal when there is no modulation and when there is some each sample will be processed minimum times. The disadvantage is that the delay buffer will need to stay at the maximum size and the stretching itself probably won't be vectorized, or at least not as much as it is now. But that's a reasonable price ;).
Vojtech
MeldaProduction MSoundFactory MDrummer MCompleteBundle The best plugins in the world :D

Post Reply

Return to “DSP and Plugin Development”