OK I have a better idea, sorry to make you change this again.  The way this works now, every buffer gets processed twice, once for the crossfade and once for the final version.  Instead lets have two buffers, and process like this:


process(new_buffer, new_value)
if (old_depth!=depth) {crossfadebuffers(output, old_buffer, new_buffer)}
else {copywithgain(output, new_buffer)}
old_buffer = new_buffer

that way you get the processing of the old buffer for free.  you still test to see if old_depth != depth, but that just determines if you do the crossfade.

As for the step old_buffer = new_buffer, it would be easy to actually have the buffers be an array of two buffers, ie buffer[0] and buffer[1], and then have a flipflop value that m_iBufferSwap = 1 - m_iBufferSwap to pick which one is old and which one is new.