RobinSchmidt / RS-MET

Codebase for RS-MET products (Robin Schmidt's Music Engineering Tools)
Other
56 stars 6 forks source link

Please solve: Warning: divide by 0 #32

Closed elanhickler closed 7 years ago

elanhickler commented 7 years ago
d:\_programming\rs-met\libraries\juce\modules\rosic\dynamics\rosic_softkneecompressor.cpp(88): warning C4723: potential divide by 0
d:\_programming\rs-met\libraries\juce\modules\rosic\math\rosic_complex.cpp(92): warning C4723: potential divide by 0
d:\_programming\rs-met\libraries\juce\modules\rosic\math\rosic_complex.cpp(92): warning C4723: potential divide by 0
d:\_programming\rs-met\libraries\juce\modules\rosic\analysis\rosic_waveformdisplaybuffer.cpp(169): warning C4723: potential divide by 0
d:\_programming\rs-met\libraries\juce\modules\rosic\math\rosic_specialfunctionsreal.cpp(91): warning C4723: potential divide by 0
d:\_programming\rs-met\libraries\juce\modules\rosic\math\rosic_specialfunctionsreal.cpp(75): warning C4723: potential divide by 0
d:\_programming\rs-met\libraries\juce\modules\rosic\datastructures\rosic_string.cpp(235): warning C4723: potential divide by 0
d:\_programming\rs-met\libraries\juce\modules\rosic\datastructures\rosic_string.cpp(233): warning C4723: potential divide by 0
d:\_programming\rs-met\libraries\juce\modules\rosic\dynamics\rosic_softkneeexpander.h(112): warning C4723: potential divide by 0
d:\_programming\rs-met\libraries\juce\modules\rosic\math\rosic_complex.cpp(14): warning C4723: potential divide by 0
d:\_programming\rs-met\libraries\juce\modules\rosic\filters\rosic_prototypedesigner.cpp(844): warning C4723: potential divide by 0
d:\_programming\rs-met\libraries\juce\modules\rosic\math\rosic_complexfunctions.cpp(146): warning C4723: potential divide by 0
d:\_programming\rs-met\libraries\juce\modules\rosic\math\rosic_complex.cpp(92): warning C4723: potential divide by 0
d:\_programming\rs-met\libraries\juce\modules\rosic\filters\rosic_polezeromapper.cpp(501): warning C4723: potential divide by 0
d:\_programming\rs-met\libraries\juce\modules\rosic\math\rosic_complex.cpp(92): warning C4723: potential divide by 0
d:\_programming\rs-met\libraries\juce\modules\rosic\filters\rosic_polezeromapper.cpp(476): warning C4723: potential divide by 0
d:\_programming\rs-met\libraries\juce\modules\rosic\math\rosic_complex.cpp(92): warning C4723: potential divide by 0
d:\_programming\rs-met\libraries\juce\modules\rosic\filters\rosic_polezeromapper.cpp(447): warning C4723: potential divide by 0
d:\_programming\rs-met\libraries\juce\modules\rosic\math\rosic_complex.cpp(92): warning C4723: potential divide by 0
d:\_programming\rs-met\libraries\juce\modules\rosic\filters\rosic_polezeromapper.cpp(346): warning C4723: potential divide by 0
d:\_programming\rs-met\libraries\juce\modules\rosic\math\rosic_complex.cpp(92): warning C4723: potential divide by 0
d:\_programming\rs-met\libraries\juce\modules\rosic\filters\rosic_polezeromapper.cpp(234): warning C4723: potential divide by 0
d:\_programming\rs-met\libraries\juce\modules\rosic\math\rosic_complex.cpp(92): warning C4723: potential divide by 0
d:\_programming\rs-met\libraries\juce\modules\rosic\math\rosic_polynomialalgorithms.cpp(9): warning C4723: potential divide by 0
d:\_programming\rs-met\libraries\juce\modules\rosic\math\rosic_complex.cpp(92): warning C4723: potential divide by 0
d:\_programming\rs-met\libraries\juce\modules\rosic\math\rosic_complexfunctions.cpp(204): warning C4723: potential divide by 0
d:\_programming\rs-met\libraries\juce\modules\rosic\math\rosic_complex.cpp(92): warning C4723: potential divide by 0
d:\_programming\rs-met\libraries\juce\modules\rosic\math\rosic_complex.cpp(92): warning C4723: potential divide by 0
d:\_programming\rs-met\libraries\juce\modules\rosic\math\rosic_complex.cpp(92): warning C4723: potential divide by 0
d:\_programming\rs-met\libraries\juce\modules\rosic\math\rosic_complex.cpp(92): warning C4723: potential divide by 0
d:\_programming\rs-met\libraries\juce\modules\rosic\math\rosic_complexfunctions.cpp(203): warning C4723: potential divide by 0
d:\_programming\rs-met\libraries\juce\modules\rosic\filters\rosic_prototypedesigner.cpp(1009): warning C4723: potential divide by 0
d:\_programming\rs-met\libraries\juce\modules\rosic\math\rosic_complex.cpp(14): warning C4723: potential divide by 0
d:\_programming\rs-met\libraries\juce\modules\rosic\filters\rosic_prototypedesigner.cpp(920): warning C4723: potential divide by 0
d:\_programming\rs-met\libraries\juce\modules\rosic\filters\rosic_prototypedesigner.cpp(864): warning C4723: potential divide by 0
d:\_programming\rs-met\libraries\juce\modules\rosic\math\rosic_complex.cpp(92): warning C4723: potential divide by 0
d:\_programming\rs-met\libraries\juce\modules\rosic\filters\rosic_polezeromapper.cpp(501): warning C4723: potential divide by 0
d:\_programming\rs-met\libraries\juce\modules\rosic\analysis\rosic_waveformdisplaybuffer.cpp(21): warning C4723: potential divide by 0
d:\_programming\rs-met\libraries\juce\modules\rosic\filters\rosic_prototypedesigner.cpp(944): warning C4723: potential divide by 0
d:\_programming\rs-met\libraries\juce\modules\rosic\filters\rosic_prototypedesigner.cpp(1033): warning C4723: potential divide by 0
d:\_programming\rs-met\libraries\juce\modules\rosic\datastructures\rosic_string.cpp(315): warning C4723: potential divide by 0
d:\_programming\rs-met\libraries\juce\modules\rosic\filters\rosic_prototypedesigner.cpp(1100): warning C4723: potential divide by 0
d:\_programming\rs-met\libraries\juce\modules\rosic\filters\rosic_filteranalyzer.cpp(184): warning C4723: potential divide by 0
d:\_programming\rs-met\libraries\juce\modules\rosic\dynamics\rosic_softkneeexpander.h(112): warning C4723: potential divide by 0
d:\_programming\rs-met\libraries\juce\modules\rosic\filters\rosic_prototypedesigner.cpp(1120): warning C4723: potential divide by 0
d:\_programming\rs-met\libraries\juce\modules\rosic\dynamics\rosic_softkneeexpander.h(112): warning C4723: potential divide by 0
d:\_programming\rs-met\libraries\juce\modules\jura_processors\effects\jura_funcshaper.cpp(175): warning C4723: potential divide by 0
d:\_programming\rs-met\libraries\juce\modules\rosic\filters\rosic_prototypedesigner.cpp(384): warning C4723: potential divide by 0
d:\_programming\rs-met\libraries\juce\modules\rosic\filters\rosic_prototypedesigner.cpp(501): warning C4723: potential divide by 0
d:\_programming\rs-met\libraries\juce\modules\rosic\filters\rosic_prototypedesigner.cpp(501): warning C4723: potential divide by 0
d:\_programming\rs-met\libraries\juce\modules\rosic\filters\rosic_infiniteimpulseresponsedesigner.cpp(233): warning C4723: potential divide by 0
RobinSchmidt commented 7 years ago

hmm - i'm not getting these warnings. this is warning level 4, right? in what project do they occur?

elanhickler commented 7 years ago

spiral generator. couldn't you just not divide by zero? not good practice i think.

elanhickler commented 7 years ago

#define INF (1.0/dummyFunction(0.0))

whyyyyyyy

Edit: do a fresh build (delete build files) to get the warnings.

RobinSchmidt commented 7 years ago

not sure anymore why i did it this way. this is code from about 15 years ago. can probably be replaced with a better expression now, like std::numeric_limits::infinity() - which was not available before c++11 (or was it? hmm...maybe...not sure). ...however, i think, i don't really divide by 0 but only "potentially". it typically occurs, when i set the denominator inside some branches of if-statements and the compiler cannot know, that actual code always takes some branch where the value is set to some nonzero value (the compiler must sometimes assume, that no branch is taken, when in practice, you would always use one of them - or something) i have to look into it - but i'm still not getting these warnings. are you using my latest commit of the library?

RobinSchmidt commented 7 years ago

...and could you use your modified envelope-generator class from your folder, so i/we don't always have to replace the file in my library?

elanhickler commented 7 years ago

...and could you use your modified envelope-generator class from your folder, so i/we don't always have to replace the file in my library?

Don't know how to do that without compile errors. Was planning on eventually wrapping the envelope generator class.

Yes I'm using your latest commit.

elanhickler commented 7 years ago

Just got your LATEST latest commit, I think I am not getting the warnings anymore. Will keep an eye on it.

RobinSchmidt commented 7 years ago

good. i have now set the warning level for my module to 3 (corresponding to "medium" in projucer) in the code. level 4 (high) complains a lot about things that i actually consider non-issues

RobinSchmidt commented 7 years ago

Don't know how to do that without compile errors. Was planning on eventually wrapping the envelope generator class.

hmm...should i try to do that for you? ...for free, of course - i think, it should be a small thing

edit: i mean not the wrapping but using a different file

RobinSchmidt commented 7 years ago

i think, it will just be a matter of renaming the class (maybe use a prefix "se" or "eh" or whatever you like) and adding it to your synth-framework. ...and then using the renamed class instead of the original one in your project

elanhickler commented 7 years ago

yeah you could try it for me. I tried it and got stuck.

RobinSchmidt commented 7 years ago

so, it is the file rosic_EnvelopeGenerator_elanEdit.h/cpp in Shared/EalnSynthLib, right? i think, there are at least two options:

(1) just manually add the files to each jucer project where they are needed (as you have done with ElanSynthLib in SpiralGenerator)

(2) wrap the code into a juce library module - i specifically created the se_framework library module for that purpose. it currently contains only the licensing code, but the idea is that you could put customized (shared) dsp-code, gui-code, utility-code, etc. there, too. i would propose to make a folder dsp in se_framework and put the envelope generator code together with ElanSynthLib. then you don't have to bother with manually adding the code files to your jucer projects. you just add the se_framework module to the module list and drag in all code at once

elanhickler commented 7 years ago

I already tried (1), was hoping you'd give it a shot. Adding to the jucer project is trivial, that's not the issue.

(2) No idea how modules work, I can learn about that another time.

RobinSchmidt commented 7 years ago

done.

RobinSchmidt commented 7 years ago

...oh...just fixed a little bug

RobinSchmidt commented 7 years ago

haha! it's fun to play with the parameters of spiralgenerator. i'm getting funny sounds out of it!

RobinSchmidt commented 7 years ago

...but i think, the funniness of the sounds is mostly due to the pitch detoriating in weird ways when tweaking parameters

elanhickler commented 7 years ago

Pitch deterioration is good for fx. Also you should be using spiral generator with a 2d scope, everything makes a lot more sense. But I plan on addressing pitch deterioration. There are interesting timbres that are desirable but unfortunately tied to the pitch deterioration.

RobinSchmidt commented 7 years ago

yeah - using a 2D scope for sound analysis and design is probably something i should do much more anyway. i like it when synthesized sounds are intrinsically stereo

elanhickler commented 7 years ago

ok thanks for sorting out the envelope issue.

My code is a bit of a mess, I'll be cleaning it up for the next version.

I'd like to release a paid version of Spiral Generator with anything to anything modulation and other features, but I am waiting for you to give me GUI features. Also it needs polyphony.