HardwareHeaven.com

HardwareHeaven.com

Looking for the skin chooser?
 
 
  • Home

  • Hardware reviews

  • Articles

  • News

  • Tools

  • Gaming at HardwareHeaven

  • Forums

 

Go Back   HardwareHeaven.com > Forums > Hardware and Related Topics > kX Project Audio Driver Support Forum > Effects and the DSP


Reply
 
Thread Tools
Old Feb 21, 2007, 01:59 AM   #1
Tail Razer
 
Maddogg6's Avatar
 
Join Date: Jun 2005
Location: Bernyurass, AZ - USA
Posts: 4,027
Rep Power: 0
Maddogg6 will become famous soon enoughMaddogg6 will become famous soon enough

Auto Mute plugin?

Is there a plugin - that exists that will act as a sort of binary 'ducker'.
Binary in that - it acts as a switch (on or off only, not mix amount like a traditional ducker would do with say a sidechannel input of a compressor)

What Im looking to do is...
Say I am using Prologica to upmix stereo signals. Which I send FXBuss 0/1 to.
I mix the REAR outputs of prologica with FXBuss 6/7 - and output to epilogs rear outputs.
This works fine EXCEPT - that when I say, use foobar to UPMIX - or play a DVD, I would like so way to automatically mute the prologica REAR from going to epilog - so FXBUSS 6/7 is ONLY heard..

I realize this may be possible with dynamics processor, I havent tried yet, but its kinda a resource hog to as I dont want compression/expansion - just a simple ON or OFF 'ducker'.
Does this exist, if not - how is 'ON or OFF' figured in KX DSP (more precisely, DANE ONLY).

*Hopes that made sense*

Thanks,
Mark
Maddogg6 is offline   Reply With Quote


Old Feb 21, 2007, 02:26 AM   #2
HardwareHeaven Extreme Member
 
Join Date: Jan 2005
Posts: 5,563
Rep Power: 62
Russ is just super!Russ is just super!Russ is just super!Russ is just super!Russ is just super!Russ is just super!

Assuming that the audio to FxBus 6/7 is not gated (so that when something is playing, there is always some minimum level to use for detection), then it should be pretty easy to do using conditional logic (use skip instructions).

Something like (pseudocode):

if (abs(in2) > 0)
out = in2
else
out = in1

Is this something that you want to try and make yourself?

<edit>
Actually the abs (above) is not even necessary, since you can just check for a non-zero value at the input (use a skip instruction using 0x100 as the test_value) .
i.e.
if (in2 != 0)
out = in2
else
out = in1
</edit>

Last edited by Russ; Feb 21, 2007 at 02:53 AM. Reason: typo
Russ is offline   Reply With Quote
Old Feb 21, 2007, 03:10 AM Threadstarter Thread Starter   #3
Tail Razer
 
Maddogg6's Avatar
 
Join Date: Jun 2005
Location: Bernyurass, AZ - USA
Posts: 4,027
Rep Power: 0
Maddogg6 will become famous soon enoughMaddogg6 will become famous soon enough

Quote:
Originally Posted by Russ View Post
Is this something that you want to try and make yourself?

<edit>
Actually the abs (above) is not even necessary, since you can just check for a non-zero value at the input (use a skip instruction using 0x100 as the test_value) .
i.e.
if (in2 != 0)
out = in2
else
out = in1
</edit>
Ahh - ok the skip instruction - yes I would like to make this myself in DANE - I guess I was making sure I didnt set out on an impossible quest.
(I wasnt sure if it was possible with DANE only)

Thank you sir...
Maddogg6 is offline   Reply With Quote
Old Feb 21, 2007, 03:19 AM   #4
HardwareHeaven Extreme Member
 
Join Date: Jan 2005
Posts: 5,563
Rep Power: 62
Russ is just super!Russ is just super!Russ is just super!Russ is just super!Russ is just super!Russ is just super!

Just remember that the skip instruction, skips if the test condition is true (sort of the opposite of using if..then).

Let me know if you need any help with it.
Russ is offline   Reply With Quote
Old Feb 21, 2007, 04:13 AM Threadstarter Thread Starter   #5
Tail Razer
 
Maddogg6's Avatar
 
Join Date: Jun 2005
Location: Bernyurass, AZ - USA
Posts: 4,027
Rep Power: 0
Maddogg6 will become famous soon enoughMaddogg6 will become famous soon enough

Ok - here it is, I added level controls too.

edit:
Description: If signal is present on FXBIn - then mute PL inputs. With level controls

Code:
input FXBInL, FXBInR, PLInL, PLInR
output OutL, OutR
control FXB=1, PL =1
temp t1, t2

; code

macs t1, 0, FXBInL, FXB ; t1 = T1 + PLInL * PL
macs t2, 0, FXBInR, FXB ; t2 = T2 + PLInR * PL
skip t1, ccr, 0x100, 2 ; if FXBInL = 0.. then Skip next 2 instructions

macs t1, 0, PLInL, PL ; t1 = T1 + PLInL * PL
macs t2, 0, PLInR, PL ; t2 = T2 + PLInR * PL
macs OutL, 0, t1, 1 ; 
macs OutR, 0, t2, 1 ;
Edit: Fixed as per Russ' keen eye - pointing out this dumb guy.
(Now!) Seems to work as I expect - but any suggestions to optimize or potential problems please post em...


Thanks again Russ.

Last edited by Maddogg6; Feb 21, 2007 at 06:12 AM.
Maddogg6 is offline   Reply With Quote
Old Feb 21, 2007, 04:56 AM   #6
HardwareHeaven Extreme Member
 
Join Date: Jan 2005
Posts: 5,563
Rep Power: 62
Russ is just super!Russ is just super!Russ is just super!Russ is just super!Russ is just super!Russ is just super!

Ok, there are some optimizations that you can do:

Use Outputs instead of temp registers when possible (save gprs).
Add the 2 channels together so that it is triggered if there is a signal from either channel.

Your code was not working for me, and I am not sure why, I will have to take a closer look at it.

In the mean time, here is the code I used while I was waiting (to show another (very similar) way of doing it)...

input in1_left, in1_right;
input in2_left, in2_right;
output out_left, out_right;

macs out_left, in2_left, 0, 0;
macs out_right, in2_right, 0, 0;
acc3 0, out_left, out_right, 0;
skip ccr, ccr, 0x100, 2;
macs out_left, in1_left, 0, 0;
macs out_right, in1_right, 0, 0;

To add volume controls, you would just change the first 2 and last 2 instructions to apply the volumes.

Ok, now let me figure out why your code is not working for me...

Last edited by Russ; Feb 21, 2007 at 08:35 PM.
Russ is offline   Reply With Quote
Old Feb 21, 2007, 05:36 AM   #7
HardwareHeaven Extreme Member
 
Join Date: Jan 2005
Posts: 5,563
Rep Power: 62
Russ is just super!Russ is just super!Russ is just super!Russ is just super!Russ is just super!Russ is just super!

Ok, I see what the problem is, you have the conditions backwards (those skip instructions can be confusing).

i.e.

if (in1 != 0)
out = in2 // in2 only plays when a signal is at in1
else
out = in1 // only gets here if in1 is 0, so nothing plays at all if it gets here

BTW:
Why use this:
-----------
macs OutL, 0x0, t1, 0x7fffffff;
macs OutR, 0x0, t2, 0x7fffffff;
-----------

instead of:
-----------
macs OutL, t1, 0, 0;
macs OutR, t2, 0, 0;
-----------

Not that it really matters, I am just curious...

<edit>
One more thing...
I would swap the positions of your volume controls, such that top slider controls volume for the top inputs, and the bottom slider controls the volume for the bottom inputs. Just because it is what I am used to with plugins like Stereo Mix, GainHQ, etc (I kept adjusting the wrong slider).
</edit>

Last edited by Russ; Feb 21, 2007 at 06:38 AM.
Russ is offline   Reply With Quote
Old Feb 21, 2007, 06:01 AM Threadstarter Thread Starter   #8
Tail Razer
 
Maddogg6's Avatar
 
Join Date: Jun 2005
Location: Bernyurass, AZ - USA
Posts: 4,027
Rep Power: 0
Maddogg6 will become famous soon enoughMaddogg6 will become famous soon enough

I fixed the post - Ok - NOW it works - Im positively 100% sure - I think.

hehe.


Anyway - I have a question:
Quote:
acc3 0, out_left, out_right, 0;
skip ccr, ccr, 0x100, 2;
I was wondering why testing this wasn't good?
Quote:
macs out_right, in2_right, 0, 0;
skip out_right, ccr, 0x100, 2;
?? - beside the fact you multiplied by zero (which would always = zero, no??)
(edit: nevermind the above Q - DoH out=in+(0 *0) /end edit)
But the question is more on why you added an extra instruction for the test - does that reset a value or something.

Edit - I gotya - My way is ONLY testing RIGHT - your test the combination of L+R...
Sorry - I dum ....

But then agian - Im saving an instruction - so - 'I dum like skunk'.

Last edited by Maddogg6; Feb 21, 2007 at 06:21 AM.
Maddogg6 is offline   Reply With Quote
Old Feb 21, 2007, 06:14 AM   #9
HardwareHeaven Extreme Member
 
Join Date: Jan 2005
Posts: 5,563
Rep Power: 62
Russ is just super!Russ is just super!Russ is just super!Russ is just super!Russ is just super!Russ is just super!

MACS instructions takes the form: R = A + (X * Y)
(order of operations does multiplication before addition)

MACS R, A, 0, 0; R = A + (0 * 0) or R = A

MACS R, A, 0, 1; R = A + (0 * 1) or R = A
The above instruction has the same result as the previous one, the 1 does nothing (1 * 0 = 0) except make it confusing as to what the code is supposed to do when reading it.

skip out_right, ccr, 0x100, 2;
Why are you saving the result of the skip instrcution in out_right?
You do not need to save it at all, and further it is modfying the value of out_right.

You did the same thing in your code with your tmp variable, so that when t1 is fed to the output, it is the result of the skip instruction instead on the input. You need to fix that.
Just make it:
skip ccr, ccr, 0x100, 2;

Give me a min and I will look at your update and see if there is anything else.
Russ is offline   Reply With Quote
Old Feb 21, 2007, 06:25 AM   #10
HardwareHeaven Extreme Member
 
Join Date: Jan 2005
Posts: 5,563
Rep Power: 62
Russ is just super!Russ is just super!Russ is just super!Russ is just super!Russ is just super!Russ is just super!

Ok, the only problem that I see with your new code is with the skip instruction:
Code:
skip t1, ccr, 0x100, 2 ; if FXBInL = 0.. then Skip next 2 instructions
Remove 't1' and use 'ccr' instead as I said in my previous post.
The comment is wrong, should read:
if FXBInR != 0.. then Skip next 2 instructions
(note the 'R' and the "!=")

The rest would just be optimizations to get rid of the temp variables, etc.

The only problem with such a plugin, is with audio sources that have parts in them that are completely silent (i.e. value of 0). With no noise floor (digital material), such silences can cause it to act up. It would be good to add a timer of some sort to keep it from unmuting the other input during short periods of silence, etc.

Last edited by Russ; Feb 21, 2007 at 06:36 AM.
Russ is offline   Reply With Quote
Old Feb 21, 2007, 06:31 AM Threadstarter Thread Starter   #11
Tail Razer
 
Maddogg6's Avatar
 
Join Date: Jun 2005
Location: Bernyurass, AZ - USA
Posts: 4,027
Rep Power: 0
Maddogg6 will become famous soon enoughMaddogg6 will become famous soon enough

Ok I tried yur optimizations and I think the FIRST macs that SET output registers are causing them to be set for PLIN then AGAIN for FXB - when signal is present on both... so I think the temp registers are needed.
Maddogg6 is offline   Reply With Quote
Old Feb 21, 2007, 06:45 AM Threadstarter Thread Starter   #12
Tail Razer
 
Maddogg6's Avatar
 
Join Date: Jun 2005
Location: Bernyurass, AZ - USA
Posts: 4,027
Rep Power: 0
Maddogg6 will become famous soon enoughMaddogg6 will become famous soon enough

Ok - I got it this time - poor Russ, puttin up with my idiotic ways..

Code:
input FXBInL, FXBInR, PLInL, PLInR
output OutL, OutR
control FXB=1, PL =1

; code

macs OutL, 0, FXBInL, FXB ; OutL = 0 + PLInL * PL
macs OutR, 0, FXBInR, FXB ; OutR = 0 + PLInR * PL

acc3 0, FXBInL, FXBInR,0 ; Add BOTH inputs to test BOTH L & R for any signal
skip ccr, ccr, 0x100, 2 ; If FXBInL+FXBInR != 0.. then Skip next 2 instructions
macs OutL, 0, PLInL, PL ; OutL = 0 + PLInL * PL
macs OutR, 0, PLInR, PL ; OutR = 0 + PLInR * PL
I should have beed using headphones for test this whole time to more accurately hear what was happening.

Anyway - its working 100% now - no really - it is...

Thanks again Russ for your patients and suggestions - I'll find that cliff right away... Now did you say I should leap forwards or backwards ?? lolz

edit: I added your suggested ACC3 - as it clicks less durring fade outs when signal id onFXBIn.

Now - 1 more Q - I'm thinking of using iTram (say 10 samples) and adding FXBIn's and sending the sum to that iTram, and adding that as well to the ACC3 instruction - to get a sort of delay in muting - to reduce the artifacts - as we're always crossing 0)

An I still being dum with this idea??

Last edited by Maddogg6; Feb 21, 2007 at 06:59 AM.
Maddogg6 is offline   Reply With Quote
Old Feb 21, 2007, 06:48 AM   #13
HardwareHeaven Extreme Member
 
Join Date: Jan 2005
Posts: 5,563
Rep Power: 62
Russ is just super!Russ is just super!Russ is just super!Russ is just super!Russ is just super!Russ is just super!

Quote:
Originally Posted by Maddogg6 View Post
Ok I tried yur optimizations and I think the FIRST macs that SET output registers are causing them to be set for PLIN then AGAIN for FXB - when signal is present on both... so I think the temp registers are needed.
I am not sure what you mean, I would have to see how you coded it. It works for me (except my code mutes in1 when a signal is presnt at in2).

<edit>
Just saw your last post... that looks better
</edit>

Last edited by Russ; Feb 21, 2007 at 06:57 AM.
Russ is offline   Reply With Quote
Old Feb 21, 2007, 07:04 AM   #14
HardwareHeaven Extreme Member
 
Join Date: Jan 2005
Posts: 5,563
Rep Power: 62
Russ is just super!Russ is just super!Russ is just super!Russ is just super!Russ is just super!Russ is just super!

Quote:
Originally Posted by Maddogg6 View Post
Now - 1 more Q - I'm thinking of using iTram (say 10 samples) and adding FXBIn's and sending the sum to that iTram, and adding that as well to the ACC3 instruction - to get a sort of delay in muting - to reduce the artifacts - as we're always crossing 0)

An I still being dum with this idea??
Sounds ok to me... Give it a try, that is part of the fun with making your own plugins, trying out ideas and seeing if/how well they work.
Russ is offline   Reply With Quote
Old Feb 21, 2007, 07:04 AM Threadstarter Thread Starter   #15
Tail Razer
 
Maddogg6's Avatar
 
Join Date: Jun 2005
Location: Bernyurass, AZ - USA
Posts: 4,027
Rep Power: 0
Maddogg6 will become famous soon enoughMaddogg6 will become famous soon enough

Something like this...
Code:
itramsize 10
; xtramsize 0

input FXBInL, FXBInR, PLInL, PLInR
output OutL, OutR
control FXB=1, PL =1

; code
idelay write dw at 0x0
macs OutL, 0, FXBInL, FXB ; t1 = T1 + PLInL * PL
macs OutR, 0, FXBInR, FXB ; t2 = T2 + PLInR * PL

acc3 0, FXBInL, FXBInR, dw
skip ccr, ccr, 0x100, 2 ; FXBInR != 0.. then Skip next 2 instructions
macs OutL, 0, PLInL, PL ; t1 = T1 + PLInL * PL
macs OutR, 0, PLInR, PL ; t2 = T2 + PLInR * PL
So far seems to work
Maddogg6 is offline   Reply With Quote
Old Feb 21, 2007, 07:08 AM Threadstarter Thread Starter   #16
Tail Razer
 
Maddogg6's Avatar
 
Join Date: Jun 2005
Location: Bernyurass, AZ - USA
Posts: 4,027
Rep Power: 0
Maddogg6 will become famous soon enoughMaddogg6 will become famous soon enough

Quote:
Originally Posted by Russ View Post
Sounds ok to me... Give it a try, that is part of the fun with making your own plugins, trying out ideas and seeing if/how well they work.
Seems alot of trouble is NON OPTIMAL testing methods...

But yes - that definitly seems to have helped smooth out fades.
Maddogg6 is offline   Reply With Quote
Old Feb 21, 2007, 07:10 AM   #17
HardwareHeaven Extreme Member
 
Join Date: Jan 2005
Posts: 5,563
Rep Power: 62
Russ is just super!Russ is just super!Russ is just super!Russ is just super!Russ is just super!Russ is just super!

Quote:
Originally Posted by Maddogg6 View Post
So far seems to work
Are you sure?
You have no read address, so all you are doing is writing to iTram.
(err, actually you are not even doing that ... to write to iTram, the write address needs to be the R register in one of the instructions).

Quote:
Seems alot of trouble is NON OPTIMAL testing methods...
Yeah, good testing methods would help.

<edit>
You would need to do something like this:

iDelay read dr at 10
...
acc3 dw, in1l, in1r, 0;
acc3 0, in1l, in1r, dr;
skip...

But if you have a sound that is less than 10 samples long, then this could cause problems too...
</edit>

Last edited by Russ; Feb 21, 2007 at 07:32 AM.
Russ is offline   Reply With Quote
Old Feb 21, 2007, 07:44 AM   #18
DH Senior Member
 
Join Date: Jan 2003
Location: The Netherlands
Posts: 1,932
Rep Power: 64
Lex Nahumury is just really niceLex Nahumury is just really niceLex Nahumury is just really niceLex Nahumury is just really nice

I don't mean to spoil the fun but,
Russ, you are making the same mistake as with your Noise gate.
Use average of control signal. Never per sample!

What you guys are doing now is abruptly switching channel_B on *every*
zero crossing of the signal present on channel_A.

The proper way to do such 'channel switching' without introducing distortion/pops&clicks etc, is to design a proper Gate.
So you really can't do without some form of EnvelopeFollower,attack,release + VCA.
(If this plugin has to be any good that is)

HTH,

/Lex.

PS:
Russ, Just noticed your 'itram' attempt.
Go for a 'real' Gate,..trust me
Lex Nahumury is offline   Reply With Quote
Old Feb 21, 2007, 08:16 AM   #19
HardwareHeaven Extreme Member
 
Join Date: Jan 2005
Posts: 5,563
Rep Power: 62
Russ is just super!Russ is just super!Russ is just super!Russ is just super!Russ is just super!Russ is just super!

Yup, you are right....
Russ is offline   Reply With Quote
Old Feb 21, 2007, 09:12 AM Threadstarter Thread Starter   #20
Tail Razer
 
Maddogg6's Avatar
 
Join Date: Jun 2005
Location: Bernyurass, AZ - USA
Posts: 4,027
Rep Power: 0
Maddogg6 will become famous soon enoughMaddogg6 will become famous soon enough

Hey lex... I have no doubts having the conventional gating would be better,
But I came up with this that works pretty good for my needs.
Quote:
itramsize 96
; xtramsize 0

input FXBInL, FXBInR, PLInL, PLInR
output OutL, OutR
control FXB=1, PL=1

; code
idelay write dw at 0
idelay read dr at 96

macs OutL, 0, FXBInL, FXB ; OutL = 0 + PLInL * PL
macs OutR, 0, FXBInR, FXB ; OutR = 0 + PLInR * PL

acc3 dw, 0, OutL, OutR ;Store mute delay test sample

acc3 0, dr, OutL, OutR ; prepare to test
skip ccr, ccr, 0x100, 3 ; OutR+OutL != 0.. then Skip next 2 instructions
macs OutL, 0, PLInL, PL ; OutL = 0 + PLInL * PL
macs OutR, 0, PLInR, PL ; OutR = 0 + PLInR * PL
Its low on resources and all DANE... which is what I was after - I do, on occasion hear some clicking - but this is for TV/DVD watching so its not a big deal

(I can now easily use the same DSP config now for AC3 or DSP upmix - and not have doubled sounds )

Thanks for all the input, suggestions etc etc - Oh, I found that cliff btw Russ
Maddogg6 is offline   Reply With Quote
Old Feb 21, 2007, 09:33 AM   #21
HardwareHeaven Extreme Member
 
Join Date: Jan 2005
Posts: 5,563
Rep Power: 62
Russ is just super!Russ is just super!Russ is just super!Russ is just super!Russ is just super!Russ is just super!

Sorry Maddogg6, I do not know where my brain was. I did not even think about zero-crossings, etc.

In any case, I hacked something together that might work a little better. I threw it togther quickly, so it is not optimized (at all) or anything, but I think it might work ok. It may not be the best implemention (it is 4:30 am), but maybe you can make use of it.

Here is the code (hopefully it isn't t bad... I am starting to go cross-eyed):
Code:
input FXBInL, FXBInR, PLInL;
input PLInR;
output OutL, OutR;
control FXB=1, PL=1;
static abs=0, av=0, v1=0;
static v2=0;
temp t1, t2


; code
interp v1, v1, 0.00001, 1;
macs t1, 0, FXBInL, v1;
macs t2, 0, FXBInR, v1;
macs t1, 0, t1, FXB;
macs t2, 0, t2, FXB;
tstneg abs, t1, t1, 0;
interp av, av, 0.0007, abs;
skip ccr, ccr, 0x100, 7;
interp v2, v2, 0.00001, 1;
macs t1, 0, PLInL, v2;
macs t2, 0, PLInR, v2;
macs t1, 0, t1, PL;
macs t2, 0, t2, PL;
macs v1, 0, 0, 0;      
skip ccr, ccr, 0x7fffffff, 1
macs v2, 0, 0, 0;
macs OutL, 0, t1, 1; 
macs OutR, 0, t2, 1;
It currently only uses FXBInL for testing.

In any case, it is still all Dane code, and what Lex is talking about most likley could be done all in Dane as well, without using too many resources.

Last edited by Russ; Feb 21, 2007 at 10:30 PM.
Russ is offline   Reply With Quote
Old Feb 21, 2007, 09:38 AM Threadstarter Thread Starter   #22
Tail Razer
 
Maddogg6's Avatar
 
Join Date: Jun 2005
Location: Bernyurass, AZ - USA
Posts: 4,027
Rep Power: 0
Maddogg6 will become famous soon enoughMaddogg6 will become famous soon enough

Oh - Hey Russ - you need not bothered - I have enough hehe...

But I do appreciate - I will give it a go tomarrow (and maybe learn about the A/D gating too--- maybe not ??)

Anyways -- thanks 1,000,000,004.4674 times.

Get some sleep already....
Maddogg6 is offline   Reply With Quote
Old Feb 21, 2007, 08:17 PM Threadstarter Thread Starter   #23
Tail Razer
 
Maddogg6's Avatar
 
Join Date: Jun 2005
Location: Bernyurass, AZ - USA
Posts: 4,027
Rep Power: 0
Maddogg6 will become famous soon enoughMaddogg6 will become famous soon enough

@Russ: thank you again - its working very well..

I do have a question (or 2 or 3 or.... ):

I see the static was used to 'sorta' do what I was thinking with the iTram delay - I get that, or understand why thats a better idea.

But I was wondering if you could to write up psudo code for the logic you used here.? or maybe comment the code possibly...
I think I could learn more that way... maybe not ??

if its too much hassle, I completely understand if you think it will just go over my 'low flying' head.

Again - thank you so much...

edit: it seems to output a mono mix of FXBIns...
(I sent a wide stereo signal into both, and enabled/disabled FXBIns and can hear stereo - mono... )
I would like to understand why and if possible how to fix it myself - but I dont want to be that hemeroid that wont go away either...

Last edited by Maddogg6; Feb 21, 2007 at 08:22 PM.
Maddogg6 is offline   Reply With Quote
Old Feb 21, 2007, 08:54 PM   #24
HardwareHeaven Extreme Member
 
Join Date: Jan 2005
Posts: 5,563
Rep Power: 62
Russ is just super!Russ is just super!Russ is just super!Russ is just super!Russ is just super!Russ is just super!

The mono problem was due to a typo (I corrected it) on the 5th instruction, that was causing it to only play the left side of that input.

I will add an explanation as soon as I have a chance.
Russ is offline   Reply With Quote
Old Feb 21, 2007, 09:41 PM   #25
HardwareHeaven Extreme Member
 
Join Date: Jan 2005
Posts: 5,563
Rep Power: 62
Russ is just super!Russ is just super!Russ is just super!Russ is just super!Russ is just super!Russ is just super!

The main thing to understand here is the 'interp' instruction. It basically does linear interpolation between 2 values. What this means, is that the result goes from the first value (the A parameter) toward the second value (the Y parameter) at a rate determined by the value of the X parameter.

With 2 static (starting) values (where the first value is being updated by the result), it basically works like a ramp.
With 2 dynamic values (where the first value is being updated by the result), it basically works like an averager/smoother.

The code basically takes the absolute value of the input (currently only the left side of the input that we want to test), and uses the (2nd) interp instruction to smooth it out a bit, to try and get an average value. Additionally, when the input stops (becomes 0), the two values become static and then it works like a ramp (down), delaying the point where it reaches 0, which helps to keep it from tiggerring on short silences, etc.

The other 2 interp instructions (1st and last) are used as a volume ramp (up). When either input is sent to the output, it sets the other input's starting ramp value to 0, so when it switches inputs, it basically climbs from 0 toward 1.

Does that make sense?

Here is the code with comments added, see if you can figure it out from the comments, and then ask about any part that you do not understand.
Code:
interp v1, v1, 0.00001, 1;  
; volume ramp for FXB inputs
macs t1, 0, FXBInL, v1;
; t1 = input * value of volume ramp
macs t2, 0, FXBInR, v1; 
; t2 = input * value of volume ramp
macs t1, 0, t1, FXB;
; t1 = t1 * value of volume slider
macs t2, 0, t2, FXB;
; t2 = t2 * value of volume slider
tstneg abs, t1, t1, 0;
; abs = absolute value of t1
interp av, av, 0.0007, abs;
; av is kind of the average level of FXBInL
skip ccr, ccr, 0x100, 7; 
; skip 7 instructions if result of above != 0
interp v2, v2, 0.00001, 1;
; volume ramp for PL inputs
macs t1, 0, PLInL, v2;
; t1 = input * value of volume ramp
macs t2, 0, PLInR, v2;
; t2 = input * value of volume ramp
macs t1, 0, t1, PL;
; t1 = t1 * value of volume slider
macs t2, 0, t2, PL;
; t2 = t2 * value of volume slider
macs v1, 0, 0, 0;      
; set starting value of volume ramp for FXB inputs to 0
skip ccr, ccr, 0x7fffffff, 1;
; always skip 1 instruction
macs v2, 0, 0, 0;
; set starting value of volume ramp for PL inputs to 0
macs OutL, 0, t1, 1; 
; OutL = t1
macs OutR, 0, t2, 1;  
; OutR = t2
<edit>
BTW: 'abs' does not need to be static register (can be a temp).
</edit>

Last edited by Russ; Feb 21, 2007 at 10:36 PM.
Russ is offline   Reply With Quote
Old Feb 21, 2007, 11:06 PM   #26
HardwareHeaven Extreme Member
 
Join Date: Jan 2005
Posts: 5,563
Rep Power: 62
Russ is just super!Russ is just super!Russ is just super!Russ is just super!Russ is just super!Russ is just super!

BTW: You can use the following in the MS PowerToy Calculator to simulate the interp instruction:

interp(a, x, y) = (1-x)*a+x*y

i.e.
interp(0, .5, 1) = 0.5
interp(answer, .5, 1) = 0.75
interp(answer, .5, 1) = 0.875
interp(answer, .5, 1) = 0.9375
interp(answer, .5, 1) = 0.96875
...

So you can see, with 0.5 as the interpolation factor, and Y being a constant value (1 in this case), and the A parameter (starting at 0) being continually updated by the result, the result is half the distance between A and Y each time.

Last edited by Russ; Feb 22, 2007 at 12:17 AM. Reason: spelling
Russ is offline   Reply With Quote
Old Feb 22, 2007, 12:04 AM Threadstarter Thread Starter   #27
Tail Razer
 
Maddogg6's Avatar
 
Join Date: Jun 2005
Location: Bernyurass, AZ - USA
Posts: 4,027
Rep Power: 0
Maddogg6 will become famous soon enoughMaddogg6 will become famous soon enough

Quote:
The main thing to understand here is the 'interp' instruction. It basically does linear interpolation between 2 values. What this means, is that the result goes from the first value (the A parameter) toward the second value (the Y parameter) at a rate determined by the value of the X parameter.
Dont let the fact this was your first sentance make you think its all I read btw..

But to make sure Im crystal clear on this instruction:
Quote:
9. INTERP - this instruction performs linear interpolation between two points.
What 2 points - Y and A ? is what it looks like..
Quote:
INTERP R = (1 - X) * A + X * Y
At a step size per sample cycle of 'X'.

How far off am I on this... ??

edit: Doh - I spent an hour reading about that instruction while I was composing this...

Quote:
So you can see, with 0.5 as the interpolation factor, and Y being a constant value (1 in this case), and the A parameter (starting at 0) being continually updated by the result, the result is half the distance betwen A and Y each time.
That sentence there should be in the Dane guide. That makes it much clearer - thank you.
Maddogg6 is offline   Reply With Quote
Old Feb 22, 2007, 12:26 AM   #28
h/h member-shmember
 
Join Date: Dec 2002
Location: Evil Empire
Posts: 2,639
Rep Power: 69
Max M. is just super!Max M. is just super!Max M. is just super!Max M. is just super!Max M. is just super!Max M. is just super!

[color=gray]
>That sentence there should be in the Dane guide.

The problem is that the "integrator" algorithm (what "interp av, av, 0.0007, abs" is) and the 'interp' instruction are not the same things (though the second is the best way to implement the first). The first is more to be a subject to some kind of "DSP Algorithms Guide". That's the hardest point in writing all those things like "guide to ..." - it is not always possible to find a good balance between "DSP Algorithms Guide with some examples of kX/dane programming" and 'kX/Dane Programming Guide with some examples of dsp algoritms " - you know... got more on first - lost something on second... got something on second - lost something on first... tried to fully cover both - failed to achive anything [/color]
Max M. is offline   Reply With Quote
Old Feb 23, 2007, 02:19 AM   #29
HardwareHeaven Extreme Member
 
Join Date: Jan 2005
Posts: 5,563
Rep Power: 62
Russ is just super!Russ is just super!Russ is just super!Russ is just super!Russ is just super!Russ is just super!

@Maddogg6,

Something else that you might find useful (regarding the interp instruction) for Dane only plugins, is it's ability to rescale values (this is explained somewhat in the AS10k1 Online Manual).

i.e.
Using Dane only, you can change a slider's range from 0 to 1, to something else.

i.e.
Change the range to 0 to 0.25
interp R, 0, slider_value, 0.25;

Change the range to 0.25 to 1
interp R, 0.25, slider_value, 1;

Change the range to 0.25 to 0.50
interp R, 0.25, slider_value, 0.50;

...etc.

The A and Y parameters define the new range, and the X parameter is the actual slider value.

(Note: the actual top value is 0x1 (1 bit (LSB)) less than the value you specify, due to the fact that fractional 1 is 0x1 less than 1, but hopefully you get the idea).

Again using the PowerToy Calculator you can get an idea of what it is doing:
(mapping a slider to a new range of 0 to 0.25)

With an actual slider value of 0 (min value):
interp(0, 0, 0.25) = 0 (new min value)

With an actual slider value of 1 (max value):
interp(0, 1, 0.25) = 0.25 (new max value)

With an actual slider value of 0.5 (middle value):
interp(0, 0.5, 0.25) = 0.125 (new middle value)
Russ is offline   Reply With Quote
Old Feb 23, 2007, 02:30 AM Threadstarter Thread Starter   #30
Tail Razer
 
Maddogg6's Avatar
 
Join Date: Jun 2005
Location: Bernyurass, AZ - USA
Posts: 4,027
Rep Power: 0
Maddogg6 will become famous soon enoughMaddogg6 will become famous soon enough

Quote:
Originally Posted by Russ View Post
i.e.
Using Dane only, you can change a slider's range from 0 to 1, to something else.

i.e.
Change the range to 0 to 0.25
interp R, 0, slider_value, 0.25;

Change the range to 0.25 to 1
interp R, 0.25, slider_value, 1;

Change the range to 0.25 to 0.50
interp R, 0.25, slider_value, 0.50;

...etc.
Ahh yes - this is a spectacular reference too. Very good info.
Maddogg6 is offline   Reply With Quote
Reply

Thread Tools