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

Better support for Three.js integration #90

Open
hoch opened this issue Mar 13, 2018 · 7 comments
Open

Better support for Three.js integration #90

hoch opened this issue Mar 13, 2018 · 7 comments
Assignees

Comments

@hoch
Copy link
Member

hoch commented Mar 13, 2018

@drewbitllama

What can be done to support the Three.js integration better? We can consider adding new APIs for this purpose.

FYI: This topic stemmed from this PR.

@hoch hoch self-assigned this Mar 13, 2018
@iooops
Copy link

iooops commented Mar 15, 2019

Can you make it a smoother transition whenever a Listener/Source Position/Rotation is set? When I use a slider in Threejs to change the params, I always hear the clipping sounds, which is not so tolerable.

/**
 * Updates the rotation matrix with 4x4 matrix.
 * @param {Number[]} rotationMatrix4 - A 4x4 rotation matrix. (column-major)
 */
FOARotator.prototype.setRotationMatrix4 = function(rotationMatrix4) {
  this._m0.gain.value = rotationMatrix4[0];
  this._m1.gain.value = rotationMatrix4[1];
  this._m2.gain.value = rotationMatrix4[2];
  this._m3.gain.value = rotationMatrix4[4];
  this._m4.gain.value = rotationMatrix4[5];
  this._m5.gain.value = rotationMatrix4[6];
  this._m6.gain.value = rotationMatrix4[8];
  this._m7.gain.value = rotationMatrix4[9];
  this._m8.gain.value = rotationMatrix4[10];
};

Maybe can change it like

FOARotator.prototype.setRotationMatrix4 = function(rotationMatrix4, endTime=this.context.currentTime+0.01) {
  this._m0.gain.linearRampToValue(rotationMatrix4[0], endTime);
  ......
}

@hoch
Copy link
Member Author

hoch commented Mar 15, 2019

Thanks for suggestion! There are two things to consider.

  1. We don't want to break things that are already using this function.
  2. Also there's performance implication of using AudioParam automation.
  3. Does linear interpolation of each value in the matrix make sense here?

1 or 2 is not a big deal, but I want to make sure about 3. These values are not directly related to the position or angle. The linear interpolation on each value might not make sense (mathematically) in this context. @drewbitllama might have some ideas on this.

Also if I have to add this feature, it'll be a new method tied to FOA/HOA rotator.

@iooops
Copy link

iooops commented Mar 15, 2019 via email

@hoch
Copy link
Member Author

hoch commented Mar 15, 2019

Can you elaborate on "improve the performance a lot"? Does it use less CPU? Or you meant better audio quality (like less glitching)?

@iooops
Copy link

iooops commented Mar 15, 2019 via email

@hoch
Copy link
Member Author

hoch commented Mar 15, 2019

Thanks. AudioParam.value = v is identical to AudioParam.setValueAtTime(v, t). So it is an instantaneous jump. No matter how you do it, it won't be sample-accurate interpolation.

On the other hand, setValueAtTime is much lighter than linearRampToValueAtTime function, but in this case I don't think it really matters in terms of the performance because it only has 9 AudioParams to deal with.

But the question still remains: is this mathematically correct? I have to rely on @drewbitllama's opinion on this. If the answer is yes, I can fix this right away.

@ttoommmmiiee
Copy link

Hi there, I am currently working on a project that uses Omnitone and Three.js and wondering if there's any update on the issues raised in this thread. I am also encountering some glitching - even when moving quite slowly around the scene. Thanks!

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

No branches or pull requests

3 participants