slightly better
This commit is contained in:
@ -12,6 +12,7 @@ class BytebeatProcessor extends AudioWorkletProcessor {
|
||||
this.sampleRate = 8000
|
||||
this.duration = 4
|
||||
this.loopLength = this.sampleRate * this.duration
|
||||
this.playbackRate = 1.0
|
||||
this.error = false
|
||||
|
||||
this.port.onmessage = (event) => {
|
||||
@ -32,6 +33,9 @@ class BytebeatProcessor extends AudioWorkletProcessor {
|
||||
case 'loopLength':
|
||||
this.loopLength = value
|
||||
break
|
||||
case 'playbackRate':
|
||||
this.playbackRate = value
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -71,7 +75,7 @@ class BytebeatProcessor extends AudioWorkletProcessor {
|
||||
}
|
||||
}
|
||||
|
||||
this.t++
|
||||
this.t += this.playbackRate
|
||||
if (this.loopLength > 0 && this.t >= this.loopLength) {
|
||||
this.t = 0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user