Maximum number of variables?

Initially I thought something like this would work but I was wrong. I was planning on creating a wavetable for every possible combination, and setting output = to the specified wavetable drawn in the graph.

My intent was hopefully someone else encountered the maximum number of variables issue before and had a recommended baseline. I have ran a boolean through the conditions with std::cout and it’s definetly working, that’s not the issue.

phase += 512.0/(setSampleRate()/frequency);

if(phase >= 511.0)
{
    phase -= 512.0;
}

if (gridOverlay->setXTranform() == 2 && gridOverlay->setYTransform() == 2 &&
   gridOverlay->setMouseBoxOneTopCrescentState() == true &&
   gridOverlay->setMouseBoxTwo2BottomCrescentState() == true)
{
    output = sineBuffer[(long) phase];
}

// etc.. etc..

else
{
    output = 0.0;
}

return output;

a float is 4 bytes, a double is 8 bytes. How much RAM does your computer have? how much HD space does your computer have? divide that figure (expressed in bytes) by the size of a double (or float/int/etc) and that’s the maximum number of variables of type double/float/int/etc your system will support, generically speaking…

I think that if your code is in a state where you think this is even a question you need to ask, then your real problem is much more fundamental.

Having huge chunks of copy-pasted code is a terrible code smell - Don't repeat yourself - Wikipedia

2 Likes

Even after all the posts in this thread, I still don’t understand what the code should even be doing. My guess is that it is about being able to select a wavetable in the GUI and make the audio processing use that. Which sounds like a very simple problem to solve and should easily work with thousands of wavetables of any size without the need to do intricate repeated if statements in the code.

My plan was to break them up eventually but I was doing this to just make sure everything works, which doesn’t. Been running into a lot of issues where things are working differently.

Column by column is most likely best, and combine with adding arrays. I’m not even sure why I’m getting bashed about something that isn’t final but I was simply asking about number of variables not structure. I had asked this question before and was always told this would never be an issue.

Nevertheless, this will draw the desired effect

It’s people trying to be helpful - if you asked any experienced coder to review something that looked like that, the red flag they’d see has nothing to do with compiler limits - it’s your overall approach to the problem that just looks rather confused.

I do appreciate the help, but am unable to use the typical equations as this will not always be the typical sine, saw, square wave oscillator at any given time.

So it’s about building a final wavetable from smaller wave segments? That is easily doable with arrays and a minimal number of if statements.

Has been a tedious task I was able to minimize line usage from 75,000 to ~20,000 where I split the Mouse::Listener from the actual Graphics and pass states. Which is now about 10,000 lines. Am eager to break up more but has shown some stress, it’s not nearly finished.

Tens of thousands of lines of code for a simple thing like this…? We have to be missing something, because that doesn’t make any sense.

1 Like

Those boxes light up blue as the mouse moves over each box, but the boxes have a transform so each box in every combination is required to be considered.

It sounds a little bit like you’re not really paying enough attention to the object orientated aspect of C++. I haven’t read everything in the whole thread, but it seems to me like you’d want to start with a Component class that does “I draw a waveform based on an array of data and highlight blue when the mouse is over me”, then instantiate X times with the right data being passed to each, and apply your transforms. 20k LOC for 6 widgets that do the same thing is a definite give away that something’s not right.

Well, that is not an issue everything is running fine with no change in usage of CPU theres all the apples, and possible situations. I chose the 3 boxes at the bottom.

That’s probably the last thing you say to your clients/boss/users. “Works on my machine” is really the wrong attitude, if it comes to advise…

Sorry, but sometimes someone has to say uncomfortable things…

There is no increase in cpu plain and simple, code runs fine/program runs fine. Everything’s great :smile:

I was inquiring once again, on double variables not help with my project, but if you wanna pressure me there’s all the apples. This is a personal project I enjoy synths (maybe one day for profit, who knows) I set out years ago learning math, code, and everything else to make synths.

I honestly don’t see an issue but there’s my story. I enjoy making music.

You can use literally billions of double variables in a properly structured program, if the system has enough memory to handle it. It seems this was never about the number of variables you are using but about using wrong data structures (or maybe not even using any at all) and wrong algorithms.

Bit of a strange response. People are trying to help but I’ve read this entire thread and have no idea what is the question(s). You haven’t described one problem well enough for anyone to be able to help. Your direct question about the variables was answered. There is no set limit, it’s down to the user’s machine capabilities.

The way you code things does matter, more so than just performance. Say you do implement the next phase, what about after that? Will you have to modify 20k worth of lines? It’s not sustainable.

My suggestion, forget about the UI for now. Separate out the audio processing from the UI completely. Get the audio part working and then worry about the UI.

The audio already works, the problem is the compiler is ignoring conditional statements, and only processing them once at runtime. During runtime the conditional statements are not working.

However using a simple boolean, they are working.