Tuning Waveguides
I'm working out a simple patch for a waveguide using gen for the first time, and I'm using this very helpful guide https://www.osar.fr/notes/waveguides/, but I'm at the section on tuning the delays to musical pitch. Since you have to account for the LPF in the feedback loop, is there a good way to calculate the correct delay time for a desired pitch given the current filter cutoff, that doesn't involve regression? I'm not the most comfortable with statistics in general so I'm not super confident that the equations I'm coming up with are at all accurate.
hertz to milliseconds is [!/1000.]
to get rid of functions calculation you could write the result in a buffer (outside the gen~) and use it as lookuptable.
and while this does not answer your original question, to solve the nasty frequency filtering problem in a feedback loop you could upsample it 8 times (and lp filter it when downsampling.) in the case of gen~ you will probably have to put the whole gen~ patch into a poly~.
Thanks for the reply Roman. I'm still getting a hang of optimizing these things so tips like this really help. Correct my interpretation here of the second part if I'm wrong: the upsampling here would avoid unwanted filtering from a standard sampling rate not being high enough to accurately do the calculations with? Would this be standard practice when working with feedback loops like this?
I understood the relation of delay time to frequency, but I guess my trouble is understanding how to compensate for how the inner filter also effects the pitch? It seems like an impossible problem to generalize this given all the permutations of filter coefficients.
i am not sure if got the question right, but i was under the impression that you were talking about the "unwanted combfilter" issue: for example if you delay a signal for 0.5 samples and add it to the input, you´ll end up with "interpolation 1" aka "3db lowpass at nyquist/2".
or are you talking about using frequency filters within the feedback at higher feedback decays? (you can hear that well in one of the examples on this website.) for those i believe you can only reduce it by using certain filter types/topologies.
and it is not linear (as regressions are :) ), it probably depends wether the problematic frequency range of the input material and the filter "match" or not... and you dont know what might come in next...
as you can see i am only guessing around and that i also how i patch. when i remember right, using only butterworth filters worked very well.
trial and error is completely legal, you dont need to become julius smith 2.0 in three days.
I understood the relation of delay time to frequency, but I guess my trouble is understanding how to compensate for how the inner filter also effects the pitch?
You could calculate the phase response of your filter and from there find the phase delay at - let's say - the fundamental of your pitched output sound. With this value you could 'correct' the delay time of your waveguide.
If your are using a biquad filter, there's a handy 'query' message that outputs amp and phase values.
the question is... will it be enough to substract the filters´group delay from the tapping buffer? and on which frequency should this be based?
and what happens if you want to modulate the filter quickly?
:)
Hmmm, yeah it seems like it be a bit more complex than I initial anticipated. I'll just stick to keeping that non-modulatable for now. Thanks!
In our recent book (https://cycling74.com/books/go) we took a pragmatic approach finding that for a simple one pole filter with a coefficient of "b", a pretty reliable adjustment to the delay time (in samples) is "-2*log(1-b)". It holds tuning well over the usual range of musical pitches, and is very cheap.
A better adjustment might take into account the (intended) fundamental frequency of the string, and compute the filter's phase delay at that frequency (as Volker says above). Theoretically for a one pole LPF this phase delay is -atan2(fstringhz / fcutoffhz), but in practice I don't find that this actually peforms better to keep the string in tune.
On a separate note: pitched strings require non-integer sample delay times, which means using some kind of interpolation, and that will also add some filtering which may be more noticeable on some notes than others. In the book we look at a few different ways of counteracting this filtering side effect, with allpass interpolation being the cheapest and simplest for static pitches, but because of allpass instability we prefer sinc interpolation for strings that modulate frequency.