audio position + layout rotation 2

Bugs will be moved here once resolved.

Post » Fri Jul 26, 2013 9:44 pm

@keepee did you find a workaround for this issue?
B
34
S
8
G
5
Posts: 32
Reputation: 5,404

Post » Wed Jul 31, 2013 10:01 pm

@intiva

Yep, but it's a bit ugly.

For the listener object, create a child object on a layer with 0 parallax/scale rate (and also does not rotate in events) I just use my HUD/Interface layer.
Do the same for each sound emitting object.. you'll have to link them however you want.. either use containers, or store the UID of the child in the parent (which i prefer)

so to clarify, each sound emitting object, and the listener object all have child objects that represent them on a layer that does not scroll, rotate or zoom.

then position these objects so they appear pinned to their parents 1:1 using LayerToCanvas and CanvasToLayer   (Translate coords from the 'main' layer, to the canvas, and then from the canvas to the 'interface' layer.. I should probably figure out the maths to simply make a LayerToLayer function, but this whole thing is just a temporary solution for now)

edit (simpler way): set each childs X,Y to their parents X,Y. They won't visually line up because of the parallax being different , but the relative distance between emitters/listener is what's important. Make them spin around the 0,0 coordinate with sin/cos so that they match your layout/layer rotation.

so for example, if the parent family is 'SoundEmitter' and the child object is 'Emit':

+For each SoundEmitter
+pick Emit by UID SoundEmitter.EmitID
+var Dist
+var Ang
        >set Dist to distance(0,0,SoundEmitter.X,SoundEmitter.Y)
        >set Ang to Angle(0,0,SoundEmitter.X,SoundEmitter.Y)
        >set Emit x to Dist*cos(Ang-LayoutAngle)
        >set Emit y to Dist*sin(Ang-LayoutAngle)

The vars aren't necessary but I like it cos it feels cleaner
I do exactly the same for the listener parent and child, except without the for each, because of course there is only one listener.

so anyway, then everything else is the same.. just set the listener object to the listeners child instead, and play each sound at each sound emitters child object.

So basically this workaround works by sorting out the rotation so the sound engine doesn't have to. Doppler effect and Distance model still work fine

The downside is that it creates an extra object for every sound emitter.

@ashley, this might be naive, but does this workaround give you any ideas for fixing it? ofc you won't have to around with additional objects.. I would have simply used 'play at position' and updated the position each tick, but there's no action for doing that.
If this doesn't help, could we still get actions for manually setting the panning + position using tags, like you can with effects? keepee2013-07-31 23:56:13
B
28
S
8
G
1
Posts: 469
Reputation: 4,683

Post » Thu Aug 01, 2013 6:37 pm

Thanks @keepee. I think I understand what you're doing. I'll give it a try as soon as I can.
B
34
S
8
G
5
Posts: 32
Reputation: 5,404

Post » Tue Aug 06, 2013 11:28 pm

I'm encountering this issue too, bit of a pain ;)
B
92
S
31
G
24
Posts: 3,191
Reputation: 32,689

Post » Wed Aug 14, 2013 6:34 pm

Sorry for the long turnaround on this. I think it should be fixed for the next build. I just got the orientation of the layer the wrong way round (should have subtracted off the angle, not added).
Scirra Founder
B
397
S
236
G
88
Posts: 24,423
Reputation: 194,560

Post » Thu Aug 15, 2013 4:52 pm

Seems to be working now, thanks..!

I know that feel with adding/subtracting angles..
B
28
S
8
G
1
Posts: 469
Reputation: 4,683

Previous

Return to Closed bugs

Who is online

Users browsing this forum: No registered users and 3 guests