Katsuyori Posted March 8, 2015 Report Share Posted March 8, 2015 I wanted to fix this bug myself, but couldn't find the code. The problem is when you click on a building, a sound related ot that building is played (/binaries/data/mods/public/audio/interface/select/building). When you click on that building multiple times, the sound also is played multiple times over the previous one. I want it to wait until the previous sound is finished, and then play the new one. Could you show me where the code is so I can fix it? I'm new to the project and I want to fix it myself. Thanks. Quote Link to comment Share on other sites More sharing options...
Stan` Posted March 8, 2015 Report Share Posted March 8, 2015 (edited) You could try :C:\0AD\binaries\data\mods\public\simulation\components\Sound.js // This file reads sounds from XMLsC:\0AD\source\soundmanager\*.*C:\0AD\source\simulation2\components\ //All CPP components are hereWhen you find the source, make sure your create a ticket on trac : http://trac.wildfiregames.com/Also make sure you read http://trac.wildfiregames.com/wiki/SubmittingPatchesRegards, and good luck. Edited March 8, 2015 by stanislas69 Quote Link to comment Share on other sites More sharing options...
Katsuyori Posted March 8, 2015 Author Report Share Posted March 8, 2015 You could try :C:\0AD\binaries\data\mods\public\simulation\components\Sound.js // This file reads sounds from XMLsC:\0AD\source\soundmanager\*.*C:\0AD\source\simulation2\components\ //All CPP components are hereWhen you find the source, make sure your create a ticket on trac : http://trac.wildfiregames.com/Also make sure you read http://trac.wildfiregames.com/wiki/SubmittingPatchesRegards, and good luck.Thanks. I also found something else related to GUI in /binaries/data/mods/public/gui/session/selection.js and under the "EntitySelection.prototype.addList" function, there are some lines of code like this: // Play the sound if the entity is controllable by us or Gaia-owned. var owner = GetEntityState(added[0]).player; if (!quiet && (owner == playerID || owner == 0 || g_DevSettings.controlAll)) _playSound(added[0]); }Would it matter if I change the if statement here? Quote Link to comment Share on other sites More sharing options...
Stan` Posted March 8, 2015 Report Share Posted March 8, 2015 No like sanderd17 suggested on IRC just add a time check in it. Quote Link to comment Share on other sites More sharing options...
Katsuyori Posted March 8, 2015 Author Report Share Posted March 8, 2015 (edited) No like sanderd17 suggested on IRC just add a time check in it. Yea I posted this a little bit before getting the answer on IRC. How can I get the time of the last played sound on that building? I mean I get the whole idea, but I don't know how to get that time. Edited March 8, 2015 by Katsuyori Quote Link to comment Share on other sites More sharing options...
sanderd17 Posted March 8, 2015 Report Share Posted March 8, 2015 In the GUI, you should be able to use the system dependant time. So +(new Date()) should give you the system time since 1970 (I guess in seconds, but you should read the docs for that). Quote Link to comment Share on other sites More sharing options...
historic_bruno Posted March 8, 2015 Report Share Posted March 8, 2015 This is something that was never implemented in the new sound manager, but was a desired feature from the start, so it should be implemented there. Every sound needs limits on how many times it can be played simultaneously, even battle sounds, and some like UI sounds should only play once like you propose. 1 Quote Link to comment Share on other sites More sharing options...
wowgetoffyourcellphone Posted March 9, 2015 Report Share Posted March 9, 2015 Hmm, I dont see as bug. I think player should get audio feedbacks whenever clicking the building. In fact it feel odd when clicking enemy building and hearing no sound for exampl. Quote Link to comment Share on other sites More sharing options...
sanderd17 Posted March 9, 2015 Report Share Posted March 9, 2015 Hbruno, well I doubted where it should go. Having it in the selection code may have some advantages for modability. Though indeed, it wouldn't work for battle sounds. Also, the lenghth shouldn't necesarily be the same as the file length. It could be you want a longer silence, or that the second sound can already start on the fade-out of the first one. Quote Link to comment Share on other sites More sharing options...
historic_bruno Posted March 11, 2015 Report Share Posted March 11, 2015 I like the idea of having a configurable "cooldown" period for sounds, a delay before the sound can be played again, that should cover this bug. It's better handled in the engine because it knows how long the sound will play, but exposing an API for that in scripts would be needlessly messy IMO - or a hack to workaround current behavior. Battle sounds would be more involved, either a limit on how many instances can play simultaneously and/or switching to a different sound set for heated battle (to some extent, playing individual sounds over and over doesn't give the same dramatic impression as well-crafted battle sounds). 2 Quote Link to comment Share on other sites More sharing options...
sanderd17 Posted March 12, 2015 Report Share Posted March 12, 2015 So @Katsuyori, if you'd like to keep working on it, it would be better to start of in the sound engine instead. I believe you know C++, so it wouldn't be that hard. In this case, I would suggest adding parameters to the sound settings (like http://trac.wildfiregames.com/browser/ps/trunk/binaries/data/mods/public/audio/interface/select/building/sel_barracks.xml), which can be read by the sound engine ( http://trac.wildfiregames.com/browser/ps/trunk/source/soundmanager ) I hope this helps. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.