Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tone.Offline generated audio falls apart for >30s Audio #551

Closed
Awendel opened this issue Oct 3, 2019 · 7 comments
Closed

Tone.Offline generated audio falls apart for >30s Audio #551

Awendel opened this issue Oct 3, 2019 · 7 comments

Comments

@Awendel
Copy link

Awendel commented Oct 3, 2019

I'm generating Audio within Tone.Offline with a Sampler playing a Pattern
(I have to load the buffer samples externally because of an existing bug where Sampler can't be created within Tone.Offline, which hopefully will be fixed soon)

I'm taking the created Buffer and playing it with Tone.Player() upon its creation.

This works fine for recording between 15s-40s, howeever, anything longer (> 120s) than that seems to render, but the player just doesn't seem to play it.

Is there any existing bug known around Buffers that are perhaps too large or that the playback falls apart?

I could link to a live example tomorrow if folks are unable to reproduce the issue.

@tambien
Copy link
Contributor

tambien commented Oct 3, 2019

Thanks, please include a live example of the bug when you have a moment

@Awendel
Copy link
Author

Awendel commented Oct 4, 2019

No problem:

https://jsfiddle.net/awendel/5j69de8b/16/

the top 2 variables can be modified to change the duration of the recording,
as well as toggle between playing a pattern & just repeatedly triggering a note.

EDIT: I do think the player is not the issue, but that rather the sounds don't created, since I manually checked the array values of the buffers and must of them just seem to be 0.

tambien added a commit that referenced this issue Oct 4, 2019
otherwise it leads to silence

addresses #551
@tambien
Copy link
Contributor

tambien commented Dec 14, 2019

Seems to be fixed in the latest version of tone@typescript.

Here's a validation created from a modification of your code: https://codesandbox.io/s/offline-rendering-test-2vw9r

@Awendel
Copy link
Author

Awendel commented Dec 14, 2019

Glad you were still working on it!
It sure seems a lot more robust now. What was the nature of the issue?

And how stable is the typescript branch for Production? Can all the main components be used without worry?

I played around some more with your modified example and observed quite a strange thing:

The sample works very well for 120s, but when I got up in duration, say 360s or 500s, I can see the CPU rapidly scheduling the notes and creating the Audio buffer (CPU load > 80% and the whole thing is parsed within a matter of seconds).

Yet then there seems to be a sort of "silence" where the CPU doesn't seem to do any work (at 0% load), yet the Audio Buffer doesn't play yet. This silence, I believe, is very small, almost unnoticable at 120s, yet goes up exponentially, the higher you go with duration (up to around 1 MINUTE of silence for 360s) before the playback kicks in.

Any idea what could cause this?

@tambien
Copy link
Contributor

tambien commented Dec 14, 2019

i'd say the typescript branch is fairly stable. far less tested in production environments than @next or @latest, so use at your own risk. Will likely be merged into next soon.

The compute time scales with the number of nodes, scheduled events and the duration being rendering. Not sure about the silence you're referring to. The process for scheduling generating a buffer with Offline:

  1. Invoke the callback function and create all of the nodes in the function
  2. Iterate over the timeline and schedule all events that are scheduled to the Tone.Transport
  3. Render the audio buffer using offlineAudioContext.startRendering()

Step three is maybe where you're experiencing the "silence", but that part is a native call, so i don't have any control over what happens there.

@MaxLaumeister
Copy link

MaxLaumeister commented Dec 22, 2019

I was having the same issue and updated my code to tone@typescript per the recommendation in this thread, and can confirm that the issue is fixed now for me.

Thank you @tambien for your work on this awesome library. I'm looking forward to submitting my project as a demo when it's done!

@tambien
Copy link
Contributor

tambien commented Jan 20, 2020

I think this should be fixed now in 'dev'. Closing this issue. thanks @MaxLaumeister for confirming.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants