public void pull(double[] l, double[] r, int length) { for (int i = 0; i < length; i++) { r[i] = 0.0; l[i] = 0.0; } int remain = length; while (remain > 0) { int amount = (remain > _BUFLEN) ? _BUFLEN : remain; int offset = length - remain; mSender.pull(mBufferL, mBufferR, amount); if (mView != null) { mAmpL = mView.getAmplifyL(); mAmpR = mView.getAmplifyR(); } for (int i = 0; i < amount; i++) { l[i + offset] += mBufferL[i] * mAmpL; r[i + offset] += mBufferR[i] * mAmpR; } remain -= amount; } for (int i = 0; i < length; i++) { if (l[i] > 1.0) { l[i] = 1.0; } else if (l[i] < -1.0) { l[i] = -1.0; } if (r[i] > 1.0) { r[i] = 1.0; } else if (r[i] < -1.0) { r[i] = -1.0; } } }
public void begin(long length, WorkerState state) { mRunning = true; mTotalSamples = length; long remain = length; while (remain > 0 && !state.isCancelRequested()) { int amount = (remain > BUFLEN) ? BUFLEN : (int)remain; mWaveSender.pull(mBufferL, mBufferR, amount); mReceiver.push(mBufferL, mBufferR, amount); remain -= amount; mTotalAppend += amount; } mWaveSender.end(); mReceiver.end(); mRunning = false; }