File tree Expand file tree Collapse file tree 2 files changed +13
-5
lines changed
Expand file tree Collapse file tree 2 files changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -196,7 +196,12 @@ class AudioWaveformPainter extends CustomPainter {
196196 }
197197
198198 double normalise (int s, double height) {
199- final y = 32768 + (scale * s).clamp (- 32768.0 , 32767.0 ).toDouble ();
200- return height - 1 - y * height / 65536 ;
199+ if (waveform.flags == 0 ) {
200+ final y = 32768 + (scale * s).clamp (- 32768.0 , 32767.0 ).toDouble ();
201+ return height - 1 - y * height / 65536 ;
202+ } else {
203+ final y = 128 + (scale * s).clamp (- 128.0 , 127.0 ).toDouble ();
204+ return height - 1 - y * height / 256 ;
205+ }
201206 }
202207}
Original file line number Diff line number Diff line change @@ -53,10 +53,13 @@ class JustWaveform {
5353 final bytes = Uint8List .fromList (await waveformFile.readAsBytes ()).buffer;
5454 const headerLength = 20 ;
5555 final header = Uint32List .view (bytes, 0 , headerLength);
56- final data = Int16List .view (bytes, headerLength);
56+ final flags = header[1 ];
57+ final data = flags == 0
58+ ? Int16List .view (bytes, headerLength ~ / 2 )
59+ : Int8List .view (bytes, headerLength);
5760 return Waveform (
5861 version: header[0 ],
59- flags: header[ 1 ] ,
62+ flags: flags ,
6063 sampleRate: header[2 ],
6164 samplesPerPixel: header[3 ],
6265 length: header[4 ],
@@ -99,7 +102,7 @@ class Waveform {
99102 /// A list of min/max pairs, each representing a pixel. For each pixel, the
100103 /// min/max pair represents the minimum and maximum sample over the
101104 /// [samplesPerPixel] range.
102- final Int16List data;
105+ final List < int > data;
103106
104107 Waveform ({
105108 required this .version,
You can’t perform that action at this time.
0 commit comments