File tree Expand file tree Collapse file tree 2 files changed +15
-7
lines changed Expand file tree Collapse file tree 2 files changed +15
-7
lines changed Original file line number Diff line number Diff line change @@ -404,7 +404,11 @@ class WaveSurfer extends Player<WaveSurferEvents> {
404
404
const sampleSize = Math . round ( channel . length / maxLength )
405
405
for ( let i = 0 ; i < maxLength ; i ++ ) {
406
406
const sample = channel . slice ( i * sampleSize , ( i + 1 ) * sampleSize )
407
- const max = Math . max ( ...sample )
407
+ let max = 0
408
+ for ( let x = 0 ; x < sample . length ; x ++ ) {
409
+ const n = sample [ x ]
410
+ if ( Math . abs ( n ) > Math . abs ( max ) ) max = n
411
+ }
408
412
data . push ( Math . round ( max * precision ) / precision )
409
413
}
410
414
peaks . push ( data )
Original file line number Diff line number Diff line change @@ -100,14 +100,18 @@ class WebAudioPlayer extends EventEmitter<WebAudioPlayerEvents> {
100
100
this . emit ( 'pause' )
101
101
}
102
102
103
- stopAt ( timeSeconds : number ) {
103
+ stopAt ( timeSeconds : number ) {
104
104
const delay = timeSeconds - this . currentTime
105
105
this . bufferNode ?. stop ( this . audioContext . currentTime + delay )
106
-
107
- this . bufferNode ?. addEventListener ( 'ended' , ( ) => {
108
- this . bufferNode = null
109
- this . pause ( )
110
- } , { once : true } )
106
+
107
+ this . bufferNode ?. addEventListener (
108
+ 'ended' ,
109
+ ( ) => {
110
+ this . bufferNode = null
111
+ this . pause ( )
112
+ } ,
113
+ { once : true } ,
114
+ )
111
115
}
112
116
113
117
async setSinkId ( deviceId : string ) {
You can’t perform that action at this time.
0 commit comments