audio position + layout rotation 2

0 favourites
  • 15 posts
From the Asset Store
100+ Musical High Quality Sound Effects for your game!
  • It seems that the closer the layer angle is to 180 degrees, the more the sounds are relative to the scroll position , rather than the listener object.

    edit: i notice this might sound like i'm wanting an inconsistency, where really it should either:

    follow the layer angle and the layer scroll position

    or

    follow the listener angle and the listener position

    .. so i should probably give it context, the idea is that, the camera is mouse controlled, centred a varying distance inbetween the player and mouse cursor, as if the player character is 'looking' over in that direction.. but not 'listening' over in that direction, and the rotation is still locked to the players rotation.. hope that makes sense.

    But I imagine a lot of people would want to set the the listener coord to the scroll position actually.. so it could be an option? just an idea.

    Here's the same .capx with scrolling

    Link to .capx file (required!):

    https://dl.dropboxusercontent.com/u/53374990/Forum/bugs/AudioRotation2.capx

    Steps to reproduce:

    1. rotate to 180 degrees with arrow keys

    2. scroll away from sound emitting object

    3.

    Observed result:

    volume gets quieter

    Expected result:

    should stay relative to listener object

    thanks again

    Browsers affected:

    Chrome: yes/no

    Firefox: yes/no

    Internet Explorer: yes/no

    Operating system & service pack:

    Construct 2 version:

        137

  • Noticed another bug, or a related factor to the same bug?

    As listener and sound emitter are moved away from the diagonal line, the volume decreases

    you don't need to rotate layer towards 180 degrees, but it does need to be rotated *some* amount for this bug to happen.. So the layer is angled to 1 on startup

    easier to show inside a .capx

    https://www.dropbox.com/s/fo234q7wdrcy2gj/AudioRotation3.capx

  • I've made a change for the next build to make the sounds always rotate relative to the listener, but it's pretty difficult to make it take in to account parallax. Do you really need that?

    Your second example uses a reference distance of 0, which doesn't really make any sense and probably causes the problem. You shouldn't change the values unless you know what you're after.

  • I turned the properties down in general so you didn't have to move out as far.

    I know what all the properties do, there's no reason ref distance of 0 should create this effect..

    sounds full at 0,0 and 500,500

    but down at 0,500 and 500,0

    it's gotta be a bug, some broken coords somewhere.

    Turn everything back to default and it still happens, you just have to move further out.

    Do you really need that?

    Do i really need the audio to work with scrolling..?

    of course!

    honestly though I wasn't expecting an advanced audio engine anyway, so the whole thing was a bonus that i don't really need.

  • The reference distance is used to measure attenuation over distance. If the reference distance is 100, then it means the sound will be reduced by a factor of two (or different depending on the particular formula) at a distance of 200, a factor of four at 400, and so on. If you set it to 0, it means infinite attenuation happens after 1 pixel, so the audio engine probably won't do anything reasonable or sensible in that case.

  • I see.. the manual makes it sound like it is a plateau -a distance before the attenuation starts.

    but regardless, the bug is still there if you leave it as the default values. So it's not what's causing it.

  • keepee - just a heads up, turns out there was another mistake in the calculation of panning for positioned sounds on rotated layers. Oops! It should be fixed in the next build, and it makes your AudioRotation3.capx example work correctly. Sorry for the confusion.

  • Ashley, excellent! thanks, and for notifying also

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • bad news,

    Now, the left/right panning is correct at 0 and 180, but as it is angled towards 90 or 270, it gets entirely flipped.

    This is not noticeable in AudioRotation2.capx (in OP), because at angle 90/270, the speaker appears above or below you.

    So, here's another. It's the same as AudioRotation2.capx but with the speaker moved, and without the scrolling as that all seems to be good now.

    https://www.dropbox.com/s/goj8x69w2sm8nv2/AudioRotation4.capx

    Ashley

  • keepee did you find a workaround for this issue?

  • 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.

    <strike>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) </strike>

    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 <img src="smileys/smiley35.gif" border="0"> 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?

  • Thanks I think I understand what you're doing. I'll give it a try as soon as I can.

  • I'm encountering this issue too, bit of a pain ;)

  • 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).

  • Seems to be working now, thanks..!

    I know that feel with adding/subtracting angles..

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)