From 16921f14cff49372e55b3cfcc6e43f7be0bda1bc Mon Sep 17 00:00:00 2001 From: Aaron Zuspan <50475791+aazuspan@users.noreply.github.com> Date: Mon, 12 Aug 2024 18:43:36 -0700 Subject: [PATCH] Fix example patch tests and stop tracking prev and next tokens (#15) The example patch tests were broken because the parser was initialized but never run. Additionally, none of the example patches were complex enough to hit the recursion depth limit. I added a few longer patches and run the parser, which reproduced the recursion depth limit within tests. To fix the recursion limit, which was caused by deep copying tokens, and by extension all other tokens given that they are doubly linked, I removed tracking of previous and next tokens. This was initially implemented to handle multi-word instructions by traversing to neighboring tokens, but that is now handled by TokenRegistry, and there are no other apparent use cases. If I find that I need that functionality in the future, it can be re-implemented and the _clone method can be rewritten to avoid deeply copying neighboring tokens. --- src/spinasm_lsp/parser.py | 11 -- tests/patches/LICENSE | 1 - tests/patches/LICENSE.md | 5 + tests/patches/freeverb.spn | 240 +++++++++++++++++++++++++++++++++++++ tests/patches/rev_pl_1.spn | 196 ++++++++++++++++++++++++++++++ tests/patches/rev_pl_2.spn | 197 ++++++++++++++++++++++++++++++ tests/patches/rev_pl_3.spn | 197 ++++++++++++++++++++++++++++++ tests/test_parser.py | 2 +- 8 files changed, 836 insertions(+), 13 deletions(-) delete mode 100644 tests/patches/LICENSE create mode 100644 tests/patches/LICENSE.md create mode 100644 tests/patches/freeverb.spn create mode 100644 tests/patches/rev_pl_1.spn create mode 100644 tests/patches/rev_pl_2.spn create mode 100644 tests/patches/rev_pl_3.spn diff --git a/src/spinasm_lsp/parser.py b/src/spinasm_lsp/parser.py index 5173480..7c1e71b 100644 --- a/src/spinasm_lsp/parser.py +++ b/src/spinasm_lsp/parser.py @@ -52,10 +52,6 @@ class Token: The symbol parsed by asfv1 representing the token. range : lsp.Range The location range of the token in the source file. - next_token : Token | None - The token that follows this token in the source file. - prev_token : Token | None - The token that precedes this token in the source file. """ def __init__( @@ -67,8 +63,6 @@ def __init__( self.symbol: Symbol = symbol self.range: lsp.Range = lsp.Range(start=start, end=end) - self.next_token: Token | None = None - self.prev_token: Token | None = None def __repr__(self) -> str: return self.symbol["stxt"] @@ -135,11 +129,6 @@ def register_token(self, token: Token) -> None: if token.range.start.line not in self._tokens_by_line: self._tokens_by_line[token.range.start.line] = [] - # Record the previous and next token for each token to allow traversing - if self._prev_token: - token.prev_token = self._prev_token - self._prev_token.next_token = token - # Store the token on its line self._tokens_by_line[token.range.start.line].append(token) self._prev_token = token diff --git a/tests/patches/LICENSE b/tests/patches/LICENSE deleted file mode 100644 index 1057137..0000000 --- a/tests/patches/LICENSE +++ /dev/null @@ -1 +0,0 @@ -Reproduced from the Spin Semiconductor Guitar Amp Applications GA_DEMO programs, Copyright (C) 2018 Spin Semiconductor, Inc. \ No newline at end of file diff --git a/tests/patches/LICENSE.md b/tests/patches/LICENSE.md new file mode 100644 index 0000000..16522de --- /dev/null +++ b/tests/patches/LICENSE.md @@ -0,0 +1,5 @@ +The `Basic` and `GA_DEMO` patches are reproduced from the Spin Semiconductor [Guitar Amp Applications](https://www.spinsemi.com/guitar_amp_application.html) written by Keith Barr, Copyright (C) 2018 Spin Semiconductor, Inc. + +The `rev_pl` patches are reproduced from the [Free DSP Programs](https://www.spinsemi.com/programs.php) licensed under the Spin Semiconductor Open Reverb License, and were submitted by Harmon Grold. + +The `freeverb` patch is reproduced from an [FV-1 port by basilrush](http://www.spinsemi.com/forum/viewtopic.php?t=309) of the public domain [Freeverb algorithm by Jezar](https://github.com/sinshu/freeverb). \ No newline at end of file diff --git a/tests/patches/freeverb.spn b/tests/patches/freeverb.spn new file mode 100644 index 0000000..c8d51f3 --- /dev/null +++ b/tests/patches/freeverb.spn @@ -0,0 +1,240 @@ +; freeverb from +; http://www.spinsemi.com/forum/viewtopic.php?t=309 + +; pot0: combfeedback +; pot1: +; pot2: + +equ comb1filt 32 +equ comb2filt 33 +equ comb3filt 34 +equ comb4filt 35 +equ comb5filt 36 +equ comb6filt 37 +equ comb7filt 38 +equ comb8filt 39 + +equ combR1filt 32+12 +equ combR2filt 33+12 +equ combR3filt 34+12 +equ combR4filt 35+12 +equ combR5filt 36+12 +equ combR6filt 37+12 +equ combR7filt 38+12 +equ combR8filt 39+12 + +equ combfeedback pot0 +equ stereospread 23 +equ filtco 0.5 +equ allpassamt 0.5 +mem comb1 1116 +mem comb2 1188 +mem comb3 1277 +mem comb4 1356 +mem comb5 1422 +mem comb6 1491 +mem comb7 1557 +mem comb8 1617 + +mem combR1 1116+stereospread +mem combR2 1188+stereospread +mem combR3 1277+stereospread +mem combR4 1356+stereospread +mem combR5 1422+stereospread +mem combR6 1491+stereospread +mem combR7 1557+stereospread +mem combR8 1617+stereospread + +mem allpass1 556 +mem allpass2 441 +mem allpass3 341 +mem allpass4 225 + +mem allpassR1 556+stereospread +mem allpassR2 441+stereospread +mem allpassR3 341+stereospread +mem allpassR4 225+stereospread + +; LEFT CHANNEL + +;* NOW do freeverb style comb with lowpass filters, sum outputs +; output = delay output +; delay-input = [filteredoutput * feedback + input] + +; get delay and one pole low pass +rda comb1#, 1-filtco ; read delay output +rdax comb1filt, filtco ; filter using one sample delay +wrax comb1filt, 1 ; store one sample delay, scale by feedback amount +mulx combfeedback +rdax adcl, 0.5 ; add the input +wra comb1, 0 ; write to the buffer + +rda comb2#, 1-filtco ; read delay output +rdax comb2filt, filtco ; filter using one sample delay +wrax comb2filt, 1 ; store one sample delay, scale by feedback amount +mulx combfeedback +rdax adcl, 0.5 ; add the input +wra comb2, 0 ; write to the buffer + +rda comb3#, 1-filtco ; read delay output +rdax comb3filt, filtco ; filter using one sample delay +wrax comb3filt, 1 ; store one sample delay, scale by feedback amount +mulx combfeedback +rdax adcl, 0.5 ; add the input +wra comb3, 0 ; write to the buffer + +rda comb4#, 1-filtco ; read delay output +rdax comb4filt, filtco ; filter using one sample delay +wrax comb4filt, 1 ; store one sample delay, scale by feedback amount +mulx combfeedback +rdax adcl, 0.5 ; add the input +wra comb4, 0 ; write to the buffer + +rda comb5#, 1-filtco ; read delay output +rdax comb5filt, filtco ; filter using one sample delay +wrax comb5filt, 1 ; store one sample delay, scale by feedback amount +mulx combfeedback +rdax adcl, 0.5 ; add the input +wra comb5, 0 ; write to the buffer + +rda comb6#, 1-filtco ; read delay output +rdax comb6filt, filtco ; filter using one sample delay +wrax comb6filt, 1 ; store one sample delay, scale by feedback amount +mulx combfeedback +rdax adcl, 0.5 ; add the input +wra comb6, 0 ; write to the buffer + +rda comb7#, 1-filtco ; read delay output +rdax comb7filt, filtco ; filter using one sample delay +wrax comb7filt, 1 ; store one sample delay, scale by feedback amount +mulx combfeedback +rdax adcl, 0.5 ; add the input +wra comb7, 0 ; write to the buffer + +rda comb8#, 1-filtco ; read delay output +rdax comb8filt, filtco ; filter using one sample delay +wrax comb8filt, 1 ; store one sample delay, scale by feedback amount +mulx combfeedback +rdax adcl, 0.5 ; add the input +wra comb8, 0 ; write to the buffer + +; RIGHT CHANNEL + +;* NOW do freeverb style combR with lowpass filters, sum outputs +; output = delay output +; delay-input = [filteredoutput * feedback + input] + +; get delay and one pole low pass +rda combR1#, 1-filtco ; read delay output +rdax combR1filt, filtco ; filter using one sample delay +wrax combR1filt, 1 ; store one sample delay, scale by feedback amount +mulx combfeedback +rdax adcl, 0.5 ; add the input +wra combR1, 0 ; write to the buffer + +rda combR2#, 1-filtco ; read delay output +rdax combR2filt, filtco ; filter using one sample delay +wrax combR2filt, 1 ; store one sample delay, scale by feedback amount +mulx combfeedback +rdax adcl, 0.5 ; add the input +wra combR2, 0 ; write to the buffer + +rda combR3#, 1-filtco ; read delay output +rdax combR3filt, filtco ; filter using one sample delay +wrax combR3filt, 1 ; store one sample delay, scale by feedback amount +mulx combfeedback +rdax adcl, 0.5 ; add the input +wra combR3, 0 ; write to the buffer + +rda combR4#, 1-filtco ; read delay output +rdax combR4filt, filtco ; filter using one sample delay +wrax combR4filt, 1 ; store one sample delay, scale by feedback amount +mulx combfeedback +rdax adcl, 0.5 ; add the input +wra combR4, 0 ; write to the buffer + +rda combR5#, 1-filtco ; read delay output +rdax combR5filt, filtco ; filter using one sample delay +wrax combR5filt, 1 ; store one sample delay, scale by feedback amount +mulx combfeedback +rdax adcl, 0.5 ; add the input +wra combR5, 0 ; write to the buffer + +rda combR6#, 1-filtco ; read delay output +rdax combR6filt, filtco ; filter using one sample delay +wrax combR6filt, 1 ; store one sample delay, scale by feedback amount +mulx combfeedback +rdax adcl, 0.5 ; add the input +wra combR6, 0 ; write to the buffer + +rda combR7#, 1-filtco ; read delay output +rdax combR7filt, filtco ; filter using one sample delay +wrax combR7filt, 1 ; store one sample delay, scale by feedback amount +mulx combfeedback +rdax adcl, 0.5 ; add the input +wra combR7, 0 ; write to the buffer + +rda combR8#, 1-filtco ; read delay output +rdax combR8filt, filtco ; filter using one sample delay +wrax combR8filt, 1 ; store one sample delay, scale by feedback amount +mulx combfeedback +rdax adcl, 0.5 ; add the input +wra combR8, 0 ; write to the buffer + + +;LEFT CHANNEL + +;* NOW sum outputs +rda comb1#, 1 +rda comb2#, 1 +rda comb3#, 1 +rda comb4#, 1 +rda comb5#, 1 +rda comb6#, 1 +rda comb7#, 1 +rda comb8#, 1 + +; feed through allpass filters in series + +; get delay -> add to -1*acc -> + +rda allpass1#, -allpassamt +wrap allpass1, allpassamt +rda allpass2#, -allpassamt +wrap allpass2, allpassamt +rda allpass3#, -allpassamt +wrap allpass3, allpassamt +rda allpass4#, -allpassamt +wrap allpass4, allpassamt + + +;** OUTPUT +wrax dacl, 0 + +; RIGHT CHANNEL + +;* NOW sum outputs +rda combR1#, 1 +rda combR2#, 1 +rda combR3#, 1 +rda combR4#, 1 +rda combR5#, 1 +rda combR6#, 1 +rda combR7#, 1 +rda combR8#, 1 + +; feed through allpass filters in series + +; get delay -> add to -1*acc -> + +rda allpassR1#, -allpassamt +wrap allpassR1, allpassamt +rda allpassR2#, -allpassamt +wrap allpassR2, allpassamt +rda allpassR3#, -allpassamt +wrap allpassR3, allpassamt +;rda allpassR4#, -allpassamt +;wrap allpassR4, allpassamt + +;** OUTPUT +wrax dacr, 0 diff --git a/tests/patches/rev_pl_1.spn b/tests/patches/rev_pl_1.spn new file mode 100644 index 0000000..3bf02af --- /dev/null +++ b/tests/patches/rev_pl_1.spn @@ -0,0 +1,196 @@ +;plate reverb, lush (large), stereo +;characterized by very high density, +;explosive initial sound, large +;pot0 = reverb time +;pot1 = lf loss +;pot2 = hf loss + +mem api1l 224 ;left input all passes +mem api2l 430 +mem api3l 856 +mem api4l 1089 + +mem api1r 156 ;right input all passes +mem api2r 530 +mem api3r 956 +mem api4r 1289 + +mem apd1 2301 ;loop all passes +mem apd2 2902 +mem apd3 3171 +mem apd4 2401 + +mem del1 3620 ;loop delays +mem del2 4591 +mem del3 4387 +mem del4 3679 + +equ temp reg0 +equ krt reg1 +equ ksh reg2 +equ ksl reg3 +equ lap reg4 +equ rap reg5 +equ hp1 reg6 +equ hp2 reg7 +equ hp3 reg8 +equ hp4 reg9 +equ lp1 reg10 +equ lp2 reg11 +equ lp3 reg12 +equ lp4 reg13 +equ lup reg14 + +equ kapi 0.6 ;input AP coefficients +equ kap 0.6 ;loop AP coefficients +equ kfl 0.8 ;loop filter LPF freq +equ kfh 0.02 ;loop filter HPF freq + +;now derive control coefficients from pots: + +rdax pot0,1 +log 0.5,0 +exp 1,0 ;square root pot0 +sof 0.6,0.3 ;ranges 0.3 to 0.9 +wrax krt,0 ;write for later use + +rdax pot1,1 ;control low freq loss (high pass filter) +sof 1,-0.999 ;make from -1 to 0 +wrax ksh,0 ;high pass shelf + +rdax pot2,1 ;control high freq loss (low pass filter) +sof 1,-0.999 ;make from -1 to 0 +wrax ksl,0 ;low pass shelf + +;now do input all passes, leave headroom: + +rdax adcl,0.25 +rda api1l#,kapi +wrap api1l,-kapi +rda api2l#,kapi +wrap api2l,-kapi +rda api3l#,kapi +wrap api3l,-kapi +rda api4l#,kapi +wrap api4l,-kapi +wrax lap,0 + +rdax adcr,0.25 +rda api1r#,kapi +wrap api1r,-kapi +rda api2r#,kapi +wrap api2r,-kapi +rda api3r#,kapi +wrap api3r,-kapi +rda api4r#,kapi +wrap api4r,-kapi +wrax rap,1 + +;all passed inputs in place, now process the loop, with filtering: + +rdax lup,1 ;get signal from end of loop +rda apd1#,kap +wrap apd1,-kap ;do loop all pass +wra del1,0 ;write delay +rda del1#,1 ;read delay +wrax temp,1 ;save in temp reg +rdfx hp1,kfh ;do low pass filter +wrlx hp1,-1 ;infinite shelf LPF +mulx ksh ;prepare to subtract from temp +rdax temp,1 ;subtract LPF from input (becomes HPF) +wrax temp,1 ;save in temp reg +rdfx lp1,kfl ;do high pass filter +wrhx lp1,-1 ;infinite shelf HPF +mulx ksl ;prepare to subtract from temp +rdax temp,1 ;subtract HP signal from input (LPF shelf) +mulx krt ;scale by reverb time + ;continue to next stage of loop +rdax lap,1 +rda apd2#,kap +wrap apd2,-kap +wra del2,0 +rda del2#,1 +wrax temp,1 +rdfx hp2,kfh +wrlx hp2,-1 +mulx ksh +rdax temp,1 +wrax temp,1 +rdfx lp2,kfl +wrhx lp2,-1 +mulx ksl +rdax temp,1 +mulx krt + +rdax rap,1 +rda apd3#,kap +wrap apd3,-kap +wra del3,0 +rda del3#,1 +wrax temp,1 +rdfx hp3,kfh +wrlx hp3,-1 +mulx ksh +rdax temp,1 +wrax temp,1 +rdfx lp3,kfl +wrhx lp3,-1 +mulx ksl +rdax temp,1 +mulx krt + +rdax lap,1 +rda apd4#,kap +wrap apd4,-kap +wra del4,0 +rda del4#,1 +wrax temp,1 +rdfx hp4,kfh +wrlx hp4,-1 +mulx ksh +rdax temp,1 +wrax temp,1 +rdfx lp4,kfl +wrhx lp4,-1 +mulx ksl +rdax temp,1 +mulx krt +wrax lup,0 + +;now gather outputs from loop delays: + +rda del1+201,0.8 +rda del2+1345,0.7 +rda del3+897,0.6 +rda del4+1780,0.5 +wrax dacl,0 + +rda del1+1201,0.8 +rda del2+145,0.7 +rda del3+487,0.6 +rda del4+780,0.5 +wrax dacr,0 + +;now generate a pair of LFOs to modulate the APs in the loop: + +skp run,2 +wlds 0,12,37 +wlds 1,15,33 + +;now affect each delay: + +cho rda,sin0,reg|sin|compc,apd1+40 +cho rda,sin0,sin,apd1+41 +wra apd1+80,0 + +cho rda,sin0,cos|compc,apd2+40 +cho rda,sin0,cos,apd2+41 +wra apd2+80,0 + +cho rda,sin1,reg|sin|compc,apd3+40 +cho rda,sin0,sin,apd3+41 +wra apd3+80,0 + +cho rda,sin1,cos|compc,apd4+40 +cho rda,sin0,cos,apd4+41 +wra apd4+80,0 \ No newline at end of file diff --git a/tests/patches/rev_pl_2.spn b/tests/patches/rev_pl_2.spn new file mode 100644 index 0000000..7bb38df --- /dev/null +++ b/tests/patches/rev_pl_2.spn @@ -0,0 +1,197 @@ +;plate reverb, tight, stereo +;characterized by very high density, +;slight tinnyness, +;explosive initial sound +;pot0 = reverb time +;pot1 = lf loss +;pot2 = hf loss + +mem api1l 123 ;left input all passes +mem api2l 224 +mem api3l 546 +mem api4l 868 + +mem api1r 213 ;right input all passes +mem api2r 342 +mem api3r 421 +mem api4r 978 + +mem apd1 1301 ;loop all passes +mem apd2 1902 +mem apd3 2171 +mem apd4 1401 + +mem del1 2620 ;loop delays +mem del2 2591 +mem del3 2387 +mem del4 2679 + +equ temp reg0 +equ krt reg1 +equ ksh reg2 +equ ksl reg3 +equ lap reg4 +equ rap reg5 +equ hp1 reg6 +equ hp2 reg7 +equ hp3 reg8 +equ hp4 reg9 +equ lp1 reg10 +equ lp2 reg11 +equ lp3 reg12 +equ lp4 reg13 +equ lup reg14 + +equ kapi 0.65 ;input AP coefficients +equ kap 0.6 ;loop AP coefficients +equ kfl 0.8 ;loop filter LPF freq +equ kfh 0.02 ;loop filter HPF freq + +;now derive control coefficients from pots: + +rdax pot0,1 +log 0.5,0 +exp 1,0 ;square root pot0 +sof 0.6,0.3 ;ranges 0.3 to 0.9 +wrax krt,0 ;write for later use + +rdax pot1,1 ;control low freq loss (high pass filter) +sof 1,-0.999 ;make from -1 to 0 +wrax ksh,0 ;high pass shelf + +rdax pot2,1 ;control high freq loss (low pass filter) +sof 1,-0.999 ;make from -1 to 0 +wrax ksl,0 ;low pass shelf + +;now do input all passes, leave headroom: + +rdax adcl,0.25 +rda api1l#,kapi +wrap api1l,-kapi +rda api2l#,kapi +wrap api2l,-kapi +rda api3l#,kapi +wrap api3l,-kapi +rda api4l#,kapi +wrap api4l,-kapi +wrax lap,0 + +rdax adcr,0.25 +rda api1r#,kapi +wrap api1r,-kapi +rda api2r#,kapi +wrap api2r,-kapi +rda api3r#,kapi +wrap api3r,-kapi +rda api4r#,kapi +wrap api4r,-kapi +wrax rap,1 + +;all passed inputs in place, now process the loop, with filtering: + +rdax lup,1 ;get signal from end of loop +rda apd1#,kap +wrap apd1,-kap ;do loop all pass +wra del1,0 ;write delay +rda del1#,1 ;read delay +wrax temp,1 ;save in temp reg +rdfx hp1,kfh ;do low pass filter +wrlx hp1,-1 ;infinite shelf LPF +mulx ksh ;prepare to subtract from temp +rdax temp,1 ;subtract LPF from input (becomes HPF) +wrax temp,1 ;save in temp reg +rdfx lp1,kfl ;do high pass filter +wrhx lp1,-1 ;infinite shelf HPF +mulx ksl ;prepare to subtract from temp +rdax temp,1 ;subtract HP signal from input (LPF shelf) +mulx krt ;scale by reverb time + ;continue to next stage of loop +rdax lap,1 +rda apd2#,kap +wrap apd2,-kap +wra del2,0 +rda del2#,1 +wrax temp,1 +rdfx hp2,kfh +wrlx hp2,-1 +mulx ksh +rdax temp,1 +wrax temp,1 +rdfx lp2,kfl +wrhx lp2,-1 +mulx ksl +rdax temp,1 +mulx krt + +rdax rap,1 +rda apd3#,kap +wrap apd3,-kap +wra del3,0 +rda del3#,1 +wrax temp,1 +rdfx hp3,kfh +wrlx hp3,-1 +mulx ksh +rdax temp,1 +wrax temp,1 +rdfx lp3,kfl +wrhx lp3,-1 +mulx ksl +rdax temp,1 +mulx krt + +rdax lap,1 +rda apd4#,kap +wrap apd4,-kap +wra del4,0 +rda del4#,1 +wrax temp,1 +rdfx hp4,kfh +wrlx hp4,-1 +mulx ksh +rdax temp,1 +wrax temp,1 +rdfx lp4,kfl +wrhx lp4,-1 +mulx ksl +rdax temp,1 +mulx krt +wrax lup,0 + +;now gather outputs from loop delays: + +rda del1+201,0.8 +rda del2+145,0.7 +rda del3+1897,0.6 +rda del4+280,0.5 +wrax dacl,0 + +rda del1+1897,0.8 +rda del2+1245,0.7 +rda del3+487,0.6 +rda del4+780,0.5 +wrax dacr,0 + +;now generate a pair of LFOs to modulate the APs in the loop: + +skp run,2 +wlds 0,12,37 +wlds 1,15,33 + +;now affect each delay: + +cho rda,sin0,reg|sin|compc,apd1+40 +cho rda,sin0,sin,apd1+41 +wra apd1+80,0 + +cho rda,sin0,cos|compc,apd2+40 +cho rda,sin0,cos,apd2+41 +wra apd2+80,0 + +cho rda,sin1,reg|sin|compc,apd3+40 +cho rda,sin0,sin,apd3+41 +wra apd3+80,0 + +cho rda,sin1,cos|compc,apd4+40 +cho rda,sin0,cos,apd4+41 +wra apd4+80,0 \ No newline at end of file diff --git a/tests/patches/rev_pl_3.spn b/tests/patches/rev_pl_3.spn new file mode 100644 index 0000000..8aa5130 --- /dev/null +++ b/tests/patches/rev_pl_3.spn @@ -0,0 +1,197 @@ +;plate reverb, very tight, stereo +;characterized by extreme density, +;slight tinnyness, +;explosive initial sound +;pot0 = reverb time +;pot1 = lf loss +;pot2 = hf loss + +mem api1l 123 ;left input all passes +mem api2l 264 +mem api3l 606 +mem api4l 768 + +mem api1r 163 ;right input all passes +mem api2r 322 +mem api3r 591 +mem api4r 778 + +mem apd1 1201 ;loop all passes +mem apd2 782 +mem apd3 1071 +mem apd4 947 + +mem del1 1190 ;loop delays +mem del2 1091 +mem del3 1287 +mem del4 1379 + +equ temp reg0 +equ krt reg1 +equ ksh reg2 +equ ksl reg3 +equ lap reg4 +equ rap reg5 +equ hp1 reg6 +equ hp2 reg7 +equ hp3 reg8 +equ hp4 reg9 +equ lp1 reg10 +equ lp2 reg11 +equ lp3 reg12 +equ lp4 reg13 +equ lup reg14 + +equ kapi 0.65 ;input AP coefficients +equ kap 0.65 ;loop AP coefficients +equ kfl 0.8 ;loop filter LPF freq +equ kfh 0.02 ;loop filter HPF freq + +;now derive control coefficients from pots: + +rdax pot0,1 +log 0.5,0 +exp 1,0 ;square root pot0 +sof 0.53,0.4 ;ranges 0.4 to 0.93 +wrax krt,0 ;write for later use + +rdax pot1,1 ;control low freq loss (high pass filter) +sof 1,-0.999 ;make from -1 to 0 +wrax ksh,0 ;high pass shelf + +rdax pot2,1 ;control high freq loss (low pass filter) +sof 1,-0.999 ;make from -1 to 0 +wrax ksl,0 ;low pass shelf + +;now do input all passes, leave headroom: + +rdax adcl,0.25 +rda api1l#,kapi +wrap api1l,-kapi +rda api2l#,kapi +wrap api2l,-kapi +rda api3l#,kapi +wrap api3l,-kapi +rda api4l#,kapi +wrap api4l,-kapi +wrax lap,0 + +rdax adcr,0.25 +rda api1r#,kapi +wrap api1r,-kapi +rda api2r#,kapi +wrap api2r,-kapi +rda api3r#,kapi +wrap api3r,-kapi +rda api4r#,kapi +wrap api4r,-kapi +wrax rap,1 + +;all passed inputs in place, now process the loop, with filtering: + +rdax lup,1 ;get signal from end of loop +rda apd1#,kap +wrap apd1,-kap ;do loop all pass +wra del1,0 ;write delay +rda del1#,1 ;read delay +wrax temp,1 ;save in temp reg +rdfx hp1,kfh ;do low pass filter +wrlx hp1,-1 ;infinite shelf LPF +mulx ksh ;prepare to subtract from temp +rdax temp,1 ;subtract LPF from input (becomes HPF) +wrax temp,1 ;save in temp reg +rdfx lp1,kfl ;do high pass filter +wrhx lp1,-1 ;infinite shelf HPF +mulx ksl ;prepare to subtract from temp +rdax temp,1 ;subtract HP signal from input (LPF shelf) +mulx krt ;scale by reverb time + ;continue to next stage of loop +rdax lap,1 +rda apd2#,kap +wrap apd2,-kap +wra del2,0 +rda del2#,1 +wrax temp,1 +rdfx hp2,kfh +wrlx hp2,-1 +mulx ksh +rdax temp,1 +wrax temp,1 +rdfx lp2,kfl +wrhx lp2,-1 +mulx ksl +rdax temp,1 +mulx krt + +rdax rap,1 +rda apd3#,kap +wrap apd3,-kap +wra del3,0 +rda del3#,1 +wrax temp,1 +rdfx hp3,kfh +wrlx hp3,-1 +mulx ksh +rdax temp,1 +wrax temp,1 +rdfx lp3,kfl +wrhx lp3,-1 +mulx ksl +rdax temp,1 +mulx krt + +rdax lap,1 +rda apd4#,kap +wrap apd4,-kap +wra del4,0 +rda del4#,1 +wrax temp,1 +rdfx hp4,kfh +wrlx hp4,-1 +mulx ksh +rdax temp,1 +wrax temp,1 +rdfx lp4,kfl +wrhx lp4,-1 +mulx ksl +rdax temp,1 +mulx krt +wrax lup,0 + +;now gather outputs from loop delays: + +rda del1+201,0.8 +rda del2+145,0.7 +rda del3+697,0.6 +rda del4+580,0.5 +wrax dacl,0 + +rda del1+697,0.8 +rda del2+845,0.7 +rda del3+487,0.6 +rda del4+780,0.5 +wrax dacr,0 + +;now generate a pair of LFOs to modulate the APs in the loop: + +skp run,2 +wlds 0,12,37 +wlds 1,15,33 + +;now affect each delay: + +cho rda,sin0,reg|sin|compc,apd1+40 +cho rda,sin0,sin,apd1+41 +wra apd1+80,0 + +cho rda,sin0,cos|compc,apd2+40 +cho rda,sin0,cos,apd2+41 +wra apd2+80,0 + +cho rda,sin1,reg|sin|compc,apd3+40 +cho rda,sin0,sin,apd3+41 +wra apd3+80,0 + +cho rda,sin1,cos|compc,apd4+40 +cho rda,sin0,cos,apd4+41 +wra apd4+80,0 \ No newline at end of file diff --git a/tests/test_parser.py b/tests/test_parser.py index 6f4394a..5742703 100644 --- a/tests/test_parser.py +++ b/tests/test_parser.py @@ -14,7 +14,7 @@ def test_example_patches(patch): """Test that the example patches from SPINAsm are parsable.""" with open(patch, encoding="utf-8") as f: - assert SPINAsmParser(f.read()) + assert SPINAsmParser(f.read()).parse() @pytest.fixture()