I'm using the UWP AudioGraph API to generate tones as in the SDK sample for audio creation. It works fine, but I'm trying to add panning. I can get it to pan all the way to the left speaker, but not all the way to the right. For example,
leftEmitter = new AudioNodeEmitter(AudioNodeEmitterShape.CreateOmnidirectional(), AudioNodeEmitterDecayModel.CreateCustom(1, 1), AudioNodeEmitterSettings.DisableDoppler); leftEmitter.Position = new System.Numerics.Vector3(-1, 0, 0); leftEmitter.Gain = 1; frameInputNodeLeft = graph.CreateFrameInputNode(nodeEncodingProperties, leftEmitter); frameInputNodeLeft.AddOutgoingConnection(deviceOutputNode);
This sets the position as x = -1, y = 0 and z = 0. It only comes out of the left speaker, which is great, but it's opposite,
leftEmitter.Position = new System.Numerics.Vector3(1, 0, 0);
This comes out of both speakers, why is this? Maybe I'm misunderstanding the coordinate system? I'm using headphones too so aren't mistaken about where it's coming out of.
Nick.
PS: I'm also trying real-time panning from left to right, I start with this position,
leftEmitter.Position = new System.Numerics.Vector3(-100, 0, 10)
And I add 0.1 to the X position every time the frame is rendered, it results in me hearing it all the way in the left speaker, to slowly moving to the right, BUT, it gets stuck just after the half way point, at least that's what it sounds like. It won't go any further than that.
Sample code:
Goto scenario 3, and press "Left" button to hear panning from left to right.
0 comments:
Post a Comment