Hi,
I've created a basic tremolo algorithm but want to be able to alter the sine wave shape. This would be much easier on a general purpose processor, but how can this be accomplished with the FV-1?
Thanks.
Modifying wave shape
Moderator: frank
There are a number of ways to generate wave shapes. Is there a particular waveform you need to generate?
Frank Thomson
Experimental Noize
Experimental Noize
-
- Posts: 34
- Joined: Thu Nov 09, 2006 6:58 am
- Contact:
I think the simplest implementation would be a variable wave-shape tremolo, such that one of the POTs is used to fade between a sine wave and a square wave. I think you could just have two waves running at the same time and multiply sin by the POT value and sqr by 1/POT value.
My question is, how do we do sin, tri and sqr waves on the FV-1 without using the SIN or RAMP generators? Or if we DO use the onboard generators, is there a way to do it that leaves at least one RAMP free for doing a delay or pitch shift at the same time?
Matt Farrow
My question is, how do we do sin, tri and sqr waves on the FV-1 without using the SIN or RAMP generators? Or if we DO use the onboard generators, is there a way to do it that leaves at least one RAMP free for doing a delay or pitch shift at the same time?
Matt Farrow
Basically run a recursive equation to generate the desired waveform. As an example, this will generate SIN and COS waves and output the COS output to the left DAC output. POT0 controls frequency, POT1 controls amplitude.
Now you could use an RMPA instruction to read from the delay RAM by writing the COS value scaled and offset to operate within the delay length to the ADDR_PTR register.
Code: Select all
;sine wave generator
;
; SIN = SIN + freq * COS
; COS = COS - freq * SIN
; POT0 is frequency control
; POT1 is amp
; Define a couple register
equ s reg0
equ c reg1
; Initialize SIN to 0.5, COS to 0 on start
skp run,3
SOF 0,0.5 ;initialize SIN to 0.5
wrax s,0
wrax c,0 ;initialize COS to 0
;Normal program starts here
rdax c,1 ;Read COS
mulx pot0 ;freq * COS
rdax s,1 ;SIN + freq*COS
wrax s,-1 ;Save SIN and mult by -1
mulx pot0 ;freq*(-SIN)
rdax c,1 ;COS - freq*SIN
wrax c,1 ;Save COS
mulx pot1 ;scale output
wrax dacl,1 ; write output
Frank Thomson
Experimental Noize
Experimental Noize
-
- Posts: 34
- Joined: Thu Nov 09, 2006 6:58 am
- Contact:
Frank, thanks for the code. That takes care of the sine wave for the trem, you can just multiply the input by that number for tremolo. But what about a square wave? Square wave trem is certainly musically viable - any ideas on how to do a square wave in software (as opposed to the normal sin and ramp osc. in hardware.)
Thanks,
Matt Farrow
Thanks,
Matt Farrow
There are a number of ways to make a square wave. If you need just a square wave then using a counter is generally the easiest solution. Load counter, decrement each sample period, when it hits 0 flip the phase of the output and reload the counter.
Now while that is a simple method, in an earlier post you mentioned being able to cross-fade between a sin and square wave. In this case we would want the sin and square wave to be frequency and phased locked. A simple way to do this is use the sin wave to generate the square wave as is done in the following code. Basically I just use the sign of the sin wave to create the square wave (output on DAC right)
Now while that is a simple method, in an earlier post you mentioned being able to cross-fade between a sin and square wave. In this case we would want the sin and square wave to be frequency and phased locked. A simple way to do this is use the sin wave to generate the square wave as is done in the following code. Basically I just use the sign of the sin wave to create the square wave (output on DAC right)
Code: Select all
;sine + square generator
;
; SIN = SIN + freq * COS
; COS = COS - freq * SIN
; POT0 is frequency control
; POT1 is amp
; Define a couple register
equ s reg0
equ c reg1
; Initialize SIN to 0.5, COS to 0 on start
skp run,3
SOF 0,0.5 ;initialize SIN to 0.5
wrax s,0
wrax c,0 ;initialize COS to 0
;Normal program starts here
rdax c,1 ;Read COS
mulx pot0 ;freq * COS
rdax s,1 ;SIN + freq*COS
wrax s,-1 ;Save SIN and mult by -1
mulx pot0 ;freq*(-SIN)
rdax c,1 ;COS - freq*SIN
wrax c,1 ;Save COS
mulx pot1 ;scale output
wrax dacl,1 ; write output
skp NEG, out_low ; If negative, then skip
sof 0,0.5 ; Positive output
skp GEZ, scale_out ;Skip to the output step
out_low: sof 0,-0.5 ; Negative output
scale_out: mulx pot1
wrax dacr, 0
Frank Thomson
Experimental Noize
Experimental Noize
-
- Posts: 131
- Joined: Sun Nov 15, 2009 3:37 pm
- Location: New Orleans, LA US
I'm looking to do the same thing, except at audio frequencies. Can I use the audio sine generator example and add this:
?
Code: Select all
skp NEG, out_low ; If negative, then skip
sof 0,0.5 ; Positive output
skp GEZ, scale_out ;Skip to the output step
out_low: sof 0,-0.5 ; Negative output
scale_out: mulx pot1
Don't see why not, the code doesn't care where the sine wave comes from.
Frank Thomson
Experimental Noize
Experimental Noize