I'll hug thehen if I ever see him.

0 favourites
  • 13 posts
  • I want an audio emitter behavior, you assign it to a sprite and in the behavior properties you assign it an audio file from the list of imported sounds, from there you select a range which attenuates volume based on its distance from an assigned game object (listener).

    Also in the properties should be a checkbox to stop playing the audio file when object is out of range.


    If the game object with the audio emitter is copied then the game should play multiple instances of that same audio file, each instance with its own distance attenuation.

    Also there should be a parameter to adjust pitch. And maybe even pitch attenuation based on speed of motion.

    Anyone up for this? I can only afford ?50 :(

  • CrudeMik I don't understand why you can't just set volume based on an objects distance, from another. For pitch shifting based on motion you can just change the pitch based on velocity.

    Any reason why you want this explicitly as a plugin?

  • I am dong it in code at the moment and it's a lot of code for each sound object and I can't copy the emitters to create multiple instances of the same sound.

    This is how I currently do it:

    <img src="https://dl.dropbox.com/u/3317708/audio.jpg" border="0" />

    Problem is that for each doesn't work, it messes up when I copy the emitter object.

    So mostly it's for convenience the game I'm working on has a lot of audio.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The trick is to use families for this sort of thing. If you can set up a simple .capx with what you're doing, I'll put together a workable solution.

  • Thanks for having a look, I've got a testcap from my project here https://dl.dropbox.com/u/3317708/testarea.capx

    I've removed all the levels this is just a layout I use to play with things, the audio emitters are on the debug layer, press tab to turn on the debug ui while running the game.

    Arrows move.

    I took out all the for each commands.

    It would be super useful to get a solution for this but I also still thing the plugin would be a massive time saver for me considering just how much audio I want to implement.

  • Right CrudeMik, there's a lot of stuff you're approaching from a wrong angle that will quickly make this project unmaintainable.

    Here's an example .capx that shows one way you could be handling audio:


    You may want to add more control over the emitters, such as sharper falloff, greater cut off distance etc. These should always be defined as instance variables! This way you reuse the same code for every emitter.

    You don't need so many footstep sfx either. Look at the 'set playback rate' audio action to add subtle pitch variation using Random().

  • That's a brilliant way of doing it, so much simpler than all my code! haha thanks for having a look at it.

    I modified the code to say emitter.soundFile = "sound" set volume to volume -10db as a way of mixing. This doesn't work with ranges though. So I'm not sure of the best way to set individual volumes and ranges.

    One last thing I can't seem to do is use the same sound file in different emitters, it confuses the system and doesn't work. - This is quite important to me as I would like to re-use many smaller spot SFX multiple times across a level. As part of this I also don't know how to stop playing the audio file when out of range to free up resources. In my messy code I used system compare distance to start / stop the files.

    I think it's still good to have more variety in repeated sounds even with random variation, but yeah I will be adding that too!

    Thanks again for having a look man.

  • CrudeMik I better get that hug!

    So yeah, you're right. Using the same sound multiple times won't work with that method. The best way to approach this is to still have it as the same sound that plays, but to base the volume on the nearest emitter to the player.

    Here's an example: https://www.dropbox.com/s/lqfx4qwifiku39c/audioemitters.capx

    I'm not sure I understand your mixing question though.

  • I've worked out a mixing solution, I have one line of code for each sound which lets me mix the levels it's fine.

    This is nearly perfect the only other thing I'd like to do (within the current limitations of the engine) - is to adjust the ranges for each sound independently. Is this possible within this fantastic solution?

    If you're ever in Cambridge I'll buy you a pint!

  • CrudeMik Haha, my hometown is Norwich so not far ;)

    I'm not sure what you mean by adjusting the ranges independently? You can change the pitch with playback rate, but anything more advanced than that is limited by the web audio API I'm afraid.

    Awesome music showreel btw, amazing stuff.

  • Thanks!

    By range I mean the audible distance. Actually I think you made it as roll-off rate. The rate at which it fades from quiet to full volume. Some emitters I'd want to cover a large area and some would be small.

    It's not the web audio API that's limited, the API is able to do amazing things including reverb, doppler, filters, delays etc - the problem is that only Google Chrome currently supports the API and Scirra don't want to have two versions of the audio object.

    I'm gagging for the day to have access to the rest of the API functionality within construct.

    Maybe I should offer out my ?50 again....haha

  • Ah yeah, sorry I meant browser support for the web audio API.

    -Distance(Player.X, Player.Y, Emitter.X, Emitter.Y) / 10

    ^ this code just replace the divide by 10, with divide by an instance variable. The higher the number the further the audible distance.

    Hope that helps.

  • yusss got it, now I'm just trying to stop playing the audio file when out of range... IT NEVER ENDS!

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