1
\$\begingroup\$

My question would be, how can I develop an easy-to-use sound system under slick-util? Under the function

a.playAsSoundEffect(1, 1, true, x, y, z);

it already works to create a static position for the source. But if I adjust my CameraPosition in-game. So how can I change the position of the listener in Slick?

Answers would be awesome :) Thanks, Mineorbit!

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

Looking at the slick-util documentation, it doesn't look like there's a way to just change the x, y, and z positions while a sound is playing. The following is a work-around I could think of off the top of my head, but I don't know how efficient this would be

So, every time the camera position changes (or maybe only when the camera position has changed significantly,) store a.getPosition() in some variable (like lastPosition) to save where the sound was playing from. Then call a.stop(), a.playAsSoundEffect(1, 1, true, new_x, new_y, new_z), and then a.setPosition(lastPosition).

Again, not sure how efficient that would be, but it's an idea.

\$\endgroup\$
2
  • \$\begingroup\$ Thank you verymuch. this might be the obvious solution, but then i had to calculate the positional translatations in perspective of the camera myself, right? 'cause that was the thing I tried to avoid. if I can't figure this out, could somebody send me an easy tutorial link towards openal and an source and listener system. The one on the lwjgl wiki I allready viewed and couldn't get into it. Again thank you very much! \$\endgroup\$
    – Mineorbit
    Commented Jul 24, 2014 at 19:08
  • \$\begingroup\$ Yes, you would have to calculate the translations yourself in this example. I'm not aware of any tutorials specifically for this situation, but I would imagine it's not too hard to figure out. \$\endgroup\$ Commented Jul 25, 2014 at 18:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .