Spin Semiconductor Forum Index Spin Semiconductor
Support forum
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Bandpass Resonant Filter

 
Post new topic   Reply to topic    Spin Semiconductor Forum Index -> Algorithm development
View previous topic :: View next topic  
Author Message
MacroMachines



Joined: 12 Dec 2014
Posts: 70
Location: Detroit,MI

PostPosted: Sun Jun 19, 2016 11:01 am    Post subject: Bandpass Resonant Filter Reply with quote

I am wondering how i can streamline this code I got from spinCAD, from the notch module, I just want a 2nd order resonant bandpass and Im sure I don't need nearly this many registers and ops to do it:

Code:
;------ Notch
RDAX POT1,1.0000000000
SOF 0.2000000000,0.0000000000
RDFX REG10,0.0100000000
WRAX REG10,1.0000000000
WRAX REG6,0.0000000000
RDAX REG2,1.0000000000
SOF 1.0000000000,-1.0000000000
ABSA
RDFX REG11,0.0100000000
WRAX REG11,1.0000000000
WRAX REG7,0.0000000000
LDAX REG5
MULX REG6
RDAX REG4,1.0000000000
WRAX REG4,-1.0000000000
RDAX REG1,1.0000000000
WRAX REG8,1.0000000000
LDAX REG5
MULX REG7
SOF 1.4142135624,0.0000000000
SOF -1.4142135624,0.0000000000
RDAX REG8,1.0000000000
WRAX REG8,1.0000000000
MULX REG6
SOF 0.4385941600,0.0000000000
RDAX REG5,1.0000000000
WRAX REG5,0.0000000000
LDAX REG4
RDAX REG8,1.0000000000
WRAX REG9,1.0000000000


I am hoping to make a bank of resonators, I was able to get 3 using spinCAD before running out of registers, it sounds amazing, and I can get a decent physical model going with 8 or so.

I also just made a pretty cool oscillator using spin cad in about 15 minutes! insanity!!!:
https://www.instagram.com/p/BG2FK-thymG/?taken-by=axiomcrux
_________________
http://MacroMachines.net
Digital Control for your Analog Soul.
Back to top
View user's profile Send private message Visit poster's website AIM Address
MacroMachines



Joined: 12 Dec 2014
Posts: 70
Location: Detroit,MI

PostPosted: Sun Jun 19, 2016 8:30 pm    Post subject: Reply with quote

Here is where I got with it:

Code:

;------ Resonator
equ freq reg2

RDAX POT0, 0.2      ;frequency pot
WRAX freq, 0      ;stored in reg2 for frequency

RDAX POT1, 0.01
WRAX REG3, 0.      ;store reg3 and clear

LDAX REG1      ;load reg1
MULX freq      ;multiply by freq
RDAX REG0, 1.      ;ACC+reg0
WRAX REG0, -1      ;write reg0, invert
RDAX ADCL, 1      ;add adcl

WRAX REG4, 1      ; write reg4
LDAX REG1      ;load reg1
MULX REG3      ;mult by reg3

SOF -1, 0          ;times -k
RDAX REG4, 1.       ;add reg4
WRAX REG4, 1.      ;write reg4

MULX REG2      ;times reg2

RDAX REG1, 1      ;add reg1
WRAX REG1,0      ;write reg1 and clear
LDAX REG0      ;read reg0



;------ Output
RDAX REG1, 1

WRAX DACL, 1
WRAX DACR, 0


I was able to eliminate quite a bit in streamlining it to a resonator
_________________
http://MacroMachines.net
Digital Control for your Analog Soul.
Back to top
View user's profile Send private message Visit poster's website AIM Address
MacroMachines



Joined: 12 Dec 2014
Posts: 70
Location: Detroit,MI

PostPosted: Sun Jun 19, 2016 9:19 pm    Post subject: Reply with quote

a bit more work, are my labels correct? what would reg0 be?


Code:
;------ Resonator

equ freq reg1
equ reso reg2
equ input reg3
equ output reg4


RDAX POT0, 0.2      ; frequency pot
WRAX freq, 0      ; store frequency and clear

RDAX POT1, 0.01      ; resonance pot
WRAX reso, 0.      ; store reso and clear

LDAX output      ; load output for feedback
MULX freq      ; multiply by freq
RDAX REG0, 1.      ; ACC+reg0
WRAX REG0, -1      ; write reg0, invert
RDAX ADCL, 1      ; add adcl
WRAX input, 1      ; write input

LDAX output      ; load output
MULX reso       ; mult by resonance
SOF -1, 0          ; invert
RDAX input, 1.      ; add input
WRAX input, 1.      ; write input
MULX freq      ; times frequency

RDAX output, 1      ; add output
WRAX output, 0      ; write output and clear


;------ Output
RDAX output, 1

WRAX DACL, 1
WRAX DACR, 0

_________________
http://MacroMachines.net
Digital Control for your Analog Soul.
Back to top
View user's profile Send private message Visit poster's website AIM Address
Digital Larry



Joined: 12 Nov 2012
Posts: 274

PostPosted: Tue Jun 21, 2016 9:31 am    Post subject: Reply with quote

Someone gave me that code for the notch function, which I threw into SPinCAD Designer without much thought, but I don't think it is very efficient. I have a more recent two-pole state variable filter that should be able to do LP, BP, HP all at the same time. I'll try to remember to post that this evening.
Back to top
View user's profile Send private message Visit poster's website
MacroMachines



Joined: 12 Dec 2014
Posts: 70
Location: Detroit,MI

PostPosted: Sat Jun 25, 2016 5:00 pm    Post subject: Reply with quote

Digital Larry wrote:
Someone gave me that code for the notch function, which I threw into SPinCAD Designer without much thought, but I don't think it is very efficient. I have a more recent two-pole state variable filter that should be able to do LP, BP, HP all at the same time. I'll try to remember to post that this evening.

Would love to check out your Svf Smile
_________________
http://MacroMachines.net
Digital Control for your Analog Soul.
Back to top
View user's profile Send private message Visit poster's website AIM Address
Digital Larry



Joined: 12 Nov 2012
Posts: 274

PostPosted: Sun Jun 26, 2016 5:41 am    Post subject: Reply with quote

There's a very useful block diagram.

http://www.earlevel.com/main/2003/03/02/the-digital-state-variable-filter/

Code:
rdax wf1, 1
mulx wf
rdax wf2, 1.0
wrax wf2, -1.0
rdax adcl, 1.0
wrax temp, 0
rdax wf1, -1
mulx wq
rdax temp, 1
wrax hp_out, 1
mulx wf
rdax wf1, 1
wrax wf1, 0
Back to top
View user's profile Send private message Visit poster's website
MacroMachines



Joined: 12 Dec 2014
Posts: 70
Location: Detroit,MI

PostPosted: Sun Jun 26, 2016 11:57 am    Post subject: Reply with quote

Digital Larry wrote:
There's a very useful block diagram.

http://www.earlevel.com/main/2003/03/02/the-digital-state-variable-filter/

Code:
rdax wf1, 1
mulx wf
rdax wf2, 1.0
wrax wf2, -1.0
rdax adcl, 1.0
wrax temp, 0
rdax wf1, -1
mulx wq
rdax temp, 1
wrax hp_out, 1
mulx wf
rdax wf1, 1
wrax wf1, 0


A couple questions, how do you set the frequency as noted? It uses a sin function, is there a way to do this in asm or is it somehow not needed?
Also, I see the labeled hp_out but where is bp and lp? I could likely trim down a few lines with that info. Cheers and thank you!
_________________
http://MacroMachines.net
Digital Control for your Analog Soul.
Back to top
View user's profile Send private message Visit poster's website AIM Address
Digital Larry



Joined: 12 Nov 2012
Posts: 274

PostPosted: Mon Jun 27, 2016 5:29 am    Post subject: Reply with quote

The frequency control comes in on "wf" which is some other variable (register), or possibly a pot put through an SOF statement and stored in a register.

The lp and bp are in wf1 and wf2. My request to you since I'm not currently doing anything with the FV-1 is to try them and report back which is which.

If you don't need hi pass then you can get rid of the hp_out register, however the state variable filter structure does require the rest of this code to be in there even if you are not using the low pass out.

I don't quite catch your comment about the "sin" function, can you elaborate?
Back to top
View user's profile Send private message Visit poster's website
Aaron



Joined: 04 Mar 2015
Posts: 42

PostPosted: Mon Jun 27, 2016 6:23 am    Post subject: Reply with quote

I believe MacroMachines is referring to the function:

f = 2sin(pi*Fc/Fs)

This is what you use to find the coefficient for the corner frequency (wf).
Back to top
View user's profile Send private message
Digital Larry



Joined: 12 Nov 2012
Posts: 274

PostPosted: Mon Jun 27, 2016 1:27 pm    Post subject: Reply with quote

My answer to that is that how filters move dynamically with changes in the control input is a fascinating topic unto itself and in the case of something like an auto-wah, can have a significant impact on the evolving sound. But I can't tell you whether linear or log or reverse square root is the best. I can tell you that trying all of those to see which one floats your boat the best can be fun and frustrating.
Back to top
View user's profile Send private message Visit poster's website
MacroMachines



Joined: 12 Dec 2014
Posts: 70
Location: Detroit,MI

PostPosted: Mon Jul 04, 2016 8:29 pm    Post subject: Reply with quote

I don't understand why people don't give their variables somewhat readable names. its already alien enough working with 3 letter opcodes, can't variable equs just be "frequency" or "freq" or "lowpass" or even "LP"

jeesh Razz

HAHAHAHA did you read the code I posted in the first reply where I edited down your notch bandpass? I just double checked and this is EXACTLY what I already had! boiled it down to!!! HAHAHAHA Razz

regarding the sin function, I realized it was not actually important in this context since I am not trying to set the frequency specifically via "440Hz" and am just using potentiometers. I have been doing a lot of tests lately with Audulus3, I am sure I mentioned elsewhere, but in there I can easily use the expression node to make "sin(x)" and z-1 transform node and delay lines and biquads etc.. so I am used to functioning on a slightly more digital modular network mentality and forget sometimes FV-1 is more like making a nice sauce, you just sort of add the ingredients you think will work and pinch in bits of salt and pepper till it tastes good. Razz Not that I don't do that in audulus, just that when I am copying an online referenced DSP block diagram I first do it precisely as shown. I replicated the block diagram for this while I was camping last weekend and it sounds great, super useful, also has a nice band reject out as well.

@Digital Larry, I do highly recommend checking out audulus 3, especially if you have an iPad. Its really rad fun modular synth program, considering you made a modular synth program its right up your alley. I am working with Taylor, the designer of the app on a bunch of things, and if we can get me set up with your code working I might be able to get some sweet graphic enhancement help from him (still haven't gotten it to compile, Ill check your forum again in a moment). His modular app really is the coolest looking and most fluid UI i have seen. really fun to just chill on iPad (I have an iPad pro) and patch my ideas up. Smile

here is a video clip of what I am working on bringing to my partially FV-1 based hardware device I am prototyping:
https://www.instagram.com/p/BHaF8hPAKGs/?taken-by=axiomcrux
_________________
http://MacroMachines.net
Digital Control for your Analog Soul.
Back to top
View user's profile Send private message Visit poster's website AIM Address
Digital Larry



Joined: 12 Nov 2012
Posts: 274

PostPosted: Tue Jul 05, 2016 5:09 am    Post subject: Reply with quote

Well I am glad you got it figured out even if my post was not the most helpful thing in the world. Lots of times I am dealing with code that I copied from somewhere else and so there you go.

As you may have guessed, one of the reasons I developed SpinCAD is that Spin ASM gives me a headache even to this day.

If I ever get any spare time I will look into this other thing you are talking about. All FV-1 activities in my own life take place when I am not working on my "real job" which is sufficiently different that I find it difficult to easily switch back and forth - unless someone is paying me.
Back to top
View user's profile Send private message Visit poster's website
MacroMachines



Joined: 12 Dec 2014
Posts: 70
Location: Detroit,MI

PostPosted: Thu Jul 07, 2016 10:32 pm    Post subject: Reply with quote

Digital Larry wrote:
Well I am glad you got it figured out even if my post was not the most helpful thing in the world. Lots of times I am dealing with code that I copied from somewhere else and so there you go.

As you may have guessed, one of the reasons I developed SpinCAD is that Spin ASM gives me a headache even to this day.

If I ever get any spare time I will look into this other thing you are talking about. All FV-1 activities in my own life take place when I am not working on my "real job" which is sufficiently different that I find it difficult to easily switch back and forth - unless someone is paying me.


hehe "difficult to easily" Razz

I am creating audulus modules for each of the opcodes now so that I can test out things like pot mapping and maybe even do simulation. it is also helping a ton in learning in depth how the assembler language works. One of the things about audulus I like and why I mention it, is that its powerful yet casual to work in, IE I never feel like its going to take much time at all to implement and test even complex ideas.
_________________
http://MacroMachines.net
Digital Control for your Analog Soul.
Back to top
View user's profile Send private message Visit poster's website AIM Address
Display posts from previous:   
Post new topic   Reply to topic    Spin Semiconductor Forum Index -> Algorithm development All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group