Re: [music-dsp] Changing Biquad filter coefficients on-the-fly, how to handle filter state?

2016-03-28 Thread vadim.zavalishin

robert bristow-johnson писал 2016-03-28 23:31:

This statement implies the LTI case, where the concept of the

transfer

function exists.


i didn't say that.  i said "applying ... to the same integrator."
about each individual "transfer function" that looks like "s^(-1)"


You were talking about bilinear transform, which is a thing applied to 
the transfer function, therefore I thought you implied that.



i didn't say anything about a "transfer function", until this post.  i
am saying that the trapezoidal rule for modeling integrators is
replacing those integrators (which by themselves are LTI and *do*
happen to have a transfer function of "s^(-1)") with whatever "T/2 *
(1 + z^(-1)) / (1 - z^(-1))"  means.  and that's the same as the
trapezoid rule.  (the stuff connected in-between might be neither L
nor TI.)


No argument about that.


a "transfer function" is not enough information to fully define a
system unless other assumptions are made (like "observability" or
"controllability").  that's why the general state-variable system
(Hal's title is a little bit of a misnomer), ya know with the A, B, C,
D matrices, exists to generalize it.  i'm pretty confident that any
*linear* circuit (but possibly time-varying) you toss up there, with
either gooder or badder emulation of the reactive elements, will come
out as this generalized state-variable system.


To the best of my knowledge a transfer function fully defines the 
"outside" behavior of an LTI system (treated as black box) regardless of 
observability or controllability. As for the state-space form, being a 
set of explicitly written differential or difference equations, it 
contains full information about the time-varying behavior of the system.




but with some coefficients that can vary.  like in
http://control.ucsd.edu/mauricio/courses/mae280a/lecture8.pdf .  i
couldn't easily find a discrete-time version on the web.  you might
notice that there *is* a concept of a time-variant impulse response
h(t, tau) (if it were LTI, h(t, tau) = h(t-tau)).  it's the impulse
response, h(t), responding to a unit impulse applied at time tau.  fix
tau and you have an h(t).  if you have an h(t), then you also have an
H(s) (or in general an H(s,tau)) and i might call that a "transfer
function".  but it's a time-varying transfer function and if it varies
wildly, you can't use Fourier analysis at all.  but if it varies
slowly enough, you can use Fourier analysis, at least to the point of
discussing frequency response and the behavior of the system for short
periods of time.



Tau is the time of the application of the impulse, not the time, when we 
measure the output signal. This time therefore has no connection to 
filter's parameters at some given time moment (like asking, what is the 
filter's formal impulse response at the given time, when the filter's 
parameters are set to a given value). That is, the formal transfer 
function obtained from such impulse response will be dependent on the 
specific way the filter's parameters are changing over the entire time 
axis, starting with tau, and cannot be attributed to a specific moment 
in time when "the cutoff knob is set to a given position".


But I believe we strayed too far from the original topic. I believe the 
purpose of asking the question of handling the filter's state had to do 
simply with nice filter's behavior under time-varying conditions, and 
that question is easily answered in the ZDF domain (or by explicit 
trapezoidal integration of differential equations). One possible reason 
for continuous-time filters behaving nicely under parameter modulation 
is that the cutoff variation in continuous time is equivalent to a 
(monotone) warping of time axis, so there is an equivalent LTI case for 
each cutoff curve.


Of course other ways of dealing with the problem are not excluded, but 
if the reason for asking is purely practical, there is an easy answer.


--
Vadim Zavalishin
Reaktor Application Architect | R
Native Instruments GmbH
+49-30-611035-0

www.native-instruments.com

___
dupswapdrop: music-dsp mailing list
music-dsp@music.columbia.edu
https://lists.columbia.edu/mailman/listinfo/music-dsp

Re: [music-dsp] Changing Biquad filter coefficients on-the-fly, how to handle filter state?

2016-03-28 Thread vadim.zavalishin

I don't know much about these yet -- but your book is on my list to

read in

the near future!


This stuff is actually simpler than what you're trying to do. So I'm not 
sure, what are you waiting for ;)


robert bristow-johnson писал 2016-03-28 17:57:

using the trapezoid rule to model/approximate the integrator of an
analog filter is no different than applying bilinear transform
(without compensation for frequency warping) to the same integrator.

   s^(-1)  <---   T/2 * (1 + z^(-1)) / (1 - z^(-1))


This statement implies the LTI case, where the concept of the transfer 
function exists. In the topic of this thread we are talking about 
time-varying case, this means that the transfer function concept doesn't 
apply anymore. Specifically, filters with identical *formal* transfer 
functions will behave differently and this is exactly the topic of the 
discussion.


Regards,
Vadim

--
Vadim Zavalishin
Reaktor Application Architect | R
Native Instruments GmbH
+49-30-611035-0

www.native-instruments.com
___
dupswapdrop: music-dsp mailing list
music-dsp@music.columbia.edu
https://lists.columbia.edu/mailman/listinfo/music-dsp

Re: [music-dsp] Changing Biquad filter coefficients on-the-fly, how to handle filter state?

2016-03-28 Thread robert bristow-johnson







 Original Message 

Subject: Re: [music-dsp] Changing Biquad filter coefficients on-the-fly, how to 
handle filter state?

From: "Ethan Fenn" <et...@polyspectral.com>

Date: Mon, March 28, 2016 11:43 am

To: music-dsp@music.columbia.edu

--



>> I suggest using ZDF (aka TPT, aka trapezoidal) state variable filter

>> instead.

>

>

> I don't know much about these yet -- but your book is on my list to read in

> the near future!

>
using the trapezoid rule to model/approximate the integrator of an analog 
filter is no different than applying bilinear transform (without compensation 
for frequency warping) to the same integrator.
�
� �s^(-1) �<--- � T/2 * (1 + z^(-1)) / (1 -
z^(-1))

--
r b-j � � � � � � � � �r...@audioimagination.com
"Imagination is more important than knowledge."


�
___
dupswapdrop: music-dsp mailing list
music-dsp@music.columbia.edu
https://lists.columbia.edu/mailman/listinfo/music-dsp

Re: [music-dsp] Changing Biquad filter coefficients on-the-fly, how to handle filter state?

2016-03-28 Thread Ethan Fenn
Hi Vadim,


IIRC, the problem with this form (as with Jordan normal form in principle)
> is that it gets ill-conditioned when the poles get close to each other
> (upon the first look I'm not sure where this ill-conditioning appears in
> your formulas, though, so I might be wrong there, or there could have been
> a mistake).


Thanks for pointing that out -- here I've assumed implicitly that 4*a2 >
a1^2... i.e. that the filter is in fact underdamped. As the poles move onto
the real axis, it becomes critically damped, and the oscillator
interpretation falls apart.

Mathematically, my sigma (which is simply twice the imaginary part of the
poles) goes to zero, and the 1/sigma terms blow up.

I suggest using ZDF (aka TPT, aka trapezoidal) state variable filter
> instead.


I don't know much about these yet -- but your book is on my list to read in
the near future!

Best,
Ethan



On Mon, Mar 28, 2016 at 8:31 AM, vadim.zavalishin <
vadim.zavalis...@native-instruments.de> wrote:

> Ethan Fenn писал 2016-03-25 20:57:
>
> oscillator. The update step looks like this:
>>
>> y := p + b0*x
>>
>> p := -(a1/2)*p + (sigma/2)*q + (b1 - a1*b0)*x
>> q := -(sigma/2)*p - (a1/2)*q + (1/sigma)*(2*b2 - 2*a2*b0 - a1*b1 +
>> a1^2*b0)*x
>>
>> Is there a name for this kind of representation?
>>
>
> This looks like a single (real) Jordan cell of a state-space form. Also,
> equivalently, I think "coupled form" oscillator is the name, where here
> it's explicitly excited to be used as a filter. Not sure if "magic circle"
> means the same.
>
> IIRC, the problem with this form (as with Jordan normal form in principle)
> is that it gets ill-conditioned when the poles get close to each other
> (upon the first look I'm not sure where this ill-conditioning appears in
> your formulas, though, so I might be wrong there, or there could have been
> a mistake). So, it's not very practical if the resonance may be low. I
> suggest using ZDF (aka TPT, aka trapezoidal) state variable filter instead.
>
> Regards,
> Vadim
>
> --
> Vadim Zavalishin
> Reaktor Application Architect | R
> Native Instruments GmbH
> +49-30-611035-0
>
> www.native-instruments.com
>
>
> ___
> dupswapdrop: music-dsp mailing list
> music-dsp@music.columbia.edu
> https://lists.columbia.edu/mailman/listinfo/music-dsp
>
___
dupswapdrop: music-dsp mailing list
music-dsp@music.columbia.edu
https://lists.columbia.edu/mailman/listinfo/music-dsp

Re: [music-dsp] Changing Biquad filter coefficients on-the-fly, how to handle filter state?

2016-03-28 Thread vadim.zavalishin

Ethan Fenn писал 2016-03-25 20:57:


oscillator. The update step looks like this:

y := p + b0*x

p := -(a1/2)*p + (sigma/2)*q + (b1 - a1*b0)*x
q := -(sigma/2)*p - (a1/2)*q + (1/sigma)*(2*b2 - 2*a2*b0 - a1*b1 +
a1^2*b0)*x

Is there a name for this kind of representation?


This looks like a single (real) Jordan cell of a state-space form. Also, 
equivalently, I think "coupled form" oscillator is the name, where here 
it's explicitly excited to be used as a filter. Not sure if "magic 
circle" means the same.


IIRC, the problem with this form (as with Jordan normal form in 
principle) is that it gets ill-conditioned when the poles get close to 
each other (upon the first look I'm not sure where this ill-conditioning 
appears in your formulas, though, so I might be wrong there, or there 
could have been a mistake). So, it's not very practical if the resonance 
may be low. I suggest using ZDF (aka TPT, aka trapezoidal) state 
variable filter instead.


Regards,
Vadim

--
Vadim Zavalishin
Reaktor Application Architect | R
Native Instruments GmbH
+49-30-611035-0

www.native-instruments.com

___
dupswapdrop: music-dsp mailing list
music-dsp@music.columbia.edu
https://lists.columbia.edu/mailman/listinfo/music-dsp

Re: [music-dsp] Changing Biquad filter coefficients on-the-fly, how to handle filter state?

2016-03-25 Thread Ethan Fenn
So the idea I mentioned earlier in this thread about matching signal value
and derivative didn't really turn out to make much sense when I tried it
out. But I did hit upon a topology that seems interesting. By changing the
basis of the state space and computing some new coefficients, a biquad can
be realized directly as an underdamped oscillator. The update step looks
like this:

y := p + b0*x
p := -(a1/2)*p + (sigma/2)*q + (b1 - a1*b0)*x
q := -(sigma/2)*p - (a1/2)*q + (1/sigma)*(2*b2 - 2*a2*b0 - a1*b1 +
a1^2*b0)*x

Here sigma=sqrt(4*a2 - a1^2), y is output sample, x is input sample. p and
q are the new state variables, and they represent the in-phase and
quadrature components of the oscillator.

Is there a name for this kind of representation?

The nice thing about this is that p and q have a natural interpretation --
by preserving them when changing filter coefficients you're preserving the
amplitude and phase of the oscillator.

If you have another type of filter topology but want to preserve the phase
and amplitude in this way, you can temporarily change basis to compute p
and q, then change back using the new filter coefficients. For example, for
a transposed direct form II filter this process looks like:

p := s1
q := (1/sigma)*(2*s2 - a1*s1)
s1' := p
s2' := (a1'/2)*p + (sigma'/2)*q

Here s1 and s2 are the state variables as defined in
https://ccrma.stanford.edu/~jos/fp/Transposed_Direct_Forms.html , and the
apostrophes represent the new coefficients/state after the filter change
takes place.

I'm not sure yet how useful this idea is in practice, but it sure was
interesting to work out!

-Ethan




On Fri, Mar 4, 2016 at 2:21 AM, Tom O'Hara  wrote:

>
> 4.  the only problem with the filter cross-fade scheme is knowing how long
>> to wait before you can ping-pong back to the other filter.  it's like you
>> have two filters running simultaneously on the same input with ostensibly
>> the same coefficients (most of the time) so their outputs should be the
>> same.  then you change the coefficients in the "inactive" filter, wait for
>> the transient to pass and then cross-fade over to it (which makes it the
>> "active" filter).  or you could slew the inactive filter to the target
>> values and wait a very little amount of time before cross-fading.  i
>> dunno.  sounds like that could work and i have never done it.
>>
>
> I copy the old coefficients and states to the spare filter, and new
> coefficients and states to the normal filter, then crossfade them at both
> the inputs and outputs using a sin/cos, as cos^2 + sin^2 = 1. As this is in
> a mixer, I have one spare filter for six normal filters, after the
> crossfade time the spare filter is freed.
>
> This works much better than just a linear fade at the outputs, which I
> have also done.
>
> I use a 10mS fade time.
>
> Tom
>
>
> ___
> dupswapdrop: music-dsp mailing list
> music-dsp@music.columbia.edu
> https://lists.columbia.edu/mailman/listinfo/music-dsp
>
>
___
dupswapdrop: music-dsp mailing list
music-dsp@music.columbia.edu
https://lists.columbia.edu/mailman/listinfo/music-dsp

Re: [music-dsp] Changing Biquad filter coefficients on-the-fly, how to handle filter state?

2016-03-03 Thread Tom O'Hara


4.  the only problem with the filter cross-fade scheme is knowing how 
long to wait before you can ping-pong back to the other filter.  it's 
like you have two filters running simultaneously on the same input 
with ostensibly the same coefficients (most of the time) so their 
outputs should be the same.  then you change the coefficients in the 
"inactive" filter, wait for the transient to pass and then cross-fade 
over to it (which makes it the "active" filter).  or you could slew 
the inactive filter to the target values and wait a very little amount 
of time before cross-fading.  i dunno.  sounds like that could work 
and i have never done it.


I copy the old coefficients and states to the spare filter, and new 
coefficients and states to the normal filter, then crossfade them at 
both the inputs and outputs using a sin/cos, as cos^2 + sin^2 = 1. As 
this is in a mixer, I have one spare filter for six normal filters, 
after the crossfade time the spare filter is freed.


This works much better than just a linear fade at the outputs, which I 
have also done.


I use a 10mS fade time.

Tom

___
dupswapdrop: music-dsp mailing list
music-dsp@music.columbia.edu
https://lists.columbia.edu/mailman/listinfo/music-dsp



Re: [music-dsp] Changing Biquad filter coefficients on-the-fly, how to handle filter state?

2016-03-03 Thread robert bristow-johnson

On 3/3/16 7:46 PM, Stefan Sullivan wrote:
I looked into this exact issue a little while ago. I found that my 
filters sounded better/worse depending on the biquad topology. 
Basically if your gaining your input going into states, then those 
states are more likely to be very far off from where they should be 
when you change the parameters. But if you're not doing that, it's 
pretty hard to notice any clicks that don't sound totally reasonable 
(e.g. instantaneously changing huge changes). Like everybody else has 
indicated, zeroing your states is definitely _not_ the best approach.


Other recommendations I heard (but didn't try) were: run two biquads 
in parallel, and interpolate between their outputs. Or, use other 
topologies altogether, although there's something to be said for how 
many tightly optimized biquad implementations there are in the world.




i gotta tightly optimized 5-coefficient Lattice running on a SHArC.  but 
it's more than twice the cost of a 5-coefficient Direct Form biquad.


--

r b-j  r...@audioimagination.com

"Imagination is more important than knowledge."



___
dupswapdrop: music-dsp mailing list
music-dsp@music.columbia.edu
https://lists.columbia.edu/mailman/listinfo/music-dsp



Re: [music-dsp] Changing Biquad filter coefficients on-the-fly, how to handle filter state?

2016-03-03 Thread Stefan Sullivan
I looked into this exact issue a little while ago. I found that my filters
sounded better/worse depending on the biquad topology. Basically if your
gaining your input going into states, then those states are more likely to
be very far off from where they should be when you change the parameters.
But if you're not doing that, it's pretty hard to notice any clicks that
don't sound totally reasonable (e.g. instantaneously changing huge
changes). Like everybody else has indicated, zeroing your states is
definitely _not_ the best approach.

Other recommendations I heard (but didn't try) were: run two biquads in
parallel, and interpolate between their outputs. Or, use other topologies
altogether, although there's something to be said for how many tightly
optimized biquad implementations there are in the world.

-stefan

On Thu, Mar 3, 2016 at 4:40 PM, robert bristow-johnson <
r...@audioimagination.com> wrote:

> On 3/3/16 7:23 PM, robert bristow-johnson wrote:
>
>>
>> 6.  another form to consider is the Lattice or, if you're doing it in
>> fixed-point, the Normalized Ladder form.  these are all second-order so
>> they all have the same transfer function and you can calculate coefficients
>> as a function of Cookbook coefs or from emulating an analog circuit with
>> trapezoid-integration or Euler's forward method or Euler's backward method
>> or predictor-corrector or whatever source of your heart's desire.  so you
>> can have Andrew's or Hal's or Andy Moorer's or Stanley Whites or
>> harris-Brooking's or Massie's or Regalia-Mitra's or whatever definition of
>> a second-order IIR filter you like.
>>
>
> forgot to mention Orfanidis's and Knud Christenson's coefficient
> definitions...
>
>   that is an orthogonal issue.  but, if you really wanna crank on the
>> knobs (perhaps with an LFO for tremolo/vibrato), i would do this with a
>> Lattice filter because it decouples the Q from one of the pole coefficients
>> (k2) which means it depends only on the resonant frequency.  there is an
>> LPF output tap and an APF output tap and a tap in between (dunno what i
>> would call it) and you can combine those three taps in any arbitrary way
>> and get any arbitrary numerator to your biquad transfer function.  but i
>> think that the slewing/stabilty behavior of a Lattice is better than that
>> of any other filter topology that i have tried.
>>
>>
> --
>
> r b-j  r...@audioimagination.com
>
> "Imagination is more important than knowledge."
>
>
>
> ___
> dupswapdrop: music-dsp mailing list
> music-dsp@music.columbia.edu
> https://lists.columbia.edu/mailman/listinfo/music-dsp
>
>
___
dupswapdrop: music-dsp mailing list
music-dsp@music.columbia.edu
https://lists.columbia.edu/mailman/listinfo/music-dsp

Re: [music-dsp] Changing Biquad filter coefficients on-the-fly, how to handle filter state?

2016-03-03 Thread robert bristow-johnson

On 3/3/16 7:23 PM, robert bristow-johnson wrote:


6.  another form to consider is the Lattice or, if you're doing it in 
fixed-point, the Normalized Ladder form.  these are all second-order 
so they all have the same transfer function and you can calculate 
coefficients as a function of Cookbook coefs or from emulating an 
analog circuit with trapezoid-integration or Euler's forward method or 
Euler's backward method or predictor-corrector or whatever source of 
your heart's desire.  so you can have Andrew's or Hal's or Andy 
Moorer's or Stanley Whites or harris-Brooking's or Massie's or 
Regalia-Mitra's or whatever definition of a second-order IIR filter 
you like.


forgot to mention Orfanidis's and Knud Christenson's coefficient 
definitions...


  that is an orthogonal issue.  but, if you really wanna crank on the 
knobs (perhaps with an LFO for tremolo/vibrato), i would do this with 
a Lattice filter because it decouples the Q from one of the pole 
coefficients (k2) which means it depends only on the resonant 
frequency.  there is an LPF output tap and an APF output tap and a tap 
in between (dunno what i would call it) and you can combine those 
three taps in any arbitrary way and get any arbitrary numerator to 
your biquad transfer function.  but i think that the slewing/stabilty 
behavior of a Lattice is better than that of any other filter topology 
that i have tried.




--

r b-j  r...@audioimagination.com

"Imagination is more important than knowledge."



___
dupswapdrop: music-dsp mailing list
music-dsp@music.columbia.edu
https://lists.columbia.edu/mailman/listinfo/music-dsp



Re: [music-dsp] Changing Biquad filter coefficients on-the-fly, how to handle filter state?

2016-03-03 Thread robert bristow-johnson


so i read Jean Laroche's paper in the previous decade and i forget what 
the takeaway was from it besides i thought he had a good model for 
describing the non-TI in the LTI.  had to do with calculation of the 
states in a way that made an equivalent filter but with possibly 
unstable conditions.  i just forgot how he modeled it.


the Ethan's have an interesting take on this.  you could say that "let's 
adjust the states to that it would be the same thing whether the 
coefficients were moved or not"  and you can model it as the value of 
one state and the difference between it and the previous state and that 
would cover a DF2 biquad.


there's a few different issues going on here about calculating varying 
coefficients.  it depends on what's being slewed and how're you're 
slewing it.


1.  if you're slewing reasonably slowly so that the effects Laroche was 
writing about is less of a problem, the if the slewing has no overshoot, 
you cannot slew from one stable biquad to another stable biquad and slew 
through unstable territory.  for a resonant biquad the stability depends 
solely on the a2 coefficient and as long as it's less than 1, the filter 
is stable for any stationary values in between.


2.  biquad coefficients usually get "cooked" from the user-supplied 
parameters with some math that is not linear.  so it might make a 
difference between setting target user parameters (during the foreground 
process in response to someone turning a knob) and slewing toward them 
(and continually recalculating the coefs from the changing parameters 
on-the-fly) or steping to the target user parameters directly, 
calculating the target coefficients from that, and slewing the 
coefficients themselves toward their targets.


3.  there are in-between strategies.  some of us process samples in 
blocks of samples.  i personally like blocks of 32 because it's large 
enough that the amortization of overhead (like setup of pointers and 
coefs and loading and storing of states) is effective (it's divided by 
32) and the delay (two block periods or 64 samples) is not much worse 
than a millisecond.  you can calculate target coefficients *once* at the 
beginning of the block and slew the current coefficients toward their 
targets on a sample-by-sample basis.  this behaves better and costs more 
for smaller sample blocks.


4.  the only problem with the filter cross-fade scheme is knowing how 
long to wait before you can ping-pong back to the other filter.  it's 
like you have two filters running simultaneously on the same input with 
ostensibly the same coefficients (most of the time) so their outputs 
should be the same.  then you change the coefficients in the "inactive" 
filter, wait for the transient to pass and then cross-fade over to it 
(which makes it the "active" filter).  or you could slew the inactive 
filter to the target values and wait a very little amount of time before 
cross-fading.  i dunno.  sounds like that could work and i have never 
done it.


5.  the Cookbook is cheap.  that's why it's free.  Direct Form biquads 
are cheap (in instruction cycles).  cheaper than other forms, of which 
Andrew's SVF or Hal's SVF are two forms that are more expensive than DF1 
or DF2 and, while they cannot have a different static output from a DF1 
or DF2 for the LTI case (strictly-speaking an LTI must be forever 
static) with double-precision words.  but these different forms *do* 
behave differently when parameters change and also regarding 
quantization noise, if the word-width ain't so wide.


6.  another form to consider is the Lattice or, if you're doing it in 
fixed-point, the Normalized Ladder form.  these are all second-order so 
they all have the same transfer function and you can calculate 
coefficients as a function of Cookbook coefs or from emulating an analog 
circuit with trapezoid-integration or Euler's forward method or Euler's 
backward method or predictor-corrector or whatever source of your 
heart's desire.  so you can have Andrew's or Hal's or Andy Moorer's or 
Stanley Whites or harris-Brooking's or Massie's or Regalia-Mitra's or 
whatever definition of a second-order IIR filter you like.  that is an 
orthogonal issue.  but, if you really wanna crank on the knobs (perhaps 
with an LFO for tremolo/vibrato), i would do this with a Lattice filter 
because it decouples the Q from one of the pole coefficients (k2) which 
means it depends only on the resonant frequency.  there is an LPF output 
tap and an APF output tap and a tap in between (dunno what i would call 
it) and you can combine those three taps in any arbitrary way and get 
any arbitrary numerator to your biquad transfer function.  but i think 
that the slewing/stabilty behavior of a Lattice is better than that of 
any other filter topology that i have tried.


that's my spin on the story and i'm sticking to it, until i hear a 
better spin on it.


r b-j



On 3/3/16 4:23 PM, Ethan Fenn wrote:


I'm not sure quite how this would work 

Re: [music-dsp] Changing Biquad filter coefficients on-the-fly, how to handle filter state?

2016-03-03 Thread Ethan Fenn
>
> I'm not sure quite how this would work for discrete time? Is the idea to
> interpret them as continuous-time filters for the purposes of the state
> update?


I wasn't really thinking about them as continuous-time filters, but
considering the output as a continuous-time signal. Specifically, during
ring-out our signal is a sum of two exponentials. After the filter swap the
signal will be a sum of two different exponentials. By choosing our new
state variables carefully we should be able to match of the value and first
derivative at the join.

I guess the gist of the idea is: the state space is two-dimensional, but we
have many choices of basis vectors for the space, many ways of describing a
state using two values (of course we can also describe it using more
redundant values, as in the case of a DF I filter). And what I'm proposing
is that the most natural way to describe the state, which can be
transferred to a new filter design without transients, is "current value
we'll output assuming no input" and "current derivative of the output
assuming no input."

-Ethan




On Thu, Mar 3, 2016 at 3:46 PM, Ethan Duni  wrote:

> Yeah zeroing out the state is going to lead to a transient, since the
> filter has to ring up.
>
> If you want to go that route, one possibility is to use two filters in
> parallel: one that keeps the old state/coeffs but gets zero input, and
> another that has zero state and gets the new input/coeffs. You then add
> their outputs together, combining the ring-out of the old state/coeffs with
> the ring-up of the new coeffs/input. This is the zero-state/zero-input
> decomposition. However this can still result in transient artifacts if the
> filter has changed a lot (i.e., the old coeffs might have a short ring-out
> time, but the new ones have a long ring-up time, or vice versa). And if
> your coeffs aren't changing much, then probably you can get away with more
> direct methods. But a worthwhile exercise for theoretical edification, I
> think.
>
> Another thing to consider is how to interpret the state variables for
> different filter topologies. If you use Direct Form I then the state
> variables are simply the previous inputs and outputs to/from the filter,
> which still make sense if you change the coeffs. Other topologies have
> state variables that corresponds to history samples multiplied by the
> coeffs, so when you change the coeffs they cease to make sense and you have
> problems. If any of the coeffs are 0 you lose info and then can't "convert"
> to the state corresponding to a different set of coeffs. Not that Direct
> Form I is immune to artifacts when you change the coeffs, but they tend to
> be much less severe than other topologies for a given set of coeffs/inputs.
> This is because it's only a matter of the coefficient mismatch, and not the
> additional factor of the state interpretation mismatch.
>
> >Now if we're going to change to new filter coefficients, we have two
> degrees of freedom
> >in the state space. A reasonable goal seems to be to match the value and
> derivative of
> >the output after we change the coefficients.
>
> I'm not sure quite how this would work for discrete time? Is the idea to
> interpret them as continuous-time filters for the purposes of the state
> update?
>
> E
>
> On Thu, Mar 3, 2016 at 11:34 AM, Ethan Fenn 
> wrote:
>
>> As a simple fix, I would also try just leaving the state alone rather
>> than zeroing it out. I've done this plenty of times before and it's always
>> sounded okay for moderate/gradual changes of the coefficients.
>>
>> As for doing it "correctly" -- I haven't read up on this but my thinking
>> would go like so... let's suppose we have a biquad in a free ringing state,
>> no longer receiving any input. Its output will be a sum of two complex
>> exponentials. Given the current state variables, we can compute the
>> weighting of these two exponentials, giving us the current value and first
>> derivative of the output.
>>
>> Now if we're going to change to new filter coefficients, we have two
>> degrees of freedom in the state space. A reasonable goal seems to be to
>> match the value and derivative of the output after we change the
>> coefficients. So we can perform the same analysis with the new
>> coefficients, getting new exponents in the output. We can figure out what
>> new state variables will give us the desired match. I haven't done the math
>> yet but I don't see any complications and this would give us a matrix
>> mapping old state variables to new ones.
>>
>> Is this the kind of reasoning I would find in the references, or is there
>> a better way to think about this?
>>
>> -Ethan
>>
>>
>>
>> On Wed, Mar 2, 2016 at 12:49 PM, Theo Verelst 
>> wrote:
>>
>>> Paul Stoffregen wrote:
>>>
 Does anyone have any suggestions or publications or references to best
 practices for what
 to do with the state variables of a biquad filter when 

Re: [music-dsp] Changing Biquad filter coefficients on-the-fly, how to handle filter state?

2016-03-03 Thread Ethan Duni
Yeah zeroing out the state is going to lead to a transient, since the
filter has to ring up.

If you want to go that route, one possibility is to use two filters in
parallel: one that keeps the old state/coeffs but gets zero input, and
another that has zero state and gets the new input/coeffs. You then add
their outputs together, combining the ring-out of the old state/coeffs with
the ring-up of the new coeffs/input. This is the zero-state/zero-input
decomposition. However this can still result in transient artifacts if the
filter has changed a lot (i.e., the old coeffs might have a short ring-out
time, but the new ones have a long ring-up time, or vice versa). And if
your coeffs aren't changing much, then probably you can get away with more
direct methods. But a worthwhile exercise for theoretical edification, I
think.

Another thing to consider is how to interpret the state variables for
different filter topologies. If you use Direct Form I then the state
variables are simply the previous inputs and outputs to/from the filter,
which still make sense if you change the coeffs. Other topologies have
state variables that corresponds to history samples multiplied by the
coeffs, so when you change the coeffs they cease to make sense and you have
problems. If any of the coeffs are 0 you lose info and then can't "convert"
to the state corresponding to a different set of coeffs. Not that Direct
Form I is immune to artifacts when you change the coeffs, but they tend to
be much less severe than other topologies for a given set of coeffs/inputs.
This is because it's only a matter of the coefficient mismatch, and not the
additional factor of the state interpretation mismatch.

>Now if we're going to change to new filter coefficients, we have two
degrees of freedom
>in the state space. A reasonable goal seems to be to match the value and
derivative of
>the output after we change the coefficients.

I'm not sure quite how this would work for discrete time? Is the idea to
interpret them as continuous-time filters for the purposes of the state
update?

E

On Thu, Mar 3, 2016 at 11:34 AM, Ethan Fenn  wrote:

> As a simple fix, I would also try just leaving the state alone rather than
> zeroing it out. I've done this plenty of times before and it's always
> sounded okay for moderate/gradual changes of the coefficients.
>
> As for doing it "correctly" -- I haven't read up on this but my thinking
> would go like so... let's suppose we have a biquad in a free ringing state,
> no longer receiving any input. Its output will be a sum of two complex
> exponentials. Given the current state variables, we can compute the
> weighting of these two exponentials, giving us the current value and first
> derivative of the output.
>
> Now if we're going to change to new filter coefficients, we have two
> degrees of freedom in the state space. A reasonable goal seems to be to
> match the value and derivative of the output after we change the
> coefficients. So we can perform the same analysis with the new
> coefficients, getting new exponents in the output. We can figure out what
> new state variables will give us the desired match. I haven't done the math
> yet but I don't see any complications and this would give us a matrix
> mapping old state variables to new ones.
>
> Is this the kind of reasoning I would find in the references, or is there
> a better way to think about this?
>
> -Ethan
>
>
>
> On Wed, Mar 2, 2016 at 12:49 PM, Theo Verelst  wrote:
>
>> Paul Stoffregen wrote:
>>
>>> Does anyone have any suggestions or publications or references to best
>>> practices for what
>>> to do with the state variables of a biquad filter when changing the
>>> coefficients?
>>> ...
>>>
>>
>> I am not directly familiar with the programming of the particular biquad
>> filter variation, but some others, and like many have said, I suspect that
>> varying the external cutoff and/or resonance control, computing the effects
>> on the various filter coefficients, and essentially not making any changes
>> across some sort of singularity (if there is one), or overly rapid changes,
>> should leave the audio running through fine.
>>
>> The state variable filter theory and origins in the use of audio
>> equipment like the early analog synthesizers isn't exactly the same as the
>> digital implementations, so there are things to consider more accurately if
>> you want them wonderful sweeping resonant filter sounds on a sound source:
>> there are non-linearities for instance in a Moog ladder filter, and the
>> "state" which is remembered in an analog filter in the capacitors, gets
>> warped when the voltage controls change. A mostly linearized digital filter
>> simulation will probably not automatically exhibit the same behavior as the
>> well known analog filters. Also, all kinds signal subtleties are lost in
>> the approximation by sampling the time axis, which may or may not be a
>> problem.
>>
>> I looked at the 

Re: [music-dsp] Changing Biquad filter coefficients on-the-fly, how to handle filter state?

2016-03-03 Thread Ethan Fenn
As a simple fix, I would also try just leaving the state alone rather than
zeroing it out. I've done this plenty of times before and it's always
sounded okay for moderate/gradual changes of the coefficients.

As for doing it "correctly" -- I haven't read up on this but my thinking
would go like so... let's suppose we have a biquad in a free ringing state,
no longer receiving any input. Its output will be a sum of two complex
exponentials. Given the current state variables, we can compute the
weighting of these two exponentials, giving us the current value and first
derivative of the output.

Now if we're going to change to new filter coefficients, we have two
degrees of freedom in the state space. A reasonable goal seems to be to
match the value and derivative of the output after we change the
coefficients. So we can perform the same analysis with the new
coefficients, getting new exponents in the output. We can figure out what
new state variables will give us the desired match. I haven't done the math
yet but I don't see any complications and this would give us a matrix
mapping old state variables to new ones.

Is this the kind of reasoning I would find in the references, or is there a
better way to think about this?

-Ethan



On Wed, Mar 2, 2016 at 12:49 PM, Theo Verelst  wrote:

> Paul Stoffregen wrote:
>
>> Does anyone have any suggestions or publications or references to best
>> practices for what
>> to do with the state variables of a biquad filter when changing the
>> coefficients?
>> ...
>>
>
> I am not directly familiar with the programming of the particular biquad
> filter variation, but some others, and like many have said, I suspect that
> varying the external cutoff and/or resonance control, computing the effects
> on the various filter coefficients, and essentially not making any changes
> across some sort of singularity (if there is one), or overly rapid changes,
> should leave the audio running through fine.
>
> The state variable filter theory and origins in the use of audio equipment
> like the early analog synthesizers isn't exactly the same as the digital
> implementations, so there are things to consider more accurately if you
> want them wonderful sweeping resonant filter sounds on a sound source:
> there are non-linearities for instance in a Moog ladder filter, and the
> "state" which is remembered in an analog filter in the capacitors, gets
> warped when the voltage controls change. A mostly linearized digital filter
> simulation will probably not automatically exhibit the same behavior as the
> well known analog filters. Also, all kinds signal subtleties are lost in
> the approximation by sampling the time axis, which may or may not be a
> problem.
>
> I looked at the code quickly, couldn't find the "definition" datastructure
> definition in the .h file and didn't look much further, but I suppose you
> should use the part where you initially compute all the (5?) coefficients
> you use from the biquad filter again to gradually change the coefficient of
> the actual filter code. I do not know what the relation is between the
> biquad coefficients (at sufficiently high sampling frequency) and the
> equivalent analog "state" of the filter. Maybe someone else knows how the
> biquads behave in that comparison.
>
> T.
>
>
> ___
> dupswapdrop: music-dsp mailing list
> music-dsp@music.columbia.edu
> https://lists.columbia.edu/mailman/listinfo/music-dsp
>
>
___
dupswapdrop: music-dsp mailing list
music-dsp@music.columbia.edu
https://lists.columbia.edu/mailman/listinfo/music-dsp

Re: [music-dsp] Changing Biquad filter coefficients on-the-fly, how to handle filter state?

2016-03-02 Thread Theo Verelst

Paul Stoffregen wrote:

Does anyone have any suggestions or publications or references to best 
practices for what
to do with the state variables of a biquad filter when changing the 
coefficients?
...


I am not directly familiar with the programming of the particular biquad filter variation, 
but some others, and like many have said, I suspect that varying the external cutoff 
and/or resonance control, computing the effects on the various filter coefficients, and 
essentially not making any changes across some sort of singularity (if there is one), or 
overly rapid changes, should leave the audio running through fine.


The state variable filter theory and origins in the use of audio equipment like the early 
analog synthesizers isn't exactly the same as the digital implementations, so there are 
things to consider more accurately if you want them wonderful sweeping resonant filter 
sounds on a sound source: there are non-linearities for instance in a Moog ladder filter, 
and the "state" which is remembered in an analog filter in the capacitors, gets warped 
when the voltage controls change. A mostly linearized digital filter simulation will 
probably not automatically exhibit the same behavior as the well known analog filters. 
Also, all kinds signal subtleties are lost in the approximation by sampling the time axis, 
which may or may not be a problem.


I looked at the code quickly, couldn't find the "definition" datastructure definition in 
the .h file and didn't look much further, but I suppose you should use the part where you 
initially compute all the (5?) coefficients you use from the biquad filter again to 
gradually change the coefficient of the actual filter code. I do not know what the 
relation is between the biquad coefficients (at sufficiently high sampling frequency) and 
the equivalent analog "state" of the filter. Maybe someone else knows how the biquads 
behave in that comparison.


T.

___
dupswapdrop: music-dsp mailing list
music-dsp@music.columbia.edu
https://lists.columbia.edu/mailman/listinfo/music-dsp



Re: [music-dsp] Changing Biquad filter coefficients on-the-fly, how to handle filter state?

2016-03-01 Thread Phil Burk
I use biquads in JSyn. The coefficients are calculated using RBJ's
excellent biquad cookbook from the music-dsp archives.

I have found that I can recalculate and update the filter coefficients on
the fly without unpleasant artifacts. I do NOT zero out or modify the
internal state variables. I should think that setting them to zero would
sound pretty bad.

Generally the filter settings are changed gradually using a knob or driven
by an LFO or envelope.

Phil Burk


On Tue, Mar 1, 2016 at 6:56 AM, Paul Stoffregen  wrote:

> Does anyone have any suggestions or publications or references to best
> practices for what to do with the state variables of a biquad filter when
> changing the coefficients?
>
> For a bit of background, I implement a Biquad Direct Form 1 filter in this
> audio library.  It works well.
>
> https://github.com/PaulStoffregen/Audio/blob/master/filter_biquad.cpp#L94
>
> There's a function which allows the user to change the 5 coefficients.
> Lines 94 & 95 set the 4 filter state variables (which are 16 bits, packed
> into two 32 bit integers) to zero.  I did this clear-to-zero out of an
> abundance of caution, for concern (maybe paranoia) that a stable filter
> might do something unexpected or unstable if the 4 state variables are
> initialized with non-zero values.
>
> The problem is people wish to change the coefficients in real time with as
> little audible artifact as possible between the old and new filter
> response.  Clearing the state to zero usually results in a very noticeable
> click or pop sound.
>
> https://github.com/PaulStoffregen/Audio/issues/171
>
> Am I just being overly paranoid by setting all 4 state variables to zero?
> If "bad things" could happen, are there any guidelines about how to manage
> the filter state safely, but with with as graceful a transition as possible?
>
>
>
> ___
> dupswapdrop: music-dsp mailing list
> music-dsp@music.columbia.edu
> https://lists.columbia.edu/mailman/listinfo/music-dsp
>
>
___
dupswapdrop: music-dsp mailing list
music-dsp@music.columbia.edu
https://lists.columbia.edu/mailman/listinfo/music-dsp

Re: [music-dsp] Changing Biquad filter coefficients on-the-fly, how to handle filter state?

2016-03-01 Thread Laurent de Soras

Paul Stoffregen wrote:


Does anyone have any suggestions or publications or references to best
practices for what to do with the state variables of a biquad filter
when changing the coefficients?


Use an implementation designed to handle nicely coefficient
changes. For example the trapezoidal SVF:



___
dupswapdrop: music-dsp mailing list
music-dsp@music.columbia.edu
https://lists.columbia.edu/mailman/listinfo/music-dsp



Re: [music-dsp] Changing Biquad filter coefficients on-the-fly, how to handle filter state?

2016-03-01 Thread Bjorn Roche
This is a common and well-researched problem. The two solutions are usually:

1. cross-fade between two filter settings (this actually works reasonably
well)
2. use a filter architecture that is guaranteed to be stable for
intermediate states. (e.g., I believe lattice filters have this property,
but I'm a bit rusty)

bjorn


On Tue, Mar 1, 2016 at 9:56 AM, Paul Stoffregen  wrote:

> Does anyone have any suggestions or publications or references to best
> practices for what to do with the state variables of a biquad filter when
> changing the coefficients?
>
> For a bit of background, I implement a Biquad Direct Form 1 filter in this
> audio library.  It works well.
>
> https://github.com/PaulStoffregen/Audio/blob/master/filter_biquad.cpp#L94
>
> There's a function which allows the user to change the 5 coefficients.
> Lines 94 & 95 set the 4 filter state variables (which are 16 bits, packed
> into two 32 bit integers) to zero.  I did this clear-to-zero out of an
> abundance of caution, for concern (maybe paranoia) that a stable filter
> might do something unexpected or unstable if the 4 state variables are
> initialized with non-zero values.
>
> The problem is people wish to change the coefficients in real time with as
> little audible artifact as possible between the old and new filter
> response.  Clearing the state to zero usually results in a very noticeable
> click or pop sound.
>
> https://github.com/PaulStoffregen/Audio/issues/171
>
> Am I just being overly paranoid by setting all 4 state variables to zero?
> If "bad things" could happen, are there any guidelines about how to manage
> the filter state safely, but with with as graceful a transition as possible?
>
>
>
> ___
> dupswapdrop: music-dsp mailing list
> music-dsp@music.columbia.edu
> https://lists.columbia.edu/mailman/listinfo/music-dsp
>
>


-- 
Bjorn Roche
@shimmeoapp
___
dupswapdrop: music-dsp mailing list
music-dsp@music.columbia.edu
https://lists.columbia.edu/mailman/listinfo/music-dsp

Re: [music-dsp] Changing Biquad filter coefficients on-the-fly, how to handle filter state?

2016-03-01 Thread Ivan Cohen
Have a look also for the book "the art of virtual analog filter design" 
by Vadim Zavalishin. It provides a new structure for simulating state 
variable filters especially suited for time varying cases.


Ivan

MusicalEntropy.com 
Blog  | Twitter 
 | Facebook 



Le 01/03/2016 16:16, pdowling a écrit :

yes - don’t use biquads :-)


On 1 Mar 2016, at 14:56, Paul Stoffregen  wrote:


Does anyone have any suggestions or publications or references to best 
practices for what to do with the state variables of a biquad filter when 
changing the coefficients?

For a bit of background, I implement a Biquad Direct Form 1 filter in this 
audio library.  It works well.

https://github.com/PaulStoffregen/Audio/blob/master/filter_biquad.cpp#L94

There's a function which allows the user to change the 5 coefficients.  Lines 94 
& 95 set the 4 filter state variables (which are 16 bits, packed into two 32 
bit integers) to zero.  I did this clear-to-zero out of an abundance of caution, 
for concern (maybe paranoia) that a stable filter might do something unexpected or 
unstable if the 4 state variables are initialized with non-zero values.

The problem is people wish to change the coefficients in real time with as 
little audible artifact as possible between the old and new filter response.  
Clearing the state to zero usually results in a very noticeable click or pop 
sound.

https://github.com/PaulStoffregen/Audio/issues/171

Am I just being overly paranoid by setting all 4 state variables to zero?  If "bad 
things" could happen, are there any guidelines about how to manage the filter state 
safely, but with with as graceful a transition as possible?



___
dupswapdrop: music-dsp mailing list
music-dsp@music.columbia.edu
https://lists.columbia.edu/mailman/listinfo/music-dsp


___
dupswapdrop: music-dsp mailing list
music-dsp@music.columbia.edu
https://lists.columbia.edu/mailman/listinfo/music-dsp




___
dupswapdrop: music-dsp mailing list
music-dsp@music.columbia.edu
https://lists.columbia.edu/mailman/listinfo/music-dsp

Re: [music-dsp] Changing Biquad filter coefficients on-the-fly, how to handle filter state?

2016-03-01 Thread pdowling
yes - don’t use biquads :-)


On 1 Mar 2016, at 14:56, Paul Stoffregen  wrote:

> Does anyone have any suggestions or publications or references to best 
> practices for what to do with the state variables of a biquad filter when 
> changing the coefficients?
> 
> For a bit of background, I implement a Biquad Direct Form 1 filter in this 
> audio library.  It works well.
> 
> https://github.com/PaulStoffregen/Audio/blob/master/filter_biquad.cpp#L94
> 
> There's a function which allows the user to change the 5 coefficients.  Lines 
> 94 & 95 set the 4 filter state variables (which are 16 bits, packed into two 
> 32 bit integers) to zero.  I did this clear-to-zero out of an abundance of 
> caution, for concern (maybe paranoia) that a stable filter might do something 
> unexpected or unstable if the 4 state variables are initialized with non-zero 
> values.
> 
> The problem is people wish to change the coefficients in real time with as 
> little audible artifact as possible between the old and new filter response.  
> Clearing the state to zero usually results in a very noticeable click or pop 
> sound.
> 
> https://github.com/PaulStoffregen/Audio/issues/171
> 
> Am I just being overly paranoid by setting all 4 state variables to zero?  If 
> "bad things" could happen, are there any guidelines about how to manage the 
> filter state safely, but with with as graceful a transition as possible?
> 
> 
> 
> ___
> dupswapdrop: music-dsp mailing list
> music-dsp@music.columbia.edu
> https://lists.columbia.edu/mailman/listinfo/music-dsp
> 

___
dupswapdrop: music-dsp mailing list
music-dsp@music.columbia.edu
https://lists.columbia.edu/mailman/listinfo/music-dsp



Re: [music-dsp] Changing Biquad filter coefficients on-the-fly, how to handle filter state?

2016-03-01 Thread Giulio Moro
Have a look at these
G. Stoyanov and M. Kawamata, “Variable digital filters,” J.Signal Processing, 
vol. 1, no. 4, pp. 275–289, 1997.

J. Laroche, “On the stability of time-varying recursive filters,”Journal of the 
Audio Engineering Society, vol. 55, no.6, pp. 460–471, 2007. 
V. Välimäki and T.I. Laakso, “Suppression of transients intime-varying 
recursive filters for audio signals,” in Proceedingsof the 1998 IEEE 
International Conference on Acoustics,Speech and Signal Processing, 1998, May 
1998, vol. 6,pp. 3569–3572 vol.6. 
A. Wishnick, “Time-varying filters for musical applications,”in Proceedings of 
the 17th International Conference on DigitalAudio Effects (DAFx-14), 2014, pp. 
69–76.



 
  From: Paul Stoffregen 
 To: music-dsp@music.columbia.edu 
 Sent: Tuesday, 1 March 2016, 14:56
 Subject: [music-dsp] Changing Biquad filter coefficients on-the-fly, how to 
handle filter state?
   
Does anyone have any suggestions or publications or references to best 
practices for what to do with the state variables of a biquad filter 
when changing the coefficients?

For a bit of background, I implement a Biquad Direct Form 1 filter in 
this audio library.  It works well.

https://github.com/PaulStoffregen/Audio/blob/master/filter_biquad.cpp#L94

There's a function which allows the user to change the 5 coefficients.  
Lines 94 & 95 set the 4 filter state variables (which are 16 bits, 
packed into two 32 bit integers) to zero.  I did this clear-to-zero out 
of an abundance of caution, for concern (maybe paranoia) that a stable 
filter might do something unexpected or unstable if the 4 state 
variables are initialized with non-zero values.

The problem is people wish to change the coefficients in real time with 
as little audible artifact as possible between the old and new filter 
response.  Clearing the state to zero usually results in a very 
noticeable click or pop sound.

https://github.com/PaulStoffregen/Audio/issues/171

Am I just being overly paranoid by setting all 4 state variables to 
zero?  If "bad things" could happen, are there any guidelines about how 
to manage the filter state safely, but with with as graceful a 
transition as possible?



___
dupswapdrop: music-dsp mailing list
music-dsp@music.columbia.edu
https://lists.columbia.edu/mailman/listinfo/music-dsp



   
___
dupswapdrop: music-dsp mailing list
music-dsp@music.columbia.edu
https://lists.columbia.edu/mailman/listinfo/music-dsp