gregzanch / cram

cram is a computational room acoustics module to simulate and explore various acoustic properties of a modeled space
https://cram.vercel.app/
MIT License
45 stars 5 forks source link

Dev gz #59

Closed gregzanch closed 3 years ago

gregzanch commented 3 years ago

fix for #58

two things had to be changed:

  1. AudioBuffer did not have a copyToChannel method, so the returned buffer in AudioEngine.createBufferSource had to be filled manually like so:
const sourceBuffer = source.buffer.getChannelData(0);
sourceBuffer.set(buffer, 0);
  1. Apparently OfflineAudioContext.startRendering() does not return the rendered AudioBuffer, instead it can be pulled out of the event callback OfflineAudioContext.oncomplete like so:
context.oncomplete = function(event: OfflineAudioCompletionEvent) {
  if(!event.renderedBuffer){
    reject("failed to get renderedBuffer after context completed rendering");
  } else {
    resolve(event.renderedBuffer);
  }
};
context.startRendering();

see AudioEngine.renderContextAsync for implementation.

vercel[bot] commented 3 years ago

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/gregzanch/cram/Ai267iej5mFXH7gwxAYRFVieivHz
✅ Preview: https://cram-git-dev-gz-gregzanch.vercel.app