-
Notifications
You must be signed in to change notification settings - Fork 55
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
Playing Ambisonic File with Resonace Audio Web SDK #12
Comments
@prioleaud Have you tried Omnitone? That might be a more appropriate solution. |
@brianchirls No I haven't tried it. Thanks for the suggestion! In what way, do you think it will be better suited? |
Since Resonance Audio is powered by Omnitone, is there a way to access the Omnitone object from Resonance Audio, or do you have to load it separately? It would be great if there was some documentation on creating an ambisonic node and connecting it to the audioContext. |
It seems as though all nodes created with cxt.createMediaElementSource() are one channel mono. I'm not sure how to feed the ambisonic input a 4-channel file. That seems to be the issue. Furthermore, it seems that regular single source nodes are converted to mono as well even if your is a stereo file. |
Okay I figured it out... Live site: https://noahneumark.github.io/aframe-resonance-audio/ |
Thanks @noahneumark, just found this thread as I'm trying to do the same thing. Looking at your commits on your project, this seems more complicated than it should be. Appreciate you sharing this. |
My component kit is complicated because it has far more features than just being an ambisonic player. That said, if you are just trying to implement playing ambisonic files, you need to include a function that does this (from connectBuffer() {
//Create 4 channel splitter
this.splitter = this.resonanceAudioContext.createChannelSplitter(4);
//Connect bufferNode to splitter
this.bufferNode.connect(this.splitter)
//Create merger as ambisonicSourceNode
this.ambisonicSourceNode = this.resonanceAudioContext.createChannelMerger()
//Connect splitter to ambisonicSourceNode
this.splitter.connect(this.ambisonicSourceNode, 0, 0)
this.splitter.connect(this.ambisonicSourceNode, 1, 1)
this.splitter.connect(this.ambisonicSourceNode, 2, 2)
this.splitter.connect(this.ambisonicSourceNode, 3, 3)
//Setup ambisonicInput to receive source
this.resonanceAudioScene.ambisonicInput.channelInterpretation = "discrete"
this.resonanceAudioScene.ambisonicInput.channelCountMode = "clamped-max"
this.resonanceAudioScene.ambisonicInput.channelCount = 4
//Connect ambisonicSourceNode to ambisonicInput
this.ambisonicSourceNode.connect(this.resonanceAudioScene.ambisonicInput)
//Set up
this.resonanceAudioScene.ambisonicInput.gain.value = this.data.gain
if (this.data.loop) {
this.bufferNode.loop = true
}
if (this.data.autoplay && this.resonanceAudioContext.state === "running") {
this.bufferNode.start()
}
this.connectedSrc = true
} Let me know if you have any questions about this. |
As suggested by @brianchirls, you'd be better off using Omnitone if the goal is to simply play an ambisonic media. (FOA, SOA, TOA). @prioleaud Please feel free to follow up or close the issue if needed. |
At least some of the other Resonance implementations, iOS for example, seem to have playing sound fields as a feature. The confusion here is that the web SDK doesn't, though it seems to include internals to do so. As for why not just using Omnitone, the reason is to combine sound fields with dynamically spatialize sounds. |
@jwarchol That makes sense. Thanks for the clarification. So the solution is to expose the Omnitone decoder as a part of API? |
Perhaps. I think @prioleaud's original notion of doing something like |
Hi,
This is my first time using Resonance Audio Web SDK and I'm unsure of how to play an ambisonic file with resonance audio. I followed the tutorial to play a monophonic file and changed "resonanceAudioScene.output.connect(audioContext.destination)" to "resonanceAudioScene.ambisonicOutput.connect(audioContext.destination)" and then I changed removed all the code for creating an audio input source.
So I remove:
let source = resonanceAudioScene.createSource();
audioElementSource.connect(source.input);
source.setPosition(-0.707, -0.707, 0);
And replaced it with:
audioElementSource.connect(resonanceAudioScene.ambisonicInput); //to add the Ambisonic soundfield.
Am I going about this correctly? Or am I missing something? Thanks for your help.
The text was updated successfully, but these errors were encountered: