ok
This commit is contained in:
@ -22,6 +22,17 @@ export class BytebeatGenerator {
|
||||
this.duration = options.duration ?? 10
|
||||
}
|
||||
|
||||
updateOptions(options: Partial<BytebeatOptions>): void {
|
||||
if (options.sampleRate !== undefined) {
|
||||
this.sampleRate = options.sampleRate
|
||||
this.audioBuffer = null
|
||||
}
|
||||
if (options.duration !== undefined) {
|
||||
this.duration = options.duration
|
||||
this.audioBuffer = null
|
||||
}
|
||||
}
|
||||
|
||||
setFormula(formula: string): void {
|
||||
this.formula = formula
|
||||
try {
|
||||
@ -106,6 +117,25 @@ export class BytebeatGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
onLoopEnd(callback: () => void): void {
|
||||
if (this.sourceNode && !this.sourceNode.loop) {
|
||||
this.sourceNode.onended = callback
|
||||
}
|
||||
}
|
||||
|
||||
setLooping(loop: boolean): void {
|
||||
this.isLooping = loop
|
||||
}
|
||||
|
||||
scheduleNextTrack(callback: () => void): void {
|
||||
if (this.audioContext && this.sourceNode) {
|
||||
this.sourceNode.loop = false
|
||||
this.sourceNode.onended = () => {
|
||||
callback()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pause(): void {
|
||||
if (this.sourceNode && this.audioContext) {
|
||||
this.pauseTime = this.audioContext.currentTime - this.startTime
|
||||
|
||||
Reference in New Issue
Block a user