Strange object memory behavior (not due to JUCE)

Hello

I’m trying to develop for fun a Juce standalone application (virtual guitar pickup simulation)
And I’m facing a very very strange problem, not related to Juce I think
But I would very much appreciate if someone cares and could give me a direction where to investigate

My app has an AudioAppComponent, its method ‘getNextAudioBlock’ finally
Calls a ‘process’ method of a unique (for now) object called ‘GuitarSetMagnetic’

‘GuitarSetMagnetic’ has a private member :
AudioBuffer pickupMultiBuffer [ 3 ]; where I store and manipulate sounds
(For now, I only use pickupMultiBuffer [ 0 ])

In the process method, for debug purpose :

  • If I add that line below : (toto is a not used ‘dummy’ static float* variable)
    toto = pickupMultiBuffer [ 0 ].getWritePointer ( 0 );
    Everything sounds crystal clear. Note that I make no use of ‘toto’ in my app.

  • if I change for
    toto = pickupMultiBuffer [ 1 ].getWritePointer ( 0 );
    I get a sort of ring modulated horrible sound (I don’t use occurrence 1 of this array for now)

It looks like I have to access to the used part of pickupMultiBuffer memory to make things OK.
Do you have a clue of what could happen ?
I’m fairly hopeless after hours hours and hours of code reading.

Any help would be very very appreciated.
I tried here to keep it short and avoid you lines and lines of source code…
Best regards
Luc B

I would advise against making an array of AudioBuffer objects. Either make separate objects, each with a unique name, or use multiple channels of audio within one AudioBuffer object.

You also mention using a static variable – you should generally avoid using statics except for a few very specific scenarios. In general they cause more problems than they solve.