Search Unity

[RELEASED] SECTR AUDIO: Immersive, Spatial Audio

Discussion in 'Assets and Asset Store' started by MakeCodeNow, Feb 21, 2014.

  1. duplexius

    duplexius

    Joined:
    Apr 24, 2015
    Posts:
    43
    Hi, I'm using SECTR Audio for a year now and have a question regarding the Prefabs under Advanced Properties, as there is no example for this.
    I would like to add a reverb filter to a specific audio cue. I can only create a prefab with a Unity Audio Reverb Filter if it also has a Unity Audio Source. Is it OK to just add a default Audio source in there? I assume the properties of the Audio Source will be overwritten by the cue properties?

    Thanks in advance for your response!
     
  2. MakeCodeNow

    MakeCodeNow

    Joined:
    Feb 14, 2014
    Posts:
    1,246
    That's exactly right!
     
  3. duplexius

    duplexius

    Joined:
    Apr 24, 2015
    Posts:
    43
    Thanks and Merry Christmas! :)
     
  4. GarretPolk

    GarretPolk

    Joined:
    May 26, 2013
    Posts:
    49
    Is there a way to play a clip starting at a particular position? Specifically I'm trying to start an environmental sound at a random position so it sounds less fake (wind).

    Thanks!
     
  5. MakeCodeNow

    MakeCodeNow

    Joined:
    Feb 14, 2014
    Posts:
    1,246
    Right now there is not, but I will look into adding that.
     
  6. electroflame

    electroflame

    Joined:
    May 7, 2014
    Posts:
    177
    I've been working on integrating SECTR Audio for the past week, and it's been going great. However, I've now hit a roadblock that I think requires some help, as I can't figure it out for the life of me.

    Basically, I need to edit AudioEffect values at runtime (LowPass, currently). I understand that you have to make a "dummy" prefab with the effect you need on it and hook it up, but I'm unclear on where to go from there. Originally, I thought it was supposed to be done via ControlParams, but not only does that throw some null reference errors (around componentType being null) but it also looks like SetParameter uses Reflection, which is not great. Ideally, I'd like to get a reference to the playing instance's component (or GameObject, so I can use GetComponent on it) directly, so I can grab the values from that -- but it doesn't look like there's anything set up to do that right now.

    Additionally, no matter what I do the AudioCueInstance that's returned to me always goes "dead" within a few frames. I stepped through it for a while and couldn't figure out what was wrong, so maybe you have some pointers? It's a one-shot, non-looping, 2D sound being played at the same position as the AudioListener, so it's not a Range issue (even while stepping through, it wasn't being automatically culled). It's fairly long, which is why I need the AudioCueInstance to stay alive for the duration so I can manipulate it. Is there anything special I need to do to store AudioCueInstances?

    I've been trying various things for the last day or so but I can't seem to figure these two (separate, but possibly related?) issues out.

    Any ideas, @MakeCodeNow?
     
    Last edited: Feb 3, 2017
  7. electroflame

    electroflame

    Joined:
    May 7, 2014
    Posts:
    177
    Alright, so, I've made some progress. Good news first: it looks like I've managed to solve my AudioCueInstance issue. I'm not sure what the root cause for it was, delaying the initial (i.e. first time it's played/accessed) AudioCueInstance cache seems to have solved it. I still lose the AudioCueInstance when the Editor is Paused and then later Resumed, so I'm not sure if that's normal. At least I'm not losing the references immediately when the game is started.

    As for the original issue I had with the AudioEffects, I haven't found a solution. I'm still getting null reference errors around componentType being null (which seems like it should be set in the Editor and stored, if I'm reading the source correctly) so something's going on there.

    However, I really think it'd be beneficial for the AudioCueInstances to auto-map the common Unity AudioEffects (i.e. have a stored field for each AudioEffect component, that's either null if there's no component attached to it, or points to the stored component. It'd be much easier than ControlParams, wouldn't require Reflection, and would give you direct access to the actual AudioEffect component that's being applied to the internal AudioSource.

    Any thoughts, @MakeCodeNow? The AudioEffect thing has really got me stumped.
     
  8. MakeCodeNow

    MakeCodeNow

    Joined:
    Feb 14, 2014
    Posts:
    1,246
    Hey, sorry for the slow reply. I think you're on the right track. A few things...

    AudioCueInstances are weak references, so they can go null at any time, like if a sound is done playing or if the internal pool is empty.

    Regarding AudioEffects, the prefab + control param is intended to be the right solution. If you can email a sample project w/ a repro to support@makecodenow.com, I'll take a look.

    Also, you can add some plumbing to AudioCueInstance that lets you get at the internal AudioSource or GameObject if you like. I don't do that by default because it can be dangerous for users who don't know what they are doing, but for you it should be fine.

    Lastly, I thought about wrapping all of the Unity components but it's just an awful lot of boilerplate code and Unity changes those classes fairly often, so it's just a lot to write and maintain for a feature that not that many people use, hence the current state of things.
     
  9. electroflame

    electroflame

    Joined:
    May 7, 2014
    Posts:
    177
    Thanks for getting back to me. I'll have to take some time to strip out a repro project for the null references errors, but while I do that I figured I could respond to this.

    That makes sense. Is there any particular reason (or, I guess, is it normal) for audio to be dropped/not resume when the editor is paused? I don't think this is inherently a WeakReference thing -- if anything, it's more likely a struct problem with AudioCueInstances (since Unity doesn't really serialize the structs). It's actually really annoying to pause for debugging, but then lose all playing audio when the editor resumes.

    I'll see what I can do about this.

    I've been debating this for the past week. If possible, I really try to avoid directly editing the source of the few Asset Store assets I use, as any time I need to update I have to go and untangle and diff the changes, which turns into a huge headache.

    I was thinking that it'd actually be really nice if SECTR AUDIO's private methods/field/classes were marked protected by default, as then anyone (like me) who is using this as more of a foundation can derive and build on top of it, without having to resort to modifying the source files.

    I wasn't talking about wrapping all of the public fields of all of the components, but rather providing a single, public field for each component type that returns a reference to that actual component (or null, if there is no component to return, obviously). As far as I can tell, things haven't really changed that much from Unity 4.0.0 (the earliest version you're supporting). According to the Unity 4 documentation, the same basic AudioFilters are available (I was calling them AudioEffects before, but I actually meant AudioFilters). The current docs specify the same AudioFilters.

    I suspect the only major problem would be supporting the 4.x versions with the whole Free/Pro split, but you already handle that pretty well with the code that's there already. I'm not trying to be pushy and demand it's implemented or anything like that, but I wasn't sure if my initial explanation was confusing.

    As I think about it more, almost all of this could be solved on my end with the private-to-protected switch I mentioned earlier, as I could derive and implement all of this specific-use-case stuff that likely doesn't come up often enough for you to implement yourself. I don't know if that's something you'd consider, but it'd certainly make things more modification-friendly for the people (like me) who aren't afraid to dig in and start making adjustments, but don't want to modify the core itself.
     
    Last edited: Feb 4, 2017
  10. MakeCodeNow

    MakeCodeNow

    Joined:
    Feb 14, 2014
    Posts:
    1,246
    I'm not sure about the pause/resume behavior. Unity can do some funky stuff when editor pauses and resumes, so I'm guessing it's related to that. Do you see this only when setting breakpoints or even when you press the pause button (I assume it's the former)?

    I'll consider the private to protected thing, but it's really not designed to be derived from and I'd have to think through all of the ways it could break or be confusing. I think the much simpler change is to just add a GetAudioSource() function to AudioCueInstance interface and the couple of related subclasses and then you can have your way with it.
     
  11. electroflame

    electroflame

    Joined:
    May 7, 2014
    Posts:
    177
    It's actually any time the editor is paused and resumed. Breakpoints make it happen as well, but it happens even when a debugger isn't attached and you just pause the editor. This is Unity 5.5, by the way. I'm not sure about earlier versions.

    It's definitely interesting, as it shouldn't be due to the references being garbage collected or anything (as I'm still holding on to a reference to their AudioCueInstance) so the only thing I can surmise is that it's due to the usage of structs internally and the fact they aren't being serialized/deserialized properly, although I'd have to do some investigation to be sure. (Although, I use some structs for my own stuff and it persists, so now I'm actually not sure about my theory...)

    A method akin to GetInternalInstance that returns the AudioSource would be amazing, actually. Direct access to the underlying AudioSource would allow for GetComponent calls for the Audio Filters, and easy access to everything else (GameObject, Transform, etc.) from there. It would also be type-safe, unlike the current parameter implementation that relies on naked strings for the parameter names.

    I think that that would likely fulfill all of my current implementation needs, and would be significantly easier (and safer) for you than the private to protected conversion. I mean, making everything protected would be great for any heavy-duty modifications, but I fully understand your point of view on it, and why you're reluctant to do it. The GetAudioSource() method sounds like a fantastic compromise.

    EDIT: Aha! 15 minutes of debugging later (and several Unity Editor crashes later...) I've found the solution to the Pause/Resume issue! It actually isn't related to serialization at all (phew!) instead, it's a bug in SECTR_AudioSystem's Instance.Active implementation. Specifically, this:
    Code (CSharp):
    1. return (Loops || Delayed || (source && (source.isPlaying || Paused))) && !FadingOut;
    The problem here is that source.isPlaying will return false when the Editor is paused (because the AudioSource is paused automatically) even though the source isn't actually done playing. My quick patch instead checks if we're in the editor, and if we are we'll always return true (i.e. keep all instances Active) while we're paused. The modified get accessor looks like this:
    Code (CSharp):
    1.             get
    2.             {
    3. #if UNITY_EDITOR
    4.                 if(!EditorApplication.isPaused)
    5.                 {
    6. #endif
    7.                     // Looping sounds are always active, as are playing and paused sounds,
    8.                     // except when fading out (i.e. stop has been called) at which point they
    9.                     // are logically complete.
    10.                     return (Loops || Delayed || (source && (source.isPlaying || Paused))) && !FadingOut;
    11. #if UNITY_EDITOR
    12.                 }
    13.                 else
    14.                 {
    15.                     //Since the editor is paused, we can't reliably check whether a clip is active, so we'll return true until the game is resumed.
    16.                     return true;
    17.                 }
    18. #endif
    19.             }
    That might not be the best way, but as a quick test it absolutely solves the problem. I'm pretty pleased that the issue was something so minor (took some time to track down, though!). You're welcome to take the code if you want -- I'm not sure if there's a better way (but, hey, it was a very quick patch :)), but for a band-aid patch it'll stop the cues from going dead prematurely.
     
    Last edited: Feb 5, 2017
    Akshara and hopeful like this.
  12. MakeCodeNow

    MakeCodeNow

    Joined:
    Feb 14, 2014
    Posts:
    1,246
    Thanks for taking the time to debug that. I just patched in your fix and also added a GetInternalAudioSource() method to the CueInstance interface. That'll be available in the next version which I'll hopefully push out tonight.

    If you get a repro of the param/prefab issue you ran into, I'll be happy to take a look at that, too.
     
  13. electroflame

    electroflame

    Joined:
    May 7, 2014
    Posts:
    177
    Sounds great, thanks! If the Asset Store's going to take a little bit, any chance I can get a copy early when it's ready? (You'll have my email after I send the repro case here shortly)

    This actually might be a larger problem than I thought, as it was easier to reproduce than I was expecting. To make my repro case I just loaded SECTR AUDIO in a brand new, clean project and modified the MusicHDR cue to have a low pass parameter on it. Reproduces it nicely.

    Interestingly, (and I didn't see this before, since I load my AudioManager that has SECTR on it on-the-fly) these errors continue after quitting playmode, as long as the SECTR_AudioSystem is in the scene. Since this was a blank project I didn't have my usual debugging tools in there, so I'm sorry I can't be more helpful. I'm zipping it up and sending it to you once this is posted. Hopefully it helps!
     
    Last edited: Feb 5, 2017
  14. Parallaxe

    Parallaxe

    Joined:
    Apr 9, 2013
    Posts:
    118
    I have a tiny little question on a feature that is driving me crazy (;

    How can I stop playback of the preview? When I click on the icon next to a clip, it starts playing (good!). But then I don't know how to stop it. Clicking again on the playback/preview icon just starts the playback from the beginning.

    Other than that, I'm still very pleased about SECTR Audio. So it's really only a tiny little question.
     
  15. MakeCodeNow

    MakeCodeNow

    Joined:
    Feb 14, 2014
    Posts:
    1,246
    Good question. The best solution is to just preview play another, very short sound. I'll look at updating the UI with a stop option :)
     
  16. Shturmovik

    Shturmovik

    Joined:
    Nov 5, 2014
    Posts:
    22
    It there an easy way to hook this up with Unity's own audio mixer groups? I've been trying to locate an answer in the docs, but haven't really been able to find anything on the subject.
     
  17. MakeCodeNow

    MakeCodeNow

    Joined:
    Feb 14, 2014
    Posts:
    1,246
    SECTR has it's own bussing system and isn't designed to work with the built in unity one.
     
  18. Shturmovik

    Shturmovik

    Joined:
    Nov 5, 2014
    Posts:
    22
    No problem. Was just trying to make a plan for integrating it with my existing setup, and I can work around this quite easily. Just now starting to use it in an actual project after picking it up in a sale some time ago, and really like working with it so far, along with the rest of SECTR COMPLETE. All thumbs up!
     
  19. MakeCodeNow

    MakeCodeNow

    Joined:
    Feb 14, 2014
    Posts:
    1,246
    Ok. Cool. Glad it's working well for you!
     
  20. radiantboy

    radiantboy

    Joined:
    Nov 21, 2012
    Posts:
    845
    I have just got some headphones to really focus on sound, I have noticed when I turn my player it moves the sound from one ear to the other, this is really cool but it feels kind of odd because it seems like it will play through one but not the other if you are standing with that ear facing the sound, but in reality you would still hear it through the other ear just not as loud. Is there any setting to adjust this, so I can still hear it in the other ear but note quite as loud?
     
  21. MakeCodeNow

    MakeCodeNow

    Joined:
    Feb 14, 2014
    Posts:
    1,246
    What you are hearing is called "stereo panning" and you're right that it's a very general approximation to the way sound works in the real world. The correct solution is to render the audio using an HRTF, which requires a plugin like Google's Spatial Audio SDK, Two Big Ears, Impulsonic/Steam, etc.

    In SECTR AUDIO there is a very basic approximation of this effect called NearBlendRange. This feature will take sounds that are within a certain distance of the microphone and blend them from 3D to 2D. It's also a pretty big hack, but it can make things sound just a touch less artificial.
     
  22. jeromeWork

    jeromeWork

    Joined:
    Sep 1, 2015
    Posts:
    279
    Slowly getting up to speed with SECTR Audio. I understand that to change music I just need to call:
    SECTR_AudioSystem.PlayMusic();
    But is it possible to crossfade between music tracks ?
     
  23. MakeCodeNow

    MakeCodeNow

    Joined:
    Feb 14, 2014
    Posts:
    1,246
    It will automatically Crossfade if you set the same fade in and fade out times for the two cues.
     
  24. jeromeWork

    jeromeWork

    Joined:
    Sep 1, 2015
    Posts:
    279
    Oh I get it ! Thanks for the prompt reply. As I say, I'm just getting my head around it all. It's taken me a while to appreciate the power behind those AudioCues :)

    Now that I'm looking at their Properties panel, I'm trying to find some info on the 'Control Parameters' - Add Parameter only seems to add one type of parameter (distance) is this being left open for other parameters in an update, or for user customization? If the latter, what kind of thing might you use it for?
     
  25. MakeCodeNow

    MakeCodeNow

    Joined:
    Feb 14, 2014
    Posts:
    1,246
    This is a super advanced feature but when you combine it with prefabs you can create cues with custom effects and control the effects attributes via parameters.
     
  26. PeterB

    PeterB

    Joined:
    Nov 3, 2010
    Posts:
    341
    Is the manual publicly available?
     
  27. MakeCodeNow

    MakeCodeNow

    Joined:
    Feb 14, 2014
    Posts:
    1,246
    PeterB likes this.
  28. Ali-Nagori

    Ali-Nagori

    Joined:
    Apr 9, 2010
    Posts:
    138
    Hi @MakeCodeNow in SECTR Audio the Falloff of the sound is identical to the linear mode.
    i started noticed that after the late updates, it was fine before that.
     
  29. MakeCodeNow

    MakeCodeNow

    Joined:
    Feb 14, 2014
    Posts:
    1,246
    Hi. You're saying that linear and log falloff sound the same to you and you think this broke in a recent update? If so, are you using hdr sounds?
     
  30. Ali-Nagori

    Ali-Nagori

    Joined:
    Apr 9, 2010
    Posts:
    138
    i'm failing to notice the Difference by myself
    for that i upload one of the clips i have issues with

    for now i had set the fading and out to 0.5 to make it bit seamless.
     

    Attached Files:

  31. MakeCodeNow

    MakeCodeNow

    Joined:
    Feb 14, 2014
    Posts:
    1,246
    I'm sorry but I'm a bit confused. Are you hearing an issue with the falloff (e.g. change in involve based on distance) or the fade in/out behavior?
     
  32. Ali-Nagori

    Ali-Nagori

    Joined:
    Apr 9, 2010
    Posts:
    138
    the fade in/out is the workaround

    yes the issue is about Distance.
    but the issue is distance trigger logarithmic falloff is almost identical to the linear [not seamless the log falloff should sound].
     
  33. MakeCodeNow

    MakeCodeNow

    Joined:
    Feb 14, 2014
    Posts:
    1,246
    I just checked the source and unless you are using HDR sounds Linear and Log are behaving exactly the same in SECTR as they do with regular Unity audio sources. Is it possible that a Unity upgrade is what introduced this issue and not a SECTR upgrade?
     
  34. Ali-Nagori

    Ali-Nagori

    Joined:
    Apr 9, 2010
    Posts:
    138
    the project is using the Last Build of 5.6 , not planning to migrate the project to 2017 version.
    i'm not using the HDR it's unchecked in the Inspector menu of the Templates the cue is used in
     
  35. MoribitoMT

    MoribitoMT

    Joined:
    Jun 1, 2013
    Posts:
    294
    Hi,

    I need to create sound manager for my game to handle all sounds, like background music, item collection musics, GUI buttons, etc.. sounds, etc.. not very much environment dependent musics.

    I have already Sectr Audio purchased, is this the right choice for me for my purposes ? Or should I check other assets ?
     
  36. MakeCodeNow

    MakeCodeNow

    Joined:
    Feb 14, 2014
    Posts:
    1,246
    SECTR audio should work great for that.
     
    MoribitoMT likes this.
  37. Shturmovik

    Shturmovik

    Joined:
    Nov 5, 2014
    Posts:
    22
    Hi,

    Just updated to Unity 2017.3.0 and now getting errors when trying to create a build. This has been present as a deprecation warning for a while:

    Assets/SECTR/Code/Core/Scripts/SECTR_Member.cs(112,79): error CS1061: Type `UnityEngine.Light' does not contain a definition for `isBaked' and no extension method `isBaked' of type `UnityEngine.Light' could be found. Are you missing an assembly reference?
     
  38. MakeCodeNow

    MakeCodeNow

    Joined:
    Feb 14, 2014
    Posts:
    1,246
    Yes, I'll have a fix for that in the new year. If you want to work around it yourself I posted some code in the SECTR complete forums.
     
  39. radiantboy

    radiantboy

    Joined:
    Nov 21, 2012
    Posts:
    845
    The spheres have vanished from around my sectr point sources, how do I get it back ?
     
  40. MakeCodeNow

    MakeCodeNow

    Joined:
    Feb 14, 2014
    Posts:
    1,246
    Expand the audio source component and select the object. When the component is collapsed in the inspector it disables the Gizmo rendering.
     
  41. ToyBrain101

    ToyBrain101

    Joined:
    Sep 15, 2014
    Posts:
    13
    Can you please explain how player Audio works?
     
  42. MakeCodeNow

    MakeCodeNow

    Joined:
    Feb 14, 2014
    Posts:
    1,246
    The dev site for SECTR AUDIO has videos and links to the documentation that should give you the insight you need. If you have any more specific questions, please post them here and I'll answer them.
     
  43. Makingames

    Makingames

    Joined:
    Jul 13, 2012
    Posts:
    13
    Hi, I can't seem to get the Sectr Audio window to preview the audio clips. The unity editor itself is playing them fine however. Is there a setting or something I need to do to get it working?
     
  44. Makingames

    Makingames

    Joined:
    Jul 13, 2012
    Posts:
    13
    Actually, I just figured it out. You need an active object with an Audio System component, with the proper Audio Bus assigned. I didn't realize that was necessary for the preview window.
     
  45. MakeCodeNow

    MakeCodeNow

    Joined:
    Feb 14, 2014
    Posts:
    1,246
    Yeah. That's right. Glad you figured it out.
     
  46. duplexius

    duplexius

    Joined:
    Apr 24, 2015
    Posts:
    43
    Hey, I just upgraded our new project to Unity 2017.3 and got the error "Cannot play sounds before SECTR_AudioSystem is initialized." on a number of looping world sounds which are played automatically upon Start().

    Here's what happened:

    The private variable bool playedFromStart is somehow stored as true and that's why the autoplay is attempted in the first OnEnable already, which can be before the OnEnable of SECTR_AudioSystem.
    This is caused by the [ExecuteInEditMode] tag on the SECTR_PointSource.
     
  47. MoribitoMT

    MoribitoMT

    Joined:
    Jun 1, 2013
    Posts:
    294
    Hi,

    I have a AudioCue with 4-5 tracks in it to shuffle, I have an event that whenever HOME menu opens, calls the SECTR_AudioSystem.playMusic( ... ). However everytime HOME menu opens track changes.

    I want to keep the track already playing unless I did not stop the music previously. I check the methods such as isAudtioning() not worked for me I just look for such a method "isPlaying" something else etc... and not fire the SECTR_AudioSystem.playMusic( ... ), if it is already playing music.

    Regards.
     
  48. MakeCodeNow

    MakeCodeNow

    Joined:
    Feb 14, 2014
    Posts:
    1,246
    I think that's a bug in Unity. It should reset/recreate objects when you go into play mode. Have you filed a bug when them? Seems especially likely since for you this just started happening when you changed versions.
     
  49. MakeCodeNow

    MakeCodeNow

    Joined:
    Feb 14, 2014
    Posts:
    1,246
    It sounds like you should add an IsMusicPlaying() function to SECTR_AudioSystem, which would basically just return the results of musicLoop.Active.
     
  50. MakeCodeNow

    MakeCodeNow

    Joined:
    Feb 14, 2014
    Posts:
    1,246
    Hi, everyone. I wanted to share some very good news - SECTR is joining the Procedural Worlds family of products and is now a sibling to great packages like Gaia and Pegasus. Adam and his team at Procedural Worlds are have some very cool ideas about how to evolve things like Gaia and SECTR together.

    For my part, I'll still be active here, providing support and answering questions until the Procedural Worlds team is fully up to speed on SECTR.
     
    AdamGoodrich likes this.