Support

If you have a problem or need to report a bug please email : support@dsprobotics.com

There are 3 sections to this support area:

DOWNLOADS: access to product manuals, support files and drivers

HELP & INFORMATION: tutorials and example files for learning or finding pre-made modules for your projects

USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here

Question about Boolean Vs Stream signals

DSP related issues, mathematics, processing and techniques

Question about Boolean Vs Stream signals

Postby Spogg » Sat Jun 17, 2017 11:13 am

Hi all

I wonder could someone please help me clarify the difference between a Boolean input/output signal, and a stream signal that switches between 1 on 0, in DSP. Wikipedia suggests it’s the same thing, in logic anyway.

I had thought they were interchangeable but I found they’re not.

If I convert a Boolean signal to a Stream signal directly I get a huge level out. It would seem that a Boolean DSP signal represents true or false somehow and is not just 1 or 0.

The stock sine osc uses a “Boolean” signal to hard sync but it works with a 0-1 signal made to look Boolean (using streamboolout instead of just streamout). Martin very kindly made me an optimised sine with sync but this will only work with a “true” Boolean signal for hard sync.

It’s confusing this poor old Vulcan because, in green, they do seem interchangeable.

I need help!

Cheers

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

Re: Question about Boolean Vs Stream signals

Postby tulamide » Sat Jun 17, 2017 12:52 pm

Don't forget that a stream always carries information for ALL individual tracks. If 3 notes were triggered, then the stream carries information for all 3. In case of a boolean stream it is the same. Each bit represents another track. In our example the stream will carry 3 different true/false signals. It will never be just 0 or 1. You can't just look at the sum of the bits.

More details will hopefully follow by the experts in DSP.
tulamide
 
Posts: 1533
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: Question about Boolean Vs Stream signals

Postby martinvicanek » Sat Jun 17, 2017 1:08 pm

If you look at the bit pattern it becomes evident:

bool "true": 11111111111111111111111111111111
float 1.0: 0 01111111 00000000000000000000000 (IEEE-754 format)
integer 1: 00000000000000000000000000000001

It is confusing, though, because in FS "green" they are all interchangeable.
martinvicanek
 
Posts: 709
Joined: Sat Jun 22, 2013 8:28 pm

Re: Question about Boolean Vs Stream signals

Postby Spogg » Sat Jun 17, 2017 2:43 pm

Thanks guys.

So a boolean false is all zeros then? Is this different to a stream value of zero? When I scoped a converted bool signal it switched between zero and HUGE!
I'm imagining that a bool signal carries some sort of header so that a DSP bool input "knows" whether it's a number or a true/false signal. Or it's just down to the input/output type specified in the code.

I think I get it now :D

Cheers

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

Re: Question about Boolean Vs Stream signals

Postby KG_is_back » Sat Jun 17, 2017 3:17 pm

Spogg wrote:So a boolean false is all zeros then? Is this different to a stream value of zero?


Boolean False and 0 happen to be identical, because they are both just zeros. There is no header or anything to tell them apart. It is fully up to the programmer to determine which one should be used. Sidenote, boolean true (all 1s) happens to be identical with "QNaN" (quiet not a number), which is a special value that is used to detect invalid float operations (like division by zero or square root of negative number).

In fact, the stream and boolean stream connectors in flowstone are purely cosmetic - they compile to the exact same code. Only reason why they are there is for visual clarity.
KG_is_back
 
Posts: 1130
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

Re: Question about Boolean Vs Stream signals

Postby Spogg » Sat Jun 17, 2017 3:28 pm

Thanks KG!

I found that

streamboolout out = (t > 1); gives the all 1s value when true

streamout out= 1 & (t > 1); gives 1 when the condition is met.

BUT

streamboolout out = 1 & (t > 1); gives the same as the streamout but is not necessarily recognised as a boolean input by another module.
I guess it depends on the code in the other module, since you say there is no difference in the way it's compiled.

Makes sense now thanks.

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

Re: Question about Boolean Vs Stream signals

Postby nix » Sun Jun 18, 2017 3:15 am

to do the conversion in dsp it's->
bool to stream:

streamboolin abool;
streamout result;
result = abool & 1;

stream to bool:

streamin avalue;
streamboolout aboolresult;
aboolresult = avalue == 1 ;


I think they're right,
I tried them
User avatar
nix
 
Posts: 649
Joined: Tue Jul 13, 2010 10:51 am

Re: Question about Boolean Vs Stream signals

Postby Spogg » Sun Jun 18, 2017 7:59 am

Thanks nix.

I got to that understanding too. Eventually :lol:

The thing is that in DSP Boolean "True" isn't 1, it's zillions! Unlike in green :mrgreen:

Cheers

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

Re: Question about Boolean Vs Stream signals

Postby tulamide » Sun Jun 18, 2017 1:52 pm

Spogg wrote:The thing is that in DSP Boolean "True" isn't 1, it's zillions!

Well :D (takes a deep breath) technically it isn't really zillions. The 32-bit float format (also called single-precision-float) has a special defined value:

Code: Select all
1 11111111 00000000000000000000000
The highest order bit tells us the sign. Unset = positive, set = negative
Following are 8 bits for the exponent.
Lastly 23 bits for the fraction part.


As you can see, the fraction part is completely unset. This value stands for "-infinity". So basically the number you get is even lower than a negative infinity.

:lol:

(Actually I don't know if a value of all bits set is even defined for single precision float, so probably you get unreliable values)
tulamide
 
Posts: 1533
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: Question about Boolean Vs Stream signals

Postby Spogg » Sun Jun 18, 2017 5:15 pm

Thanks tulamide.

A restless night with boolean nightmares awaits me.

:lol:
User avatar
Spogg
 
Posts: 1464
Joined: Thu Nov 20, 2014 4:24 pm
Location: Birmingham, England


Return to DSP

Who is online

Users browsing this forum: No registered users and 4 guests