Static WaveTable

This may be a general C++ question…

I’m building a synth. I started with the Juce Demo as a jumping off point, maintaining the Synth to SynthVoice structure. I want to create one set of wavetables for all of the individual voices to access. So I created them as static arrays of a WaveTable class, and create and access them using a static function. I call the static creation function at the end of my main Component’s constructor. The wavetable does get built as expected (I tested), but right after the creation function a BAD_ACCESS error pops up. If I remove the creation function there’s no error. And I’ve tried putting the creation function in different spots (moved it around the main component’s constructor, put it in the Synth constructor).

Am I misunderstanding what can be done with static variables?

Nope, your question is more of a “Please can someone psychically debug my program” question. We get a lot of them around here, and typically they say something like:

“I have written a [function/class], and now my program crashes. What have I done wrong?”

I’m afraid you won’t get a whole lot of sympathy if you ask us why your program is crashing without having used your debugger on it first!

Thanks for the reply. I actually did run the debugger. The problem is, it points to a specific line in Juce_Atomic.h that I don’t understand:

Sorry, I should have mentioned that. I know the Juce code isn’t to blame. I just wanted to make sure I wasn’t trying to make static variables do something they can’t. What does that specific line of Juce code mean? Any idea why a static array that’s already been created wouldn’t play nice with that line of code?

Well, that would have been better, but it still tells you absolutely nothing about what you’re doing wrong. You need to look at your stack trace and see what your own code is doing when it goes bang.

I’m surprised how often we get questions from people who don’t seem to have used a debugger before… I should probably write up a wiki or something explaining “things to do before asking for help” when you get a crash.

That wiki would be extremely helpful. I try to solve as many of these problems on my own before posting to forums, but I’m sure, like in this case, I’m not exhausting all of my options.

I’ll take a look a look at my stack trace.

Thanks.