Sequencer

Algorithm development and general DSP issues

Moderator: frank

Post Reply
livingston
Posts: 131
Joined: Sun Nov 15, 2009 3:37 pm
Location: New Orleans, LA US

Sequencer

Post by livingston »

I've been interested in having a sequencer to control parameters in the FV-1. I tried to code up something but it failed miserably. :D

Basically, I want to be able to have a time-varying sequencer that steps through 3 or 4 values, then goes back to the beginning of the sequence. A pot would control the amount of time between steps, and the values to step through would be predetermined in the program. I figured it would go something like this

1 load a register with -1
2 add .0001 every sample
3 when the number goes positive, add x [x= the parameter value of step 1]
4 write to parameter
5 SOF back to -1
6 repeat 1-5

The problem is (even if this worked), it would never repeat, it would just add to the parameter over and over which would quickly clip to 1.999...

So I don't think this is the right approach. Any thoughts?
frank
Posts: 1244
Joined: Wed Oct 19, 2005 12:26 pm
Contact:

Post by frank »

Well, you just need to reset the counter/parameter/whatever when it hits terminal count. Maybe something like:

initialize count to -1 (using skp run)

count = count + 0.25
if count >= 0 count = -1
if count == -1, set param = a
if count == -.75 set param = b
if count == -5 set param = c
if count == 0 set param = d

Code here that uses param

If you add to param then you will need to check if it exceeds a value and reset it if it does.
Frank Thomson
Experimental Noize
livingston
Posts: 131
Joined: Sun Nov 15, 2009 3:37 pm
Location: New Orleans, LA US

Post by livingston »

How would I code the statements like "if count = -5"? Would that use the AND opcode?
frank
Posts: 1244
Joined: Wed Oct 19, 2005 12:26 pm
Contact:

Post by frank »

Since there is no "if" statement in FV-1 you need to deduce the value of a register, something like:

(assume CTR is a register, it holds a number from -1 to 0, 0 or + is a terminal condition where the register is reloaded with -1 and all that logic is above this code)

Code: Select all

clr             ; clear the ACC
rdax   CTR,1.0    ; read CTR
sof 1,0.25         ; add 0.25
skp   gez, param1   ;skip to routine to load param 1 if >= 0
sof 1,0.25         ; add 0.25
skp   gez, param2   ;skip to routine to load param 2 if >= 0
sof 1,0.25         ; add 0.25
skp   gez, param3   ;skip to routine to load param 3 if >= 0
sof 1,0.25         ; add 0.25
skp   gez, param4   ;skip to routine to load param 4 if >= 0

param1:
clr
or 0x7fffff
wrax param,0
skp gez, algo

param2:
clr
or 0x3fffff
wrax param,0
skp gez, algo

param3:
clr
or 0x1fffff
wrax param,0
skp gez, algo

param4:
clr
or 0x0fffff
wrax param,0
skp gez, algo


algo:
; put the routine here and use param reg as the coefficient/etc.
I have not tested the above code but it should work (ok, probably a typo or two) and there are things you may be able to do to shorten it if the coefficients are related in some fashion.
Frank Thomson
Experimental Noize
Alex MAK
Posts: 89
Joined: Fri Nov 05, 2010 1:00 pm

Post by Alex MAK »

Hi, guys! Please tell me how to make it work. For example to make it work with tremolo. Thank you! Best regards, Alex!
livingston
Posts: 131
Joined: Sun Nov 15, 2009 3:37 pm
Location: New Orleans, LA US

Post by livingston »

Alex, as Frank says at the end of his code, put your tremolo code after, then use the "param" register as your sequenced value. You could apply this to volume to make a random "tremolo" or you could apply it to the speed of the tremolo.
Alex MAK
Posts: 89
Joined: Fri Nov 05, 2010 1:00 pm

Post by Alex MAK »

I want to apply it to the speed of the tremolo. To speed sequencer operated POT0. I tried to do this but my attempts do not work.

Code: Select all

equ	mono	reg0
equ	trem	reg1
equ	param	reg2
;equ	CTR	reg3		

clr             ; clear the ACC 
rdax   pot0,1.0    ; read CTR 
sof 1,0.25         ; add 0.25 
skp   gez, param1   ;skip to routine to load param 1 if >= 0 
sof 1,0.25         ; add 0.25 
skp   gez, param2   ;skip to routine to load param 2 if >= 0 
sof 1,0.25         ; add 0.25 
skp   gez, param3   ;skip to routine to load param 3 if >= 0 
sof 1,0.25         ; add 0.25 
skp   gez, param4   ;skip to routine to load param 4 if >= 0 

param1: 
clr 
or 0x7fffff 
wrax param,0 
skp gez, algo 

param2: 
clr 
or 0x3fffff 
wrax param,0 
skp gez, algo 

param3: 
clr 
or 0x1fffff 
wrax param,0 
skp gez, algo 

param4: 
clr 
or 0x0fffff 
wrax param,0 
skp gez, algo 


algo: 
; put the routine here and use param reg as the coefficient/etc. 

rdax	adcl,1
rdax	adcr,1
wrax	mono,0	;attenuate into reverb

rdax	param,1		;get control pot
mulx	param		;square function
sof	0.4,0.1		;scale rate to reasonable range
wrax	sin1_rate,0	;write to sin1 rate register

cho	rdal,sin1		;get sinewave, +/-0.5
sof	1,0.5		;add 1/2 to get sinwave that swings 0 to 1
wrax	trem,0		;write tremelo modulation signal

rdax	mono,0.5	;attenuate signals so as not to clip
mulx	trem
sof	0.75,0		;boost tremelo to maintain average amplitude
rdax	mono,-0.5
mulx	pot2		;crossover between input and tremelo with pot2
rdax	mono,0.5
sof	1.999,0		;recover gain
wrax	dacl,1
wrax	dacr,0
Post Reply