Hi everyone,
when working with GEM (and probably with pd in general), one comes inevitably to the point where input parameters need to be interpolated to make the output looking / sounding halfway good - as a prominent example, using cc's from a midi controller to rotate an object around its axis in GEM will look really ugly (the minimum change will be 360°/128 = a little less than 3 degrees, resulting in jerky leaps). Thomas Grill proposed using pd's built-in dsp filter (lop~ in particular) to do the smoothing, this is a technique which elegance I really admire (although I must admit that I don't unterstand completely how it actually works). It has a serious drawback, however: it interpolates everything, even sudden parameter jumps that would be better passed through unchanged - imagine the following scenario: a geo is constantly rotated by a counter that rolls over at 360 degrees. Now, the lop~ filter interpolates this change that really is a jump by spitting out some values in between 360 and 0 degrees, which will make the result look jerky again when the rollover occurs. I tried to work around this behaviour by filtering these values out or setting the cutoff frequency of the filter during the rollover really high which causes it not to interpolate anymore but ran into timing issues ... to do it the right way, one probably would have to switch over to another lop~-abstraction during the rollover, which seems a bit like overkill to me. Additionally, someone stated on the list that filtering in the dsp domain does require a fair amount of cpu cycles.
So, at the end of this lengthy post:
abstraction with a "set x"-message that would cause it to start interpolating from the x-value ? How demanding (in terms of cpu cycles) would that abstraction then be?
does non-linear smoothing of yet-unknown parameters and detects parameter jumps? My math is a bit rusty, and googling only yielded stuff regarding the interpolation of _known_ values.
Thank you very much in advance, Thoralf.
How much free photo storage do you get? Store your holiday snaps for FREE with Yahoo! Photos http://uk.photos.yahoo.com
Thoralf Schulze wrote:
Hi everyone,
So, at the end of this lengthy post:
- is there a possibility to amend Thomas' smoothing
abstraction with a "set x"-message that would cause it to start interpolating from the x-value ? How demanding (in terms of cpu cycles) would that abstraction then be?
i don't think that you can use soemthing like "set <f>" with dsp-filters.
- if not: is there an easy-to-implement algorithm that
does non-linear smoothing of yet-unknown parameters and detects parameter jumps? My math is a bit rusty, and googling only yielded stuff regarding the interpolation of _known_ values.
now that'll be cool: doing interpolation between (however yet) unknown values. i guess this would solve many many problems.
a simple non-linear (IIR) low-pass filter is x[n]=a*x[n-1]+(1-a)*y[n] (with 0<=a<=1)
however, this filter still only works for known values to filter.
apart from that, your problem is basically about unwrapping your incoming values [0..360] to something covering all values; if you have a series that goes 0..89..188..267..356..85 you want it to become 0..89..188..267..356..445
attached is a file that unwraps degree-values. it depends on zexy's [wrap] (because this was faster to do), but you can replace wrap with something build with [%]. the basic idea is to wrap the difference between to consecutive values and sum it up again.
mfg.a.sdr IOhannes
#N canvas 408 256 699 358 10; #N canvas 0 0 450 300 unwrap 0; #X obj 139 128 f; #X obj 139 199 wrap -180 180; #X obj 139 243 t f f; #X obj 139 151 t f f; #X obj 139 175 -; #X obj 139 220 +; #X obj 139 104 inlet; #X obj 139 268 outlet; #X connect 0 0 3 0; #X connect 1 0 5 0; #X connect 2 0 7 0; #X connect 2 1 5 1; #X connect 3 0 4 1; #X connect 3 1 4 0; #X connect 4 0 1 0; #X connect 5 0 2 0; #X connect 6 0 0 0; #X restore 117 137 pd unwrap; #X floatatom 117 66 5 0 0 0 - - -; #X floatatom 117 117 5 0 0 0 - - -; #X floatatom 117 161 5 0 0 0 - - -; #X text 180 91 to get jumps; #X text 191 138 this is using zexy's [wrap] , but you can do it with core pd objects too.; #X obj 117 90 wrap 360; #X connect 0 0 3 0; #X connect 1 0 6 0; #X connect 2 0 0 0; #X connect 6 0 2 0;
Hi Johannes, hi list,
i don't think that you can use soemthing like "set <f>" with dsp-filters.
bad news ...
now that'll be cool: doing interpolation between (however yet) unknown values. i guess this would solve many many problems.
Yeah. Perfect knowledge of the future is a good thing.
Let's throw probability on the garbage dump ...
Seriously, the mail I wrote yesterday didn't make much
sense, it was a hot day here :-).
I'll try to reformulate my problem: I need a filter
that interpolates control signals in real time.
Ideally, this filter would be self-adopting in a way
that it could be fed with control data that are a)
non-predictable and b) come in in varying intervals
and that it (the filter) would still output smooth
curves. Another prerequisite is that the filter is
able to recognise parameter jumps that exceed a
certain threshold and doesn't interpolate these jumps.
I realise that this is probably impossible to
accomplish.
a simple non-linear (IIR) low-pass filter is x[n]=a*x[n-1]+(1-a)*y[n] (with 0<=a<=1)
So this would basically be lop~ , but not in the frequency domain? I'm a bit confused about the y[n], shouldn't that be x[n] as well? Sorry, I'm totally new to this ...
thank you, thoralf (quite confused).
How much free photo storage do you get? Store your holiday snaps for FREE with Yahoo! Photos http://uk.photos.yahoo.com
curves. Another prerequisite is that the filter is able to recognise parameter jumps that exceed a certain threshold and doesn't interpolate these jumps. I realise that this is probably impossible to accomplish.
certainly not impossible, dynamics compressors/expanders operate on this concept, only mangling the signal when (or when there isnt) an abrupt change. most of them use a small blocksize-or-two lookahead to get better results.. maybe you want to involve a gate of some sort, and flip on and off the lowpass/interpolation/compression depending on some threshold of recent change..
a simple non-linear (IIR) low-pass filter is x[n]=a*x[n-1]+(1-a)*y[n] (with 0<=a<=1)
So this would basically be lop~ , but not in the frequency domain? I'm a bit confused about the y[n], shouldn't that be x[n] as well? Sorry, I'm totally new to this ...
thank you, thoralf (quite confused).
___________________________________________________________ How much free photo storage do you get? Store your holiday snaps for FREE with Yahoo! Photos http://uk.photos.yahoo.com
PD-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
Hi Carmen,
thank you for your answer!
certainly not impossible, dynamics compressors/expanders operate on this concept, only mangling the signal when (or when there isnt) an abrupt change. most of them use a small blocksize-or-two lookahead to get better results.. maybe you want to involve a gate of some sort, and flip on and off the lowpass/interpolation/compression depending on some threshold of recent change..
Okay. Then I would be again at the point where I would need two of Thomas' smooth-abstractions (because they cannot be set to a starting value), which looks a bit like overkill to me. Maybe I should just implement some sort of moving average or something similar.
with kind regards, Thoralf.
How much free photo storage do you get? Store your holiday snaps for FREE with Yahoo! Photos http://uk.photos.yahoo.com
Thoralf Schulze wrote:
Hi Johannes, hi list,
I'll try to reformulate my problem: I need a filter that interpolates control signals in real time.
so it comes to not filtering a signal (~) but rather a stream of float messages. then you have more control and are able to do things like "set <x>"
Ideally, this filter would be self-adopting in a way that it could be fed with control data that are a) non-predictable and b) come in in varying intervals and that it (the filter) would still output smooth curves. Another prerequisite is that the filter is able to recognise parameter jumps that exceed a certain threshold and doesn't interpolate these jumps. I realise that this is probably impossible to accomplish.
no; it should be pretty simple.
a simple non-linear (IIR) low-pass filter is x[n]=a*x[n-1]+(1-a)*y[n] (with 0<=a<=1)
So this would basically be lop~ , but not in the frequency domain?
actually it is a [lop]; like [lop~] it works in time-domain and has an effect on the frequency domain. "frequency" and "time" domains are not exclusively bound to signals~.
I'm a bit confused about the y[n], shouldn't that be x[n] as well?
not really, but what is "x" and what "y" might be a bit confusing. x[n] is the output of the filter (at time "n") and y[n] is the input of the filter.
what it does is: to calculate a new output value, take the last input value and the last output value and do some weighted averaging.
attached is a [lop]-abstraction and a demo-patch that shows that it is working.
oops, this was the "Send"-button instead of the "Attach"-button,
mfg.asd.r IOhannes
#N canvas 207 152 450 300 10; #X floatatom 36 135 5 0 0 0 - - -; #X floatatom 36 205 5 0 0 0 - - -; #X obj 36 184 lop 0.5; #X floatatom 294 68 5 0 0 0 - - -; #X floatatom 278 132 5 0 0 0 - - -; #X obj 278 86 f; #X obj 215 67 metro 100; #X obj 214 46 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 1 1 ; #X text 222 22 like a signal!; #X msg 106 120 set 12; #X text 107 104 set the internal value; #X msg 105 147 bang; #X obj 278 111 lop 0.5; #X connect 0 0 2 0; #X connect 2 0 1 0; #X connect 3 0 5 1; #X connect 5 0 12 0; #X connect 6 0 5 0; #X connect 7 0 6 0; #X connect 9 0 2 0; #X connect 11 0 2 0; #X connect 12 0 4 0;
#N canvas 0 0 902 430 10; #X obj 111 372 outlet x[n]; #X obj 111 154 inlet y[n]; #X obj 384 44 inlet feedback-factor; #X obj 111 282 +; #X obj 111 261 * 1; #X obj 111 304 t f f; #X obj 141 328 * 0; #X obj 444 73 loadbang; #X obj 444 98 f $1; #X obj 444 122 select 0; #X obj 384 155 clip 0 1; #X obj 384 179 t f f; #X msg 127 214 1 $1; #X obj 127 234 -; #X obj 201 285 f; #X obj 111 182 route float bang set; #X text 93 45 1-pole IIR-filter (low-pass); #X text 381 242 if we also allow negative feedback-factors , we can make a high-pass.; #X text 381 290 if we also feedback-factors a with |a|>1 , our filter would became unstable; #X connect 1 0 15 0; #X connect 2 0 10 0; #X connect 3 0 5 0; #X connect 4 0 3 0; #X connect 5 0 0 0; #X connect 5 1 6 0; #X connect 6 0 3 1; #X connect 7 0 8 0; #X connect 8 0 9 0; #X connect 9 1 10 0; #X connect 10 0 11 0; #X connect 11 0 12 0; #X connect 11 1 6 1; #X connect 12 0 13 0; #X connect 13 0 4 1; #X connect 14 0 6 0; #X connect 15 0 4 0; #X connect 15 1 4 0; #X connect 15 2 14 0;
Johannes,
woah, that's it. you saved my day - thank you very, very much.
With kind regards, thoralf.
___________________________________________________________ Yahoo! Messenger - NEW crystal clear PC to PC calling worldwide with voicemail http://uk.messenger.yahoo.com
Hey Thoralf,
The way I see it is that what you want is a circular interpolator. That is one that knows 0 and 359 are one step away not 359 steps away. I think this would be useful for a number of things where wrapping (roll-over) is desired, of course your example of rotation is a good representation.
I have not looked at Frank's patch yet, maybe it is such a thing?
To roll-over at a certain point would be done by multiplying the scale 0-1 (where 0 & 1 are the same point) by your scale (360). I'm not sure what you mean by a smoother that would deal with data in whatever shape... you would always need to tell it the roll-over point.
lop~ method will deal with any incoming value and interpolate from the last position to the target. without roll-over this does satisfy your first need. I guess it would be a matter of a "roll-over" mode. Of course the roll-over interpolator would not interpolate at all if you sent it 0 and then 1. Which is most cases would be desired.
that is enough of me.
b>
Hi Johannes, hi list,
i don't think that you can use soemthing like "set <f>" with dsp-filters.
bad news ...
now that'll be cool: doing interpolation between (however yet) unknown values. i guess this would solve many many problems.
Yeah. Perfect knowledge of the future is a good thing. Let's throw probability on the garbage dump ... Seriously, the mail I wrote yesterday didn't make much sense, it was a hot day here :-). I'll try to reformulate my problem: I need a filter that interpolates control signals in real time. Ideally, this filter would be self-adopting in a way that it could be fed with control data that are a) non-predictable and b) come in in varying intervals and that it (the filter) would still output smooth curves. Another prerequisite is that the filter is able to recognise parameter jumps that exceed a certain threshold and doesn't interpolate these jumps. I realise that this is probably impossible to accomplish.
a simple non-linear (IIR) low-pass filter is x[n]=a*x[n-1]+(1-a)*y[n] (with 0<=a<=1)
So this would basically be lop~ , but not in the frequency domain? I'm a bit confused about the y[n], shouldn't that be x[n] as well? Sorry, I'm totally new to this ...
thank you, thoralf (quite confused).
How much free photo storage do you get? Store your holiday snaps for FREE with Yahoo! Photos http://uk.photos.yahoo.com
PD-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
Hallo, B. Bogart hat gesagt: // B. Bogart wrote:
I have not looked at Frank's patch yet, maybe it is such a thing?
Huh, I did a patch? ;)
lop~ method will deal with any incoming value and interpolate from the last position to the target. without roll-over this does satisfy your first need.
For smooth interpolation a look at Cyrille's [line3] object would be valuable. It interpolates smoothly without the need to convert to dsp first and you can also do jumps by sending a single number instead of a pair - as does [line] in a linear way. This way you could go smoothly from 0-359 by sending these values through a pack, whereas 360 would trigger a jump:
[select 360]
| |
[0( |
| |
[s jump] [pack 0 10]
|
| [r jump]
|/
[line3 0 5]
A but crude, but should work.
Frank Barknecht _ ______footils.org__
_ __latest track: "plak" @ http://footils.org/cms/show/44