Page 2 of 5

Re: tula's DSP modules

PostPosted: Fri Jan 12, 2018 5:30 am
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"

Re: tula's DSP modules

PostPosted: Fri Jan 12, 2018 7:06 am
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

Re: tula's DSP modules

PostPosted: Fri Jan 12, 2018 5:16 pm
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 21203 times


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

Cheers

Spogg

Re: tula's DSP modules

PostPosted: Fri Jan 12, 2018 10:35 pm
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 21191 times


What do you think? And what do the DSP gurus think?

Re: tula's DSP modules

PostPosted: Sat Jan 13, 2018 2:05 am
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.

Re: tula's DSP modules

PostPosted: Sat Jan 13, 2018 9:43 am
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

Re: tula's DSP modules

PostPosted: Sat Jan 13, 2018 1:41 pm
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.

Re: tula's DSP modules

PostPosted: Sat Jan 13, 2018 1:53 pm
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?

Re: tula's DSP modules

PostPosted: Sat Jan 13, 2018 2:14 pm
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?

Re: tula's DSP modules

PostPosted: Sat Jan 13, 2018 4:20 pm
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