tula's DSP modules

Post any examples or modules that you want to share here
tulamide
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: tula's DSP modules

Post by tulamide »

RJHollins wrote:Thanks T.

Are there any DSP sites that you're researching from ?

No, but I'm sure that will happen, once I enter the "complex zone"
"There lies the dog buried" (German saying translated literally)
RJHollins
Posts: 1573
Joined: Thu Mar 08, 2012 7:58 pm

Re: tula's DSP modules

Post by RJHollins »

tulamide wrote:
RJHollins wrote:Thanks T.

Are there any DSP sites that you're researching from ?

No, but I'm sure that will happen, once I enter the "complex zone"

Alright ... well ... be safe ... report back ... hope ya keep post findings ....

and maybe we'll get more group insights/explanations.

I learned some new stuff already from this thread.

thx
User avatar
Spogg
Posts: 3368
Joined: Thu Nov 20, 2014 4:24 pm
Location: Birmingham, England
Contact:

Re: tula's DSP modules

Post by Spogg »

Here's a poly stream-controlled inverter I knocked up, together with a demo test synth attached.

DSP box.png
DSP box.png (288.21 KiB) Viewed 25720 times


I wonder if this could be made more efficiently in DSP code...

Cheers

Spogg
Attachments
Stream controlled inverter -Spogg .fsm
(552.05 KiB) Downloaded 1099 times
tulamide
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: tula's DSP modules

Post by tulamide »

Hey Spogg,

thanks for participating! Interesting question. I came to the conclusion that basically you only care for a sign switch (positive switch input = +1, negative switch input = -1). I always look at all modules, Martin shares with us. In the past, it didn't help me the slightest bit. But now that I slowly start to understand the dsp editor, I remembered that I once saw a sign bitmask in some of Martin's modules.

Code: Select all

sgn = -1&-2 //sign bitmask defined in stage 0

I have no clue what exactly is happening to the bits, but I know what a sign function does in higher level programming languages. And since it is a bitmask, I knew I had to somehow bitwise combine it with the switch. After several tries, I came up with this

Code: Select all

1|(switch&sgn) //results in either -1 or 1


The final code then looks like so:
stream_switch_inverter.png
stream_switch_inverter.png (6.42 KiB) Viewed 25708 times


What do you think? And what do the DSP gurus think?
Attachments
Stream controlled inverter -Spogg(tula) .fsm
(86.11 KiB) Downloaded 1113 times
"There lies the dog buried" (German saying translated literally)
User avatar
martinvicanek
Posts: 1334
Joined: Sat Jun 22, 2013 8:28 pm

Re: tula's DSP modules

Post by martinvicanek »

Yup, tula's inverter does the same as Spogg's and is more efficient. ;)
It is probably not meant to be used as in the schematic because it aliases quite heavily.
User avatar
Spogg
Posts: 3368
Joined: Thu Nov 20, 2014 4:24 pm
Location: Birmingham, England
Contact:

Re: tula's DSP modules

Post by Spogg »

Hey well done tulamide! :ugeek:

Nobody noticed I got the inv and noninv names crossed, not that it matters for the result.

My first attempt was to get the whole job done in just one line of code, but I failed to find a method.

I like this topic!

Spogg
TheOm
Posts: 103
Joined: Tue Jan 28, 2014 7:35 pm
Location: Germany

Re: tula's DSP modules

Post by TheOm »

tulamide wrote:

Code: Select all

sgn = -1&-2


There is actually an even simpler method to get a sign mask in dsp code:

Code: Select all

float signbit = -0;


Unfortunately you can not use xor in dsp code, otherwise one could simplify the code to

Code: Select all

out = in ^ (switch & signbit);


This is why I don't like the dsp code module, it is limiting because it doesn't have all the features and the generated asm code is poor.
User avatar
martinvicanek
Posts: 1334
Joined: Sat Jun 22, 2013 8:28 pm

Re: tula's DSP modules

Post by martinvicanek »

TheOm wrote:There is actually an even simpler method to get a sign mask in dsp code:

Code: Select all

float signbit = -0;

Cool! :ugeek:
Do you happen to have a simpler expression for the abs bitmask as well?
TheOm
Posts: 103
Joined: Tue Jan 28, 2014 7:35 pm
Location: Germany

Re: tula's DSP modules

Post by TheOm »

martinvicanek wrote:Do you happen to have a simpler expression for the abs bitmask as well?

No, unfortunately not without using stage0. I don't think there's a way to type NaN in the code module, is there?
User avatar
Spogg
Posts: 3368
Joined: Thu Nov 20, 2014 4:24 pm
Location: Birmingham, England
Contact:

Re: tula's DSP modules

Post by Spogg »

TheOm wrote:
Unfortunately you can not use xor in dsp code, otherwise one could simplify the code to

Code: Select all

out = in ^ (switch & signbit);


This is why I don't like the dsp code module, it is limiting because it doesn't have all the features and the generated asm code is poor.


Assuming the ^ symbol means XOR it'll be available in the 3.09 release according to the list I have. The DSP code will be extended considerably.

Cheers

Spogg
Post Reply