File tree Expand file tree Collapse file tree 7 files changed +398
-392
lines changed
Expand file tree Collapse file tree 7 files changed +398
-392
lines changed Original file line number Diff line number Diff line change 2121 "@rollup/plugin-node-resolve" : " ^15.2.3" ,
2222 "@rollup/plugin-typescript" : " ^11.1.6" ,
2323 "@types/wav-encoder" : " ^1.3.3" ,
24- "rollup" : " ^4.18.0 " ,
24+ "rollup" : " ^4.21.2 " ,
2525 "rollup-plugin-serve" : " ^2.0.2" ,
26- "tslib" : " ^2.6.3 " ,
27- "typescript" : " ^5.4.5 "
26+ "tslib" : " ^2.7.0 " ,
27+ "typescript" : " ^5.6.2 "
2828 }
2929}
Original file line number Diff line number Diff line change 11{
22 "name" : " @ryohey/wavelet" ,
3- "version" : " 0.7.3 " ,
3+ "version" : " 0.7.4 " ,
44 "description" : " A wavetable synthesizer that never stops the UI thread created by AudioWorklet." ,
55 "main" : " dist/index.js" ,
66 "types" : " dist/index.d.ts" ,
2020 "@rollup/plugin-commonjs" : " ^26.0.1" ,
2121 "@rollup/plugin-node-resolve" : " ^15.2.3" ,
2222 "@rollup/plugin-typescript" : " ^11.1.6" ,
23- "@types/audioworklet" : " ^0.0.55 " ,
23+ "@types/audioworklet" : " ^0.0.60 " ,
2424 "@types/jest" : " ^29.5.12" ,
2525 "jest" : " ^29.7.0" ,
26- "rollup" : " ^4.18.0 " ,
27- "ts-jest" : " ^29.1.4 " ,
28- "tslib" : " ^2.6.3 " ,
29- "typescript" : " ^5.4.5 "
26+ "rollup" : " ^4.21.2 " ,
27+ "ts-jest" : " ^29.2.5 " ,
28+ "tslib" : " ^2.7.0 " ,
29+ "typescript" : " ^5.6.2 "
3030 }
3131}
Original file line number Diff line number Diff line change 1+ /**
2+ * This is a custom implementation of Math.max to prevent call stack size exceeded error
3+ * when using Math.max(...arr).
4+ */
5+ export function max ( arr : number [ ] ) : number | undefined {
6+ if ( arr . length === 0 ) {
7+ return undefined
8+ }
9+ let max = arr [ 0 ]
10+ for ( let i = 1 ; i < arr . length ; i ++ ) {
11+ if ( arr [ i ] > max ) {
12+ max = arr [ i ]
13+ }
14+ }
15+ return max
16+ }
Original file line number Diff line number Diff line change 1- import { SynthEvent } from ".."
1+ import { SynthMessage } from ".."
22import { SynthProcessorCore } from "./SynthProcessorCore"
33
44export class SynthProcessor extends AudioWorkletProcessor {
@@ -10,7 +10,7 @@ export class SynthProcessor extends AudioWorkletProcessor {
1010 constructor ( ) {
1111 super ( )
1212
13- this . port . onmessage = ( e : MessageEvent < SynthEvent > ) => {
13+ this . port . onmessage = ( e : MessageEvent < SynthMessage > ) => {
1414 this . synth . addEvent ( e . data )
1515 }
1616 }
Original file line number Diff line number Diff line change @@ -4,11 +4,12 @@ import {
44 SampleParameterEvent ,
55 SynthEvent ,
66} from ".."
7+ import { max } from "../helper/math"
78import { SynthProcessorCore } from "../processor/SynthProcessorCore"
89
910// returns in frame unit
1011const getSongLength = ( events : SynthEvent [ ] ) =>
11- Math . max ( ... events . map ( ( e ) => ( e . type === "midi" ? e . delayTime : 0 ) ) )
12+ max ( events . map ( ( e ) => ( e . type === "midi" ? e . delayTime : 0 ) ) ) ?? 0
1213
1314// Maximum time to wait for the note release sound to become silent
1415const silentTimeoutSec = 5
You can’t perform that action at this time.
0 commit comments