naus3a / NauModular

VCV rack plugin
Creative Commons Zero v1.0 Universal
19 stars 3 forks source link

v0.5.2 (BitHammer, Function): huge voltages issues. #14

Open DomiKamu opened 6 years ago

DomiKamu commented 6 years ago

Platform: Windows 7 Pro SP1 x64 (French localized). VCV Rack v0.5.1 (not dev). NauModular v0.5.2.

Hello, firstly, thank you very much about your NauModular modules. ;)

However, I report huge voltages issues, concerning BitHammer and Function modules.

I've recorder & posted a (non-indexed) video on YouTube (2 min), showing the voltage issues on these modules. Also, I precise the oscillators I've used, TinySine and TinySawish (both by AS) deliver voltages into range -/+5 V.

Of course it's possible I'm wrong somewhere about voltage measurements, by using Fundamental's Scope.

Perhaps you'll must add a "voltage limitation" in code (for future release) to stay in range -/+12 V (in my opinion).

Link to YT video: here (please advise me when you have seen it, btw I'll remove it, thanks in advance).

Regards. Dominique Camus.

naus3a commented 6 years ago

Yes, I observed similar big peaks too and wondered if I should just let them "clip naturally" or add some kind of limitation.

Probably a limiter is a good idea. Will look into it.

DomiKamu commented 6 years ago

Can I delete the YT video?

naus3a commented 6 years ago

Sure thanks!

DomiKamu commented 6 years ago

Was done! ;)

neoh4x0r commented 5 years ago

@naus3a I just discovered this module a few days ago because I was looking for a way to do bitwise-math to check if a certain CV voltage was present (ie binary bit flags), but the BitHammer module does not do this in a predictable way.

I believe the issue with large voltages is due to the nature of how floating-point values are stored as binary (IEEE 745 format).

I can see that that you are using a union to convert back-and-forth between floats and ints.

Under this implementation the float is in unpacked format, whereas, the int is the 32-bit single precision representation (ie packed binary) and results in very large integral values.

As it stands doing a left shift will result in the output being zero (regardless of what is given for the inputs -- because you are shifting inA by a very large amount which always results in zero).

Where as the right shift's output will always be equal the value of input A.

Performing bitwise operations really only make sense when they are done on an unpacked binary representation (ie integral data types, 0, 1, 2, 3, 4, etc [ 0000, 0001, 0010, 0011, 0100, etc) [or even negative values which will be two's complemented, eg -2 = 11111110 ].

You should really cast the inputs to integers (chopping-off the decimal part) and then the bitwise operations would perform as expected, and in a predictable way (finite values).

PS: I'm sorry for necro-ing this issue (more than a year later), but I has just discovered VCV rack and all of the possibilities with the plugins about a month ago.