parse static method
Reads Waveform
data from an audiowaveform-formatted data file.
Implementation
static Future<Waveform> parse(File waveformFile) async {
final bytes = Uint8List.fromList(await waveformFile.readAsBytes()).buffer;
const headerLength = 20;
final header = Uint32List.view(bytes, 0, headerLength);
final flags = header[1];
final data = flags == 0
? Int16List.view(bytes, headerLength ~/ 2)
: Int8List.view(bytes, headerLength);
return Waveform(
version: header[0],
flags: flags,
sampleRate: header[2],
samplesPerPixel: header[3],
length: header[4],
data: data,
);
}