// else if volume is 1 we propagate the unmodified audio data
}
else
{
Time fadingDuration = new Time(mFadingDuration.get(), Time.Unit.NANO);
Time segmentDuration = new Time(frames, rate);
int numSamples = frames;
float volume = intToFloat(mCurrentVolume.get());
float volumeSegment = intToFloat(mTargetVolume.get()) - intToFloat(mCurrentVolume.get());
if(segmentDuration.getInNanoSeconds() > fadingDuration.getInNanoSeconds())
numSamples = (int)fadingDuration.getInSamples(rate);
else
volumeSegment *= (float)((double)segmentDuration.getInNanoSeconds() / (double)fadingDuration.getInNanoSeconds());
for(int i=0; i<numSamples; ++i)
{
int index = i * channels;
double vol = volume + (volumeSegment * (float)i / (float)numSamples);
for(int c=0; c<channels; ++c)
data[index + c] *= vol;
}
for(int i=(numSamples * channels); i<(frames * channels); ++i)
data[i] *= volume + volumeSegment;
mCurrentVolume.addAndGet(floatToInt(volumeSegment));
mFadingDuration.addAndGet(-segmentDuration.getInNanoSeconds());
}
super.propagate(data, frames, channels, rate);
}