renderPcm method
Future<Int16List>
renderPcm({
- required String sourcePath,
- required WaveformDocument document,
override
This method renders document to 16-bit PCM and writes no file.
The samples are byte-identical to the samples that exportWav writes for the same document, because both methods run the same C loop. That equality is the whole point. It is the reason that you can trust a preview before you commit an edit.
This method returns interleaved frames at the sample rate and the channel
count that the source itself uses. The whole render stays resident in
memory. Therefore this method is for previews and tests, and not for an
audiobook. For streaming playback, openPlayback opens a
PlaybackSession. ROADMAP.md has more information.
Web has no filesystem to read, so this method is not available there.
Implementation
@override
Future<Int16List> renderPcm({
required String sourcePath,
required WaveformDocument document,
}) async {
renders.add((sourcePath, document));
final error = nextRenderError;
if (error != null) {
nextRenderError = null;
throw error;
}
final canned = nextRender;
if (canned != null) {
nextRender = null;
return canned;
}
var frames = 0;
for (final region in document.regions) {
final length = region.sourceEnd - region.sourceStart;
if (length > 0) frames += length;
}
return Int16List(frames);
}