Octave Down Patch - OC-2 & U-Boat Style

Algorithm development and general DSP issues

Moderator: frank

Post Reply
Philcaster
Posts: 4
Joined: Mon Feb 24, 2020 2:12 pm

Octave Down Patch - OC-2 & U-Boat Style

Post by Philcaster »

First time posting code here! I was working on a vero build of a chopped OC-2 (still haven't gotten around to finishing it) and got really curious about how it worked. That led me to the Valve Wizard U-Boat page. After reading it about 4 times, I started to have an idea of what he was talking about, and then realized everything he described I knew how to do roughly on the fv-1.

So this is a patch that tries to implement the U-Boat method for octave down as described in the article.

It came out fairly well in my opinion, on guitar or bass. The tracking of course isn't perfect, but to me it's very usable.

I borrowed a friend's OC-2 to compare. There's a comment in the Valve Wizard U-Boat article that says that the boss method (inverting at the peaks) has a smoother sound, the u-boat method (invert on zero crossing) has more harmonic content. My code is the u-boat way since he said that way is easier to implement with decent tracking. Playing this patch next to the OC-2, the OC-2 is definetely smoother, and tracks slightly better. On bass, you can dial it in to sound kinda subtle (like your bass tone but fatter). But, I also kinda like the more aggressive tone of this code. I haven't played a u-boat circuit to compare.

As an afterthought, I threw on a rectify dirty octave up (absa code line), like a green ringer, controlled by pot2. It's kind of fun to blend with the octave down.

I was also helped by reading this old code post by Don Stavely, has a lot of similarities to what I wanted to do, so it helped me get my bearings a bit.
http://www.spinsemi.com/forum/viewtopic.php?t=161
--Feb 17 code post

I'd love to hear any feedback if you try it out. The oct down can get fairly loud, so take it easy, especially w/ guitar amps that weren't designed to handle bass.

Oh yeah, also, I know the LPFs can be done easier. I forgot how, and had this brute force way written down, never went back and optimized it.

Code: Select all

;Phil's Octave Down (OC-2 style) & Up (Green Ringer style)
;After reading valve wizard's u-boat page, I decided to try to implement the same algorithm in fv-1.
;The goal was a faster, funkier octave than the typical ramp delay address type, for both bass and guitar
;Tracking on the octave down is not perfect, but decent in my opinion
;As an afterthought I added the 'rectified' octave up (just an absa command), sounds like a green ringer.
;I think these 2 effects (up and down) compliment each other nicely for a synthy texture

;pot0 - clean
;pot1 - oct down
;pot2 - oct up


equ sig		reg0		;input after filter
equ sig_inv	reg1		;input after filter, iverted
equ square 	reg2		;square wave (generated from input)
equ sq_dn	reg3		;square wave divided for oct down
equ lpf1_temp	reg4
equ lpf2_temp	reg5
equ lpf3_temp	reg6
equ lpf_k2	reg7
equ env		reg8
equ peak_flag	reg9
equ prev	reg10
equ prev_sq	reg11
equ sig_dn	reg12
equ lpf4_temp	reg13
equ lpf5_temp	reg14
equ down_final	reg15
equ up_final	reg16


skp run, START
sof 0, 0.99
wrax sq_dn, 0
sof 0, 0.174			;puts lpf around 1kHz
wrax lpf_k2, 0
START:

;-----setup previous values to detect zero crossings-----
ldax sig
wrax prev, 0
ldax square
wrax prev_sq, 0

;-----convert input to amplified, filtered, balanced-----
ldax adcl
sof -2, 0
sof -2, 0			;gain 4x

rdax lpf1_temp, -1		;3x 1st order LPF at 1kHz
mulx lpf_k2
rdax  lpf1_temp, 1
wrax lpf1_temp, 1 

rdax lpf2_temp, -1
mulx lpf_k2
rdax lpf2_temp, 1
wrax lpf2_temp, 1

rdax lpf3_temp, -1
mulx lpf_k2
rdax lpf3_temp, 1
wrax lpf3_temp, 1

wrax sig, -1			;write sig (amplifed and filtered)
wrax sig_inv, 1			;write inverted 


;-----envelope folower-----
absa				;sig_inv is in the ACC (could be either sig or sig_inv)
rdax env, -1			;subract env value
skp neg, NO_PEAK		;if negative, signal is less than env
;---it is a peak (positive or negative)
sof 0, 0.99
wrax peak_flag, 0
ldax sig_inv
absa
wrax env, 0
skp ZRO, PEAK_OVR
NO_PEAK:
ldax env
sof 0.98, 0			;decay envelope follower
wrax env, 0

PEAK_OVR:


;-----set square wave if zero crossing (& prove peak)-----
ldax prev
skp neg, PRV_NEG
ldax sig
skp gez, CRS_OVR
ldax peak_flag			;peak must have been reached to trigger crossing
skp zro, CRS_OVR
sof 0, 0.1
wrax square, 0
wrax peak_flag, 0		;reset peak flag
skp zro, CRS_OVR
PRV_NEG:
ldax sig
skp neg, CRS_OVR
ldax peak_flag
skp zro, CRS_OVR
sof 0, -0.1
wrax square, 0
wrax peak_flag, 0		;reset peak flag

CRS_OVR:


;-----flip flop sq_down every positive zero crossing-----
ldax square
skp neg, FLP_OVR
ldax prev_sq
skp gez, FLP_OVR
;---it is positive zero crossing
ldax sq_dn
sof -1, 0
wrax sq_dn, 0
FLP_OVR:

ldax sq_dn
skp neg, INV_CYCLE
ldax sig
wrax sig_dn, 0
skp zro, DN_OVR
INV_CYCLE:
ldax sig_inv
wrax sig_dn, 0
DN_OVR:

ldax sig_dn
rdax lpf4_temp, -1		;2x 1st order LPF at 1kHz (remove clicks from stitching signals)
mulx lpf_k2
rdax  lpf4_temp, 1
wrax lpf4_temp, 1 

rdax lpf5_temp, -1
mulx lpf_k2
rdax lpf5_temp, 1
wrax lpf5_temp, 1

mulx pot1
wrax down_final, 0

;-----octave up (rectify, like green ringer)-----
ldax adcl
absa
mulx pot2
wrax up_final, 0

;-----mix final signals-----
ldax adcl
mulx pot0			;pot0 mixes the dry signal
rdax down_final, 1
rdax up_final, 1
wrax dacl, 0
Serhat18
Posts: 22
Joined: Mon Sep 29, 2025 6:41 am

Re: Octave Down Patch - OC-2 & U-Boat Style

Post by Serhat18 »

Hi, We'll paste the octave code you wrote here into the SpinAsm program and get a hex file. Then, we'll write it to EPPROM and use it in the FV-1 module circuit. Is this correct? Please excuse me for being new to this.
frank
Posts: 1281
Joined: Wed Oct 19, 2005 12:26 pm
Contact:

Re: Octave Down Patch - OC-2 & U-Boat Style

Post by frank »

Correct, you use SpinAsm to assemble the code and save it to a hex file and use that to program an EEPROM. If you have a Spin FV-1 dev board SpinAsm can write to the EEPROM on it.
Frank Thomson
Experimental Noize
Serhat18
Posts: 22
Joined: Mon Sep 29, 2025 6:41 am

Re: Octave Down Patch - OC-2 & U-Boat Style

Post by Serhat18 »

Hello frank.
How can I create -3/+3 octaves? For example, can you provide an example drawing in Spincad that will cause the note I specify to move up or down from the lowest pitch to the highest? Note: I don't want a pitch shift! I just want the note to move up or down a few octaves when I turn the
Serhat18
Posts: 22
Joined: Mon Sep 29, 2025 6:41 am

Re: Octave Down Patch - OC-2 & U-Boat Style

Post by Serhat18 »

frank wrote: Mon Sep 29, 2025 4:24 pm Correct, you use SpinAsm to assemble the code and save it to a hex file and use that to program an EEPROM. If you have a Spin FV-1 dev board SpinAsm can write to the EEPROM on it.
Hello. How can I create -3/+3 octaves? For example, can you provide an example drawing in Spincad that will cause the note I specify to move up or down from the lowest pitch to the highest? Note: I don't want a pitch shift! I just want the note to move up or down a few octaves when I turn the
frank
Posts: 1281
Joined: Wed Oct 19, 2005 12:26 pm
Contact:

Re: Octave Down Patch - OC-2 & U-Boat Style

Post by frank »

I do not use SpinCAD so you will have to ask over on a SpinCAD forum.

The native pitch shifter in FV-1 will not shift by 3 octaves so you will have to calculate the coefficients to use from AN-0001 and use 2 in series.

I do not understand "I don't want a pitch shift! I just want the note to move up or down a few octaves", if you want to shift the sound that is a pitch shift. Technically it is a pitch transpose but how do you expect to do a shift of +/-3 octaves without doing a shift?
Frank Thomson
Experimental Noize
Serhat18
Posts: 22
Joined: Mon Sep 29, 2025 6:41 am

Re: Octave Down Patch - OC-2 & U-Boat Style

Post by Serhat18 »

frank wrote: Thu Oct 02, 2025 8:19 am I do not use SpinCAD so you will have to ask over on a SpinCAD forum.

The native pitch shifter in FV-1 will not shift by 3 octaves so you will have to calculate the coefficients to use from AN-0001 and use 2 in series.

I do not understand "I don't want a pitch shift! I just want the note to move up or down a few octaves", if you want to shift the sound that is a pitch shift. Technically it is a pitch transpose but how do you expect to do a shift of +/-3 octaves without doing a shift?
First of all, I apologize for bothering you, and you're a great administrator for always responding to people! I didn't really explain myself clearly. My English is weak, so please excuse me. What I meant by "I don't want a pitch shift" is that I don't want a transpose. I just want the same note a few octaves down (lower voice) and a few octaves up (higher voice). The note won't change here, I just want it to go up and down, just like the octaves in the whammy octave region.
frank
Posts: 1281
Joined: Wed Oct 19, 2005 12:26 pm
Contact:

Re: Octave Down Patch - OC-2 & U-Boat Style

Post by frank »

I am still unclear on what you want. Do you mean you want to play a note and hear the original note and a shifted version of the note together? So if you play A440 you want to hear A440 and A880 (A440 up one octave) as an example? If this is correct then you do want a pitch shifter that you can mix with the dry signal.
Frank Thomson
Experimental Noize
Serhat18
Posts: 22
Joined: Mon Sep 29, 2025 6:41 am

Re: Octave Down Patch - OC-2 & U-Boat Style

Post by Serhat18 »

frank wrote: Thu Oct 02, 2025 5:00 pm I am still unclear on what you want. Do you mean you want to play a note and hear the original note and a shifted version of the note together? So if you play A440 you want to hear A440 and A880 (A440 up one octave) as an example? If this is correct then you do want a pitch shifter that you can mix with the dry signal.
No, I implemented what you described as an algorithm and succeeded, but what I wanted was exactly this: Each note on the piano and organ consists of seven octaves, and each octave sounds equally louder than the same notes in the previous octave. For example, when we press a note on the piano, by pressing the +/- option keys, that note's sound goes down on the same note (Bass) or, when we want it to go up, it goes down on the same note (Trable). I hope I was able to explain it to you, my esteemed master.
Serhat18
Posts: 22
Joined: Mon Sep 29, 2025 6:41 am

Re: Octave Down Patch - OC-2 & U-Boat Style

Post by Serhat18 »

Actually, as you said, the A440 note of the dry signal is like going up to A880 or down to A220. I don't want an additional octave signal to be added to the dry signal. I just want the note I specify to go up or down to the lower octaves, that's all.
frank
Posts: 1281
Joined: Wed Oct 19, 2005 12:26 pm
Contact:

Re: Octave Down Patch - OC-2 & U-Boat Style

Post by frank »

I think what is causing me confusion is when you say:
Serhat18 wrote: Fri Oct 03, 2025 3:21 am I just want the note I specify to go up or down to the lower octaves, that's all.
What do you mean by "the note I specify"? Any audio you play into the algorithm will be shifted, shifting is not on a note by note basis. For example if you play a chord into it then all the notes in the chord are shifted, not just one note. It may be easier for me to understand if you tell me exactly what is going in (single note, series of notes, chord, etc.) and what you expect to happen (all audio is shifted, jut a single note of a chord is shifted, just a certain note of a series of notes is shifted).
Frank Thomson
Experimental Noize
Serhat18
Posts: 22
Joined: Mon Sep 29, 2025 6:41 am

Re: Octave Down Patch - OC-2 & U-Boat Style

Post by Serhat18 »

frank wrote: Fri Oct 03, 2025 8:46 am I think what is causing me confusion is when you say:
Serhat18 wrote: Fri Oct 03, 2025 3:21 am I just want the note I specify to go up or down to the lower octaves, that's all.
What do you mean by "the note I specify"? Any audio you play into the algorithm will be shifted, shifting is not on a note by note basis. For example if you play a chord into it then all the notes in the chord are shifted, not just one note. It may be easier for me to understand if you tell me exactly what is going in (single note, series of notes, chord, etc.) and what you expect to happen (all audio is shifted, jut a single note of a chord is shifted, just a certain note of a series of notes is shifted).
sales@xnoize.com I sent a demo sample to your address, could you please check it?
Serhat18
Posts: 22
Joined: Mon Sep 29, 2025 6:41 am

Re: Octave Down Patch - OC-2 & U-Boat Style

Post by Serhat18 »

Hi frank.Do you have a code that can do -/+1 like this octave in the demo example I sent you?
Post Reply