A question about order of execution when coding objects!


#1

Hey!

Trying to code a filter here, where the order of execution is very important. Actually I want to process the code in the object NOT in the right order. But it seems like I cant get it right. See picture:

The first line named GOOOD processes the math/+ before everything else......... and this sound best for this occasion, so this is what I am trying to do.

The second line BAAAAD has "right" order of execution, but it doesnt sound as good.

Question is, how do I make sure the code ins processed in the right sequence, with the math/+ being processed first? I tried a few times but I think I dont understand order of execution in code yet. I made an example patch and my test object is included, if someone wouldn't mind taking a look at, I would appreciate it.

Jaffa

ORDER OF EXECUTION 1.axp (11.4 KB)


#2

just put it first into your code, the code is executed from top to bottom. (except for function calls etc. but since they are referenced in the code as well it still somehow processes top to bottom)


#3

I think I all ready did that. This is supposed to be the GOOOD version, but it sounds the same as the BAAAAD version:

The 2 filters has got some code in the k-rate section, which is as far as i know processed before sample rate section. So I am thinking there might be a problem there. Cause when patched with factory objects, it processed every filter individually before sending it to the next. When having all the code in one object, this changes a bit and both filter K-rate code are processed at the same time and then s-rate code. So it becomes kind of parallel, not 100% serial, like when using factory objects. Dunno if this actually matters...

Anyway, the above doesnt work.


#4

To be clear k-rate is execute prior to s-rate within the object only
( it is notexecuting all k-rate code for all objects then all s-rate code for all objects)

Your code is effectively doing the filtering one sample behind. ie your adding the previous ('filtered') sample to the current sample. Is this what you intend?

if you are unclear of execution order/what is being generated, id recommend taking a look at the xpatch.cpp that is generated in the build directory - its very clear from that what is going on.


#5

Yes, this is how I understand it. I think I said that when I have everything within one object, the k-rate code of the individual filter are processed together, before the S-rate code is processed.

And when patched with factory objects it processes the whole object, k-rate & s-rate before processing the next objects.

So there is a difference there. But I dont know if this is the reason.

I am trying to do what is described as GOOOD path, where the math/+ is processed first and then the rest. If what you say is the technical way of saying it, then yes.

So a way to do this could be adding a 1 sample delay to the filters, so math/+ is processed first and then the filters?

It seems pretty clear that it doesnt process it the way I was hoping for. So not so much a problem IF it processes it wrongly(according to what my goal is) it, more about what a solution to the problem could be.


#6

Hi,
I think that the low pass filters induce frequency dependent phase changes that can contribute to your issues.

http://www.analog.com/en/analog-dialogue/articles/phase-response-in-active-filters-2.html