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

Playing Ambisonic File with Resonace Audio Web SDK #12

Open
prioleaud opened this issue May 31, 2018 · 11 comments
Open

Playing Ambisonic File with Resonace Audio Web SDK #12

prioleaud opened this issue May 31, 2018 · 11 comments

Comments

@prioleaud
Copy link

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.

@brianchirls
Copy link

@prioleaud Have you tried Omnitone? That might be a more appropriate solution.

@prioleaud
Copy link
Author

@brianchirls No I haven't tried it. Thanks for the suggestion! In what way, do you think it will be better suited?

@noahneumark
Copy link

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.

@noahneumark
Copy link

noahneumark commented Jul 9, 2018

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.

@noahneumark
Copy link

noahneumark commented Jul 11, 2018

@jwarchol
Copy link

jwarchol commented Aug 1, 2018

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.

@noahneumark
Copy link

noahneumark commented Aug 2, 2018

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 resonance-audio-room component):

  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.

@hoch
Copy link
Collaborator

hoch commented Oct 18, 2018

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.

@hoch hoch added the question label Oct 18, 2018
@jwarchol
Copy link

jwarchol commented Oct 18, 2018

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.

@hoch
Copy link
Collaborator

hoch commented Oct 18, 2018

@jwarchol That makes sense. Thanks for the clarification. So the solution is to expose the Omnitone decoder as a part of API?

@jwarchol
Copy link

Perhaps. I think @prioleaud's original notion of doing something like audioElementSource.connect(resonanceAudioScene.ambisonicInput); feels good, if that sort of an interface is possible.

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

5 participants