I added a block of the tone control code for code Ring modulator. Where'd I go wrong? Why is this a bug? I want answers!
;POT0 : Control frequency
;
equ s reg0
equ c reg1 equ lp_filt reg2
;Then initialize the oscillator by setting one to xero and the other to -1
;we do this just once, during the first cycle of operation
skp run,endset ;do not execute if already running
wrax s,0 ;set s to 0, (acc should be zero)
sof 0,-1 ;set accum to -1
wrax c,0 ;write to c
endset: ;jump-to label
;Now do the LFO, using pot0 as a control for frequency
rdax s,0.02 ;read the s register, change this value between 0.001 and 1.0
mulx pot0 ;multiply by pot value
rdax c,1 ;read the c register
wrax c,-0.02 ;integrate the c value, this value MUST be the negative of
;what ever you set the value in 'rdax s,X' to above
mulx pot0 ;multiply by pot value
rdax s,1 ;read s reg
wrax s,1 ;integrate the s value
;Either the s or c register will be producing s waveforms (just shifted in
;phase), so either can be used as a modulation source. The maximum
;frequency of this LFO is Fs/2pi, which should be high enough!
rdax lp_filt,-1.0 ; ADCL - lp_filt
mulx pot1 ; * C (POT1 in this case)
rdax lp_filt,1.0 ; +lp_filt
wrax lp_filt,1.0; write result to lp_filt
mulx adcl
;and output the result
wrax dacl,0
I want to POT2 it was a MIX between the effect and clean guitar. How to do it? I want to apply it in other codes too .
With the addition of reverb to Octaver also released failure: (I want a more detailed explanation. What a block of code should I use? How to determine the beginning and end of the block and how to properly use the code.
rdax pot2, 1.0 ; Read in pot 2
sof 0.25, -0.125 ; POT2 in ACC, -0.125 to +0.125
rdfx potfil, 0.02 ; Smooth the result to avoid jumping
wrax potfil, 1.0
wrax rmp0_rate, 0 ; Write to LFO control register
; Do the pitch shift:
rdax adcl,1.0 ; Read in a value, ADCL * 1.0 -> ACC
wra pdel,0 ; Write it to memory address 0
cho rda,rmp0,reg|compc,pdel ; (1-k)*sample[addr]
cho rda,rmp0,0,pdel+1 ; k*sample[addr+1] + ACC
wra pmix,0 ; Save it off to memory and clear ACC
; Do other transposer tap:
cho rda,rmp0,rptr2|compc,pdel ; (1-k)*sample[addr+ half ramp]
cho rda,rmp0,rptr2,pdel+1 ; k*sample[addr+ half ramp + 1] + ACC
;crossfade between taps:
cho sof,rmp0,na|compc,0 ; Result in ACC, multiply it by (1-XFADE) coefficient
cho rda,rmp0,na, pmix ; Add value saved in memory, multiply value by XFADE coefficient
wrax dacl,0 ; Write it to DACL and clear ACC
;sum inputs to mono:
rdax adcl,0.5
rdax adcr,0.5
wrax mono,0
;do reverb and put result in revout (after pot0 control):
cho rda,sin0,sin|reg|compc,lap1b+100
cho rda,sin0,sin,lap1b+101
wra lap1b+200,0
cho rda,sin0,sin|reg|compc,lap2b+100
cho rda,sin0,sin,lap2b+101
wra lap2b+200,0
;Now do wah, a 2 pole LPF, peaking.
;begin by getting control level into detector:
rdax mono,1 ;get input
absa ;absolute value
rdfx avg,0.01 ;average input level
wrax avg,0 ;write avg level, pass on
rdax lavg,0.001
sof -0.01,0
rdax lavg,1
wrax temp,0
rdax avg,1
maxx temp,1 ;filter a long average
wrax lavg,0
;now set up a means by which the sensitivity control can affect the filter frequency:
rdax lavg,1
sof 1,0.002 ;never let lavg go to zero
log 1,0
wrax temp,0
rdax avg,1
log 1,0
rdax temp,-1
mulx pot1
exp 1,0
rdfx ffil,0.0005
wrax ffil,1
sof 0.7,0.02 ;limit frequency range
wrax wf,0
;get wfq value from pot2:
rdax pot1,1
sof -0.2,0.25 ;make 0.3 to 0.05
wrax wq,0 ;write Q value (pos number)
; Do the pitch shift:
rdax adcl,1.0 ; Read in a value, ADCL * 1.0 -> ACC
wra pdel,0 ; Write it to memory address 0
cho rda,rmp0,reg|compc,pdel ; (1-k)*sample[addr]
cho rda,rmp0,0,pdel+1 ; k*sample[addr+1] + ACC
wra pmix,0 ; Save it off to memory and clear ACC
; Do other transposer tap:
cho rda,rmp0,rptr2|compc,pdel ; (1-k)*sample[addr+ half ramp]
cho rda,rmp0,rptr2,pdel+1 ; k*sample[addr+ half ramp + 1] + ACC
;crossfade between taps:
cho sof,rmp0,na|compc,0 ; Result in ACC, multiply it by (1-XFADE) coefficient
cho rda,rmp0,na, pmix ; Add value saved in memory, multiply value by XFADE coefficient
wrax dacl,0 ; Write it to DACL and clear ACC <<<<<<<< WRITING TO DACL
;now combine outputs to make a wahout signal
rdax mono,-1
rdax wf2,1
mulx bypass
rdax mono,1
wrax wahout,1
rdax revout,1
sof 1,0.02
wrax dacl,1 ;<<<<<<<< YOU ARE OVERWRITING DACL
sof 1,-0.04
wrax dacr,0
What you should be doing is saving the result of each step to a register then adding them all together at the end then writing to DACL or DACR
Is there a debugger for SpinAsm (like Turbo debugger for TASM) to track the value of registers after each operation?
Would be of great help to me as lurking through the code trying to memorize which value you have when there are 15 registers is truly slowing down.
Would also help to avoid mistakes like one stated above with overwriting sectors.
Fulcrum wrote:Is there a debugger for SpinAsm (like Turbo debugger for TASM) to track the value of registers after each operation?
Nope, no debugger available.
Fulcrum wrote:
Would be of great help to me as lurking through the code trying to memorize which value you have when there are 15 registers is truly slowing down.
Would also help to avoid mistakes like one stated above with overwriting sectors.
There are some rules I like to follow that help:
Always name registers, it is easier to see a mistake when writing to a named register that a numbered one.
Only write to the DACL and DACR at then end of the program, it is rare you will ever need to write in the middle of the program.
Search for DACL and DACR in your code if there is a problem, there should only be one of each and should always follow the format "wrax DACL,x" where x is a number.
rdax pot2, 1.0 ; Read in pot 2
sof 0.25, -0.125 ; POT2 in ACC, -0.125 to +0.125
rdfx potfil, 0.02 ; Smooth the result to avoid jumping
wrax potfil, 1.0
wrax rmp0_rate, 0 ; Write to LFO control register
; Do the pitch shift:
rdax adcl,1.0 ; Read in a value, ADCL * 1.0 -> ACC
wra pdel,0 ; Write it to memory address 0
cho rda,rmp0,reg|compc,pdel ; (1-k)*sample[addr]
cho rda,rmp0,0,pdel+1 ; k*sample[addr+1] + ACC
wra pmix,0 ; Save it off to memory and clear ACC
; Do other transposer tap:
cho rda,rmp0,rptr2|compc,pdel ; (1-k)*sample[addr+ half ramp]
cho rda,rmp0,rptr2,pdel+1 ; k*sample[addr+ half ramp + 1] + ACC
;crossfade between taps:
cho sof,rmp0,na|compc,0 ; Result in ACC, multiply it by (1-XFADE) coefficient
cho rda,rmp0,na, pmix ; Add value saved in memory, multiply value by XFADE coefficient
wrax potfil,0 ; Write it to reg15 and clear ACC
;sum inputs to mono:
rdax potfil,0.5
rdax adcr,0.5
wrax mono,0
;do reverb and put result in revout (after pot0 control):
cho rda,sin0,sin|reg|compc,lap1b+100
cho rda,sin0,sin,lap1b+101
wra lap1b+200,0
cho rda,sin0,sin|reg|compc,lap2b+100
cho rda,sin0,sin,lap2b+101
wra lap2b+200,0
;Now do wah, a 2 pole LPF, peaking.
;begin by getting control level into detector:
rdax mono,1 ;get input
absa ;absolute value
rdfx avg,0.01 ;average input level
wrax avg,0 ;write avg level, pass on
rdax lavg,0.001
sof -0.01,0
rdax lavg,1
wrax temp,0
rdax avg,1
maxx temp,1 ;filter a long average
wrax lavg,0
;now set up a means by which the sensitivity control can affect the filter frequency:
rdax lavg,1
sof 1,0.002 ;never let lavg go to zero
log 1,0
wrax temp,0
rdax avg,1
log 1,0
rdax temp,-1
mulx pot1
exp 1,0
rdfx ffil,0.0005
wrax ffil,1
sof 0.7,0.02 ;limit frequency range
wrax wf,0
;get wfq value from pot2:
rdax pot1,1
sof -0.2,0.25 ;make 0.3 to 0.05
wrax wq,0 ;write Q value (pos number)
rdax pot1,1
rdax bypass,0.9 ;recursive gain
wrax bypass,0
;now combine outputs to make a wahout signal
rdax mono,-1
rdax wf2,1
mulx bypass
rdax mono,1
wrax wahout,1
rdax revout,1
sof 1,0.02
wrax dacl,1
sof 1,-0.04
wrax dacr,0
;Insane Pitch+sin_modulation+reverb
;pitch transopse in left channel, echo in right chan
;pot0 adjusts pitch
;pot1 adjusts sin modulation
;pot2 adjusts reverb
mem pdel 4096 ;delay for pitch transposing
mem pmix 1
mem ap1 334
mem ap2 556
mem ap3 871
mem lap1a 808
mem lap1b 1934
mem d1 2489
mem lap2a 1016
mem lap2b 1787
mem d2 2287
; Initialization, only run on first executuion of code
; Skip the following two instructions if NOT the first time
;------------------------------------------------------------------------
skp RUN, loop
wldr 0, 0, 4096 ; Load up ramp0 LFO to shift up 0 octaves, A=0x0 (4096 range)
clr ; Clear ACC
wrax s,0 ; Write 0 to sin reg
sof 0,0.5 ; 0.5 -> ACC
wrax c,0 ; Write 0.5 to cos reg
loop:
;-------------------------------------------------------------
;set up pot0 to control pitch shift:
rdax pot0, 1.0 ; Read in pot 0
sof 0.25, -0.125 ; POT0 in ACC, -0.125 to +0.125
rdfx potfil, 0.02 ; Smooth the result to avoid jumping
wrax potfil, 1.0
wrax rmp0_rate, 0 ; Write to LFO control register
; Do the pitch shift:
rdax adcl,1.0 ; Read in a value, ADCL * 1.0 -> ACC
wra pdel,0 ; Write it to memory address 0
cho rda,rmp0,reg|compc,pdel ; (1-k)*sample[addr]
cho rda,rmp0,0,pdel+1 ; k*sample[addr+1] + ACC
wra pmix,0 ; Save it off to memory and clear ACC
; Do other transposer tap:
cho rda,rmp0,rptr2|compc,pdel ; (1-k)*sample[addr+ half ramp]
cho rda,rmp0,rptr2,pdel+1 ; k*sample[addr+ half ramp + 1] + ACC
;crossfade between taps:
cho sof,rmp0,na|compc,0 ; Result in ACC, multiply it by (1-XFADE) coefficient
cho rda,rmp0,na, pmix ; Add value saved in memory, multiply value by XFADE coefficient
wrax potfil,0 ; Write it to DACL and clear ACC
clr
rdax pot1, 0.05 ; Read pot 1, scale to adjust max speed
wrax freq, 0 ; Save the freq coefficient
;
; Do the SIN calculation
rdax c, 1.0 ; COS -> ACC
mulx freq ; COS*fcoeff
rdax s, 1.0 ; +SIN
wrax s,0 ; Write it back
;
; Do the COS calculation, -SIN in ACC
rdax s, -1.0
mulx freq
rdax c, 1.0
wrax c, 0
;
; Modulate the inputs and write them to the regs
ldax adcl
mulx s
wrax wahl,0
ldax adcr
mulx s
wrax wahr,0
cho rda,sin0,sin|reg|compc,lap1b+100
cho rda,sin0,sin,lap1b+101
wra lap1b+200,0
cho rda,sin0,sin|reg|compc,lap2b+100
cho rda,sin0,sin,lap2b+101
wra lap2b+200,0
Remove everything except pitch shifting and try to get that going first. It is difficult to debug a program with so much going on, you need to attack the problem in smaller steps.
Hi guys! I need your advice! I need to POT1 worked opposite. Ie with a minimum of POT1 was the maximum volume, and would decrease with increasing values of POT1. Thank you! Sincerely, Alex.