Managing two parameters w/one pot

Algorithm development and general DSP issues

Moderator: frank

Post Reply
Sweetalk
Posts: 141
Joined: Thu Oct 15, 2009 5:13 am

Managing two parameters w/one pot

Post by Sweetalk »

Hi!, in an algorithm that I'm developing I need to control tw parameters with one pot. The first parameter has to swing between 0.3 and 0.6. The second parameter must remain in a fixed value for the lower half of the pot (or 3/4) and has to go up on the upper half. Has to swing between 0.8 and 1.3.

So, what's the problem?. This is what I coded:

Code: Select all

rdax	pot2,	1	; Read POT2
sof	0.3,	0.3	; Scale to 0.3, add 0.2
wrax	reg1,	0       ; reg1: 0.3 to 0.6. Clear acc

rdax	pot2,	1	 ; Read POT2
sof	-1,	0.999 ; Invert POT2 and add 0.999.
sof	1.99,	0	 ; Scale to clip
sof	-1,	0	; Invert POT2
sof	0.38,	0.62 ; Scale 0.38, add 0.62
wrax	reg2,	0	; reg2: 0.38 to 1
Then, when I have to control the second parameter, reg2 in this case (the first works perfectly):

Code: Select all

rdax  input,	1.3    ; Read the input register and scale by 1.3
mulx	reg2			        ; Multiply the input by reg2 that varies between 0.62 and 1.
Well, this doesn't works, the result is like the second register where only on the lower value. Can I multiply by reg2 on the rdax sentence?.
I can't scale on the rdax sentence by the register directly, no
frank
Posts: 1244
Joined: Wed Oct 19, 2005 12:26 pm
Contact:

Post by frank »

Try this code, I have not run it yet to see if I made any syntax errors, away from my dev system at the moment, but I think it will do what you want:

Code: Select all

; this code should read a pot, if < 0.5 then use the fixed value of 0.8, if >= 0.5 then scale to be between 0.8 and 1.3

rdax	pot2,1.0
sof	1.0, -0.5	; subtract 0.5, if result is negative use fixed value, if positive use scaled value
skp	NEG, negative	; jump if negative
sof	1.0, 0.8	; was positive so ACC is between 0 and 0.5 so add 0.8 to make it range 0.8 to 1.3
skp	gez, done	; ACC is positive so jump over negative value code
negative:
sof	0, 0.8		; load fixed value
done:
<rest of code>
Frank Thomson
Experimental Noize
Sweetalk
Posts: 141
Joined: Thu Oct 15, 2009 5:13 am

Post by Sweetalk »

frank wrote:Try this code, I have not run it yet to see if I made any syntax errors, away from my dev system at the moment, but I think it will do what you want:

Code: Select all

; this code should read a pot, if < 0.5 then use the fixed value of 0.8, if >= 0.5 then scale to be between 0.8 and 1.3

rdax	pot2,1.0
sof	1.0, -0.5	; subtract 0.5, if result is negative use fixed value, if positive use scaled value
skp	NEG, negative	; jump if negative
sof	1.0, 0.8	; was positive so ACC is between 0 and 0.5 so add 0.8 to make it range 0.8 to 1.3
skp	gez, done	; ACC is positive so jump over negative value code
negative:
sof	0, 0.8		; load fixed value
done:
<rest of code>
Sorry for the long time, I tried it but it doesn't work on the effect as I like to. I'll save it for another one. Thanks!!!
Post Reply