renderInterleaved method

void renderInterleaved(
  1. Float32List destination, {
  2. int offset = 0,
  3. int? length,
})
Renders the waveform as a stereo interleaved signal. The audio renderer. The destination buffer.

Implementation

void renderInterleaved(Float32List destination, {int offset = 0, int? length}) {
  if (destination.length % 2 != 0) {
    throw "The length of the destination buffer must be even.";
  }

  int sampleCount = 0;

  if (length != null) {
    sampleCount = length;
  } else {
    sampleCount = destination.length ~/ 2;
    sampleCount -= offset;
  }

  final left = Float32List(sampleCount);
  final right = Float32List(sampleCount);

  render(left, right);

  for (var t = 0; t < sampleCount; t++) {
    destination[offset + t * 2 + 0] = left[t];
    destination[offset + t * 2 + 1] = right[t];
  }
}