This commit is contained in:
2025-09-30 12:21:27 +02:00
parent 07e54ddeab
commit 2b7e09d9c9
3842 changed files with 283556 additions and 109 deletions

View File

@ -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