1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

UE3 - UT3 Getting noise data

Discussion in 'Programming' started by smnunnally, Jun 4, 2009.

  1. Zur

    Zur surrealistic mad cow

    Joined:
    Jul 8, 2002
    Messages:
    11,702
    Likes Received:
    4
  2. smnunnally

    smnunnally New Member

    Joined:
    Jun 4, 2009
    Messages:
    28
    Likes Received:
    0
    I'm afraid it doesn't work like UT1. I tried to do that and each trace I start inside the wall immediately stops. For now it basically works because I just keep moving 1 UU in the direction of the sound until I hit the end point where the sound should be, but this has to be really inefficiant. Any time a sound is made on the other side of the wall I have to run about 40 traces or more, depending on the wall thickness and angle. I could cut down on this this a bit by moving more than 1 UU at a time, but then I lose an accurate reading of the wall size. It might not be important how accurate it is, I haven't decided yet, but I would hope that there is a way to only run a trace no more than the number of obstructions between me and the location of the sound. I thought TraceActors looked good, but it never gave me a list, just the first actor it ran into. Any other help?
     
  3. brold9999

    brold9999 New Member

    Joined:
    Apr 5, 2009
    Messages:
    142
    Likes Received:
    0
    If by the filename of the sound, you want the name of the package, I think you can derive that from the SoundCue. If what you want is the name of the file that the sound was originally imported from I don't think it's stored.

    I haven't tried TraceActors on UT3 but it seemed to work on UT2004. Note that since it's an iterator, it doesn't give you a list but rather loops for each thing hit by the trace (starting with the first). If you want a list you have to build it in the loop.

    Traces are considered sort of expensive if you are doing alot of them but also bear in mind that the cost of traces has not increased much since UT1 when they were initially considered "expensive". They aren't "cheap" but you can do a couple hundred a tick with no obvious performance degradation. Also bear in mind that shorter traces use less resources.
     
  4. smnunnally

    smnunnally New Member

    Joined:
    Jun 4, 2009
    Messages:
    28
    Likes Received:
    0
    Alright, I just figured out the stuff about the sound and I am getting what I need. I imagine when I pass the information along I can always just ask whatever actor I want to play the sound I pass, so the package will do just fine.

    As for the TraceActors on UT3, I was running it in a foreach loop to go through all possibilities and just printed each actor it hit. If there was no wall between myself and the sensor I got the pawn as the only actor on that trace line. When I did it with a wall between myself and the sensor I only go the wall as the only actor on the trace line. This didn't change even if there were more walls between myself and the sensor. It appeared to me to be stopping as soon as it hit the first actor, and not continuing like it said it would.

    I will have to talk to my advisor to see if he is happy enough with a couple hundred traces a tick, especially since most don't even go anywhere, just start and stop, then I will probably just stick with what I have. Our conversion is 250 UU per meter, so I might just ignore the wall thicknesses completely since even in my few worse case scenarios I would only be adding about 2 meters on to my distance, and at that distance the logarithmic nature of the drop-off rate makes the volume change nearly non-existent.

    Thanks everyone for the help, I think I finally have exactly what I need now to pass on the information so that those making a sensor get the same information as if they had a microphone. Any specific questions for me about my code let me know and I'll try to post it for those following this thread for their needs.
     
  5. eblade

    eblade New Member

    Joined:
    Jan 29, 2006
    Messages:
    113
    Likes Received:
    0
    crap i forgot we were working with UT3...

    Looks like there is no AIHearSound in UT3, only ClientHearSound. I guess they decided if someone wants full noise data for AIControllers, they'll need to code it themselves.. bah
     
  6. smnunnally

    smnunnally New Member

    Joined:
    Jun 4, 2009
    Messages:
    28
    Likes Received:
    0
    Alright, I'm trying to test HearNoise to see how it will deal with multiple sounds at the same sound. I expect it to only give me the data of the last sound it heard and just overwrite the data for the rest, but I just want to be sure. I am spawning a weapon and calling PlayFiringSound every tick, and then I make my own sounds with a character. I toggle between normal firing and alt. firing so that I can tell when I am overwriting data and so fourth. Unfortunately when I call PlayFiringSound nothing happens. No MakeNoise function is called, or at least the HearNoise event is not being triggered. Any suggestions?
     
  7. smnunnally

    smnunnally New Member

    Joined:
    Jun 4, 2009
    Messages:
    28
    Likes Received:
    0
    Alright, I decided that I will just skip the test for now and added in arrays in my HearController class and store all data I get into these two arrays until the tick, where I will do all of the computations and empty these arrays. This will work for any number of times that HearNoise is triggered, so I am much more confident about my sensor "hearing" all of the sounds.

    Unfortunately not being able to do the above mentioned test means I don't know how to get HearNoise to actually trigger. I tried just calling MakeNoise(1.0f) before checking my HearController for new data from the HearNoise event, but this didn't work. I tried attaching it to an instigator, spawning multiple robots, with sensors that should also be making a noise, since it is all of the same code, but none of this triggered the HearNoise event. I need to be able to know how to trigger the HearNoise event because when someone wants to use the simulation and add a sound to the world, my sensor will only work if they can make their sound trigger the HearNoise event. I was hoping to get some additional suggestions on this. I was trying to spawn the weapon because I knew that the sensor was picking up when my character was firing, but even that didn't trigger the event. I made sure to fix all of the script warning, by putting the weapon in an InventoryManager and so on, but still HearNoise did not trigger, so I am not sure MakeNoise works like the source code in the Actor class suggests.

    I also need to capture the audio that is streaming from the game. I am looking at a few options and was hoping to get some input on which might be best and maybe how to work it out. I am still hoping to find a way to capture the audio stream from the Unreal engine, but can't see any way to do this. My second option is to capture it when it goes to the sound card port, but I must have the UT3 window active when this happens, plus I must write in some language outside of UScript. I am fairly certain I can figure out how to do this in java, but I might need to write it in c/c++ and I have been unsuccessful with figuring out how to get the stream in this language. The final option, which is only a fallback, is to get a library of all sounds that might be played with the same names as the sound in the unreal package, so that when I get the name of the SoundCue that was played I can just search the library and play the sound, once again outside of UScript.

    All suggestions are appreciated, although I'm not sure how much help you guys can be on the programming issues that will take place outside of UScript. If you can't help there but know a good c++ or java programming forum I'll search those for the answer. I tried to find some, but Google did not give me what I would consider trustworthy sites to check for coding help. Thanks again.
     
  8. smnunnally

    smnunnally New Member

    Joined:
    Jun 4, 2009
    Messages:
    28
    Likes Received:
    0
    I still could use some help trying to figure out how to get my HearNoise to trigger in my own code, not by just running around my robot with a character and shooting.

    I have decided to capture the audio as it goes to my machine, so I will capture it outside of UT3 entirely. I believe I have figured out how to do this, but I am trying to solve the problem that UT3 mutes its sounds when the window is not highlighted. I would like it to make sound whenever it is open so that I am constantly feeding the sounds that I want even if the UT3 window is not selected. Are there any mods, suggestions, or configurations out there that will allow this to happen?
     
  9. brold9999

    brold9999 New Member

    Joined:
    Apr 5, 2009
    Messages:
    142
    Likes Received:
    0
    I'm not sure under what circumstances the HearNoise event will be triggered. In the worst case you can use an iterator such as DynamicActors to find all sensors and trigger an event on them directly instead of relying on the native event; if the native event doesn't fire when you need it to.

    I don't know of a way to change the behaviour of the sound muting when minimizing UT3. There might be some obscure INI setting that can control this but I wouldn't be surprised if no method is provided. Why do you need to capture the actual audio? You might run into some issues there re: user interface sounds like the announcer or navigating menus.
     
  10. smnunnally

    smnunnally New Member

    Joined:
    Jun 4, 2009
    Messages:
    28
    Likes Received:
    0
    With the simulation we are running we have our own input controllers to control the robot using an outside program that allows for easy programming of controls. It is setup so that any user interested in making a controller for real robots can send the simulation the same commands as a real robot would need to perform different function. That way you can see how it works in simulation and then immediately use it on the real robot without any extra programming. We also send video feeds, and want to send sound feeds, to this same program, which is why we need to capture the actual audio because some setups run this program on a separate computer than the UT3 window.

    My sound server and client program will also allow multiple clients, so that when they do Robocup, the spectators of the event will be able to listen in to what the competitors hear as well. That's why it’s important, but I think we can just put it in our documentation that the window must be highlighted to work with sound correctly. The robots only need to hear victims and gas leaks and things of that nature that would be found at a disaster scene.

    Your idea about the event triggering might be my only option, but if someone out there knows how to trigger the HearNoise event, I would rather do it that way.
     
  11. DannyMeister

    DannyMeister UT3 Jailbreak Coder

    Joined:
    Dec 11, 2002
    Messages:
    1,270
    Likes Received:
    0
    What happened to your sensors? Back on the June 11th post you said that it detected it when calling MakeNoise().

    In my experience, MakeNoise() has triggered the HearNoise event for bots. I wrote code for an automated turret, and as it activates and each time it fires I call MakeNoise(). The bots had the HearNoise event triggered, and they would turn and acquire the turret as their enemy.
     
  12. smnunnally

    smnunnally New Member

    Joined:
    Jun 4, 2009
    Messages:
    28
    Likes Received:
    0
    I can still trigger the event when I have a character in the level and jump and shoot with him, but when I was testing my sensor and trying to create my own noise I couldn't get it to trigger. I tried just calling make noise to get the event to fire, but that didn't work, so then I tried to attach a weapon that fired from the robot every tick. I made sure to add an InventoryManager and everything to get rid of all script warnings, but still no event triggered, even though I am pretty sure I am basically using the same MakeNoise function when firing the weapon I attached to the robot as when my character shoots. So something is going on that isn't allowing the event to trigger.

    I need to figure out how to trigger it so that I can make my own noises. Just to clarify I did try adding two robots that were both shooting and both listening on the HearEvent and neither heard each other’s shooting. I just wanted to see if the instigator of a sound didn't call its own HearNoise, but this didn't work either.
     
  13. brold9999

    brold9999 New Member

    Joined:
    Apr 5, 2009
    Messages:
    142
    Likes Received:
    0
    This is just a stab in the dark, but maybe MakeNoise only propogates when called from certain classes? Not sure about this; seems like it would be odd if it were this way but there are some things (like states) that only work in certain classes.
     
  14. DannyMeister

    DannyMeister UT3 Jailbreak Coder

    Joined:
    Dec 11, 2002
    Messages:
    1,270
    Likes Received:
    0
    What I have tried successfully is making a noise in a Pawn class, and hearing it in a Controller class.

    Remember that events can have a separate function for each state. Are you maybe in some state that the super class defines the event, and you haven't overridden it in that same state?
     
  15. smnunnally

    smnunnally New Member

    Joined:
    Jun 4, 2009
    Messages:
    28
    Likes Received:
    0
    Alright, I still haven't figured out why exactly the HearNoise won't trigger when I expect it too. It is possible that it has something to do with states, but I am not too concerned about this at the moment because I have other options and I am running out of time to finish all of this up. One other option might be writing my own event and trigger. Is there a good tutorial for this, or thread somewhere? I am sorry I haven't looked that hard for it yet, but it would save time if someone knows off the top of their head and could get me a link.

    I want to change the volume levels of the game in my code because I thought it would be cool to only allow sounds to be played when the user has my sensor attached, so I want to set the default volume levels to 0, then turn them back up to 5. I am having a few different problems with this.

    The config file that sets the audio volumes is UTGame.ini. [SFXVolume UTUIDataProvider_MenuOption] is the first line of the list of audio menu options. In RangeData, it appears that I can change the MinValue and MaxValue, but not CurrentValue. I think it has something to do with the fact that the CurrentValue variable is public, so somewhere in UT3's code they are setting this. This should be good news because that means I should be able to change this value in my code, but I don't know how to access this variable. If I can do this then I will set the variable to 0 when a robot is spawned without a sound sensor, or set it to 5 if it does have a sound sensor. Any ideas on how I can get to this variable to modify it?

    I am just not sure where to start looking and there isn't any AllObject iterator to my knowledge that would allow me to access this class, which is under UIRoot, not Actor. Again this is not going to fail my sound sensor if I can't get this working, but it would be more realistic if it did work this way.

    I have the SoundServer and Client working so that I can send the audio output to the client, so if anyone was following this thread and was interested in that let me know and I might be able to help you out.
     
  16. brold9999

    brold9999 New Member

    Joined:
    Apr 5, 2009
    Messages:
    142
    Likes Received:
    0
    You can access iterators from other classes, eg if you have a reference to an actor called myActor, you can use foreach myActor.AllObjects(...)

    I don't think the INI file is going to be viable for changing volume at runtime. You can probably use console commands to do it, and console commands can be executed programatically, but I haven't tried for something like changing volume.
     
  17. smnunnally

    smnunnally New Member

    Joined:
    Jun 4, 2009
    Messages:
    28
    Likes Received:
    0
    I do not mean I want to change the INI file. I want to change the variable that is set by the INI file. The volume controls are all UTUIDataProvider_MenuOption classes. They have a RangeData variable that is a struct that has two public variables. One is CurrentValue. When I change CurrentValue in the INI file, it does not change the actual value, and I suspect this is because it is public and UT3's code is changing it back to normal somewhere, or maybe going with default values. When I change one of the non-public variables, that value does change, so that's why I think it is possible to change this CurrentValue at runtime.

    I cannot access this variable though because I do not know how to get to it. I want to use an AllObject iterator but I cannot find one. UTUIDataProvider_MenuOption does not descend from Actor, it descends from UIRoot. That is why I cannot use the AllActors iterator. If someone knows of an iterator that can go through all Objects, then that is what I need to get the variables and change their current value during runtime, but right now I am not sure how to do that.

    I also do not know what you mean by console commands? Are you talking about changing the volume of the computer? And if I did this how would I know whether or not the robot I just spawned has a sound sensor or not if I am doing this separate of my UScript code?
     
  18. DannyMeister

    DannyMeister UT3 Jailbreak Coder

    Joined:
    Dec 11, 2002
    Messages:
    1,270
    Likes Received:
    0
    From Engine\AudioDevice.uc:

    Give this a try:

    Code:
    AD = class'Engine'.static.GetAudioDevice();
    if (AD != None)
    {
    	AD.TransientMasterVolume = 0.0;
    }
    
    For re-enabling sound put the TransientMasterVolume back to 1.0.
     
  19. smnunnally

    smnunnally New Member

    Joined:
    Jun 4, 2009
    Messages:
    28
    Likes Received:
    0
    I tried this, but it did not have any effect. I was able to get the audio device that way, but when I changed the value of TransientMasterVolume two things happened. After each tick it would change back to 1.0, which I think has something to do with it being transient. Second it never seemed to mute the volume, even when I change the value to 0 each tick.

    I was able to get to the AudioComponents and anytime one was played I could stop it, but some sound would still escape before the tick would stop the sound.

    When I was looking through the Engine class to see what exactly getAudioDevice would do, it said that it would return the AudioDevice unless the sound was disabled. Does anyone know how to disable the sound? I looked into the Disable function in the Object class, but no probe functions seem to affect the sound.
     
  20. DannyMeister

    DannyMeister UT3 Jailbreak Coder

    Joined:
    Dec 11, 2002
    Messages:
    1,270
    Likes Received:
    0
    A transient variable should only mean that it is not persisted to disk. Any time you load a new instance of the object, it will be reset to the default value.

    I see that UTGameViewportClient is setting TransientMasterVolume back to 1.0 in PostRender(), maybe that is causing your problem. I don't know how you would override the viewport class though, since it is a globalconfig in Engine.uc. I'd leave that alone. Maybe you need to continue to reset it every tick, but find a better time to do it. If the order of events in the tick is play sound -> volume = 0 -> volume = 1 for instance, then you'll always hear a volume of 1.

    Oh, I just had another idea... here is the test to see whether to set it back to 1.0:
    Code:
    if (Outer.TransitionType != TT_None)
    {
    	AD.TransientMasterVolume = 0.0;
    }
    else if (AD.TransientMasterVolume == 0.0)
    {
    	AD.TransientMasterVolume = 1.0;
    }
    
    So if you set it to 0.001 instead of 0.0, maybe that would make the sound inaudible to the human ear, but check for 0.0 would fail, and it would leave it alone.
     

Share This Page