Modifying Auduino Code: Wrestling with RAM

Hi,
One thing you can do is follow this comment I added to the google code group -

Hi, Yes I can confirm that the fix is to simply to change the first few lines from this -

uint16_t syncPhaseAcc; uint16_t syncPhaseInc; uint16_t grainPhaseAcc; uint16_t grainPhaseInc; uint16_t grainAmp; uint8_t grainDecay; uint16_t grain2PhaseAcc; uint16_t grain2PhaseInc; uint16_t grain2Amp; uint8_t grain2Decay;

to this -

uint16_t syncPhaseAcc; volatile uint16_t syncPhaseInc; uint16_t grainPhaseAcc; volatile uint16_t grainPhaseInc; uint16_t grainAmp; volatile uint8_t grainDecay; uint16_t grain2PhaseAcc; volatile uint16_t grain2PhaseInc; uint16_t grain2Amp; volatile uint8_t grain2Decay;

All that we are doing is adding the volatile keyword to the variables which are accessed by both the interrupt service routine and loop. This prevents the compiler from optimising them. Without this keyword, the compiler will optimise the variables inside the interrupt service routine so that they are no longer updated by loop.

Tested in Arduino 1.0

Duane B

rcarduino.blogspot.com

It will stop the compiler from doing unexpected things as you progress your project.

With regards to the grain decay - it didn't made much of a difference in the sound of any Auduino's I built - the synch phase, and the two grain phase increments have the most noticeable effect. Next time I build one, I will probably use the two phase decay controls as output gates instead - one for gate wave form and the other for frequency.

Duane B.