Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

[OPEN SOURCE] PhysSound Physics Audio System

Discussion in 'Assets and Asset Store' started by Cramonky, Jun 17, 2015.

  1. Cramonky

    Cramonky

    Joined:
    Apr 1, 2013
    Posts:
    186
    This package is now open source (under the MIT license).

    You can grab the unitypackage file off Google Drive.
     
    Last edited: Apr 8, 2019
    djnX, mitaywalle, Iman_col and 3 others like this.
  2. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,087
    And there I was about to create something similar for my current project :)
    So thanks a lot for this. It looks (and sounds) great!
    Just bought it.

    Cheers!
     
  3. Zeblote

    Zeblote

    Joined:
    Feb 8, 2013
    Posts:
    1,102
    Can it do rolling sounds for a ball, getting louder with increasing speed?
     
    Bryarey likes this.
  4. Cramonky

    Cramonky

    Joined:
    Apr 1, 2013
    Posts:
    186
    Yes, it can achieve that effect. However, I will say that under the hood the sound wouldn't actually be based on the angular velocity of the ball. There's currently no distinction in this system between a ball sliding across a surface and a ball rolling across a surface, but both will produce sounds that will get louder with speed.

    This is a feature I have considered adding, but I decided to hold off on adding it until I got the asset approved. (Updates to assets already on the asset store seem to take much less time than submitting a new asset).
     
    Last edited: Jun 18, 2015
    I am da bawss likes this.
  5. DrewMedina

    DrewMedina

    Joined:
    Apr 1, 2013
    Posts:
    418
    Looks great, think it could be tied together with Oculus Rift's 3D audio?
     
  6. Play_Edu

    Play_Edu

    Joined:
    Jun 10, 2012
    Posts:
    722
    Cool one
     
  7. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,649
    Nice. Bookmarked. :cool:
     
  8. Cramonky

    Cramonky

    Joined:
    Apr 1, 2013
    Posts:
    186
    Hey guys,
    First off I want to thank you all for your inspiring words, it really means a lot!

    Secondly I would like to share a little sneak peak of a new feature I am currently working on: Custom Sound Sets (forgive me for the bad looking editor)

    Basically, these act as an override to the default Hard and Soft sound sets, allowing you to define a separate set of sounds for interactions between specific materials. So you can use this if you have a few special cases that you want to play different sounds for, or I guess if you want a very high amount of realism for your sounds :).

    ---
    Edit:
    Well, as I've been implementing this feature I've begun to realize that, with this current system, implementing something like this is way more dirty than I had anticipated. So with that said, a major rewrite of this system may be incoming. I'll keep this thread posted on any updates of course!
     
    Last edited: Jun 19, 2015
  9. DrewMedina

    DrewMedina

    Joined:
    Apr 1, 2013
    Posts:
    418
    Im really enjoying this! How can i make these 3D enabled? They are just as loud far away, unless it should be working...using unity's 3D audio.
     
  10. Cramonky

    Cramonky

    Joined:
    Apr 1, 2013
    Posts:
    186
    Hey HeadTrip,
    You may have to mess with the settings on your AudioSources. Make sure that the 'Spatial Blend' property of your audio source is set to all the way to 3D and not 2D. You may also want to change the falloff curve under 3D sound settings if you are still having issues.
     
  11. DrewMedina

    DrewMedina

    Joined:
    Apr 1, 2013
    Posts:
    418
    Cool thanks, must be a setup issue...will look at it soon.
     
  12. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,649
    BTW, your tool can be a very useful Foot Step Audio engine?.
     
  13. MD_Reptile

    MD_Reptile

    Joined:
    Jan 19, 2012
    Posts:
    2,664
    I'm curious if it uses some sort of procedural sounds or just clips with varied volume/pitch?
     
  14. Cramonky

    Cramonky

    Joined:
    Apr 1, 2013
    Posts:
    186
    It only uses the standard audio clips and audio sources. Basically it uses a collision's velocity to select an audio clip from a list and plays that clip. It also adjusts the volume and pitch of the audio source each time a sound is played to prevent the sounds from being repetitive.

    Well, I suppose it could be with a bit of interesting scripting, but it's not really intended to do that.
     
  15. MD_Reptile

    MD_Reptile

    Joined:
    Jan 19, 2012
    Posts:
    2,664
    Ok, well that seems cool, thanks for the quick response!
     
  16. DrewMedina

    DrewMedina

    Joined:
    Apr 1, 2013
    Posts:
    418
    ahh nice, that did it.. the slider from 2D to 3D. also, adding the 3D audio for the Rift works as well :)

    I am having issues with some physics objects that need to be really slammed against the ground to trigger audio, any suggestions? The player is holding an object and smashing it against the ground... you have to slam really hard to hear it, but then with attempts after you don't need to. It's like it needs to woken up.
    Thanks
     
  17. Cramonky

    Cramonky

    Joined:
    Apr 1, 2013
    Posts:
    186
    Hey,
    That's a bit weird... Maybe try lowering the Min value under Relative Velocity Threshold in your PhysSoundMaterial asset. if that doesn't work then I may need a video or something so I can see exactly what is happening.
     
  18. I am da bawss

    I am da bawss

    Joined:
    Jun 2, 2011
    Posts:
    2,574
    Sounds very interesting (pun not intended :D)!
    Reading from the documentation it seems the system just select from collection of sound clips based on velocity and material right? There seems to be a bit of pitch manipulation thrown in to make it sound more realistic and random.

    This actually reminds me of Jurassic Park Trespasser back in 1998!
    A very little known ground breaking game that's decade too advanced for its own good.
    One of its most impressive feature is what the creator called "Real-Time Foley" system:


    From Wiki:
    "One of the most impressive features of Trespasser is a system dubbed by the creators as "Real-Time Foley". Theoretically, the Trespasser engine could produce the sound of any two objects colliding with one another at any speed or distance by dynamically mixing several sounds together on-the-fly."

    From Gamasutra's Jurassic Park Trespasser Post Mortem:
    "Another major system for Trespasser was its audio system, which we described as "real time Foley" because of its ability to generate collision and scraping effects between differing sound materials in real time. Although the system could have used more sound material data, even with what it had it resulted in some wonderfully immersive sound effects which most other games do not duplicate - things like scraping a board down a concrete surface or hitting an oil barrel with a metal bat sound just about perfect. Since the system doesn’t simply play two sound effects but actually chooses from a group of samples and sets volumes based on the underlying physics collision, it sounds much more natural than most other audio systems currently used."

    http://www.gamasutra.com/view/feature/131746/postmortem_dreamworks_.php?print=1



    I was hoping this is actually procedurally generating the sound in real-time. Perhaps in the future update? :D

    There is a lot of research dedicated and being done in this area, particularly from Cornell University:
    Sound Rendering for Physically Based Simulation
    http://www.cs.cornell.edu/projects/sound/

    The Geometric Algorithms for Modeling, Motion, and Animation (GAMMA) group at the University of North Carolina at Chapel Hill (UNC) also dedicated a lot of their research into this area, they have a dedicated youtube channel:
    https://www.youtube.com/user/gammaunc/videos

    One of the most impressive from GAMMA group:
    Example-guided Physically-based Modal Sound Synthesis



    Another one from a Japanese group:
    Real-time Rendering of Aerodynamic Sound using Sound Textures based on Computational Fluid Dynamics (2003)
    http://nis-ei.eng.hokudai.ac.jp/~doba/papers/aerodynamic_sound.pdf
    http://nis-ei.eng.hokudai.ac.jp/~doba/anime/as/as.html (movies)



    I will definitely pick this up for sure! :)
     
    Last edited: Jun 22, 2015
    Iman_col likes this.
  19. Cramonky

    Cramonky

    Joined:
    Apr 1, 2013
    Posts:
    186
    That is some really interesting stuff! I will admit that my system is definitely not as complex as those other systems, but consider me inspired!

    As far as updates go, I have a pretty cool teaser to show regarding the potential rewrite I mentioned earlier:
    This is the PhysSound Material Type editor. What this will do is allow you to define your own material types, rather than just having the hard-coded Hard and Soft types. You can then set the Material Type in your PhysSoundMaterial to any of the types you defined here, and create the audio sets for each material type. This will provide a lot more versatility and also make the code back-end a lot cleaner!
     
    I am da bawss likes this.
  20. Cramonky

    Cramonky

    Joined:
    Apr 1, 2013
    Posts:
    186
    Hello once again!

    I have posted a couple teasers of PhysSound Version 2, but now I am very proud to announce its release!

    Major Changes:
    1. Completely revamped the major components, especially the PhysSound Materials and Objects.
    2. Added the ability to define your own material types via the Material Type Editor.
    3. Added the ability to add and remove audio sets.
    4. Added a check box to automatically create Audio Sources on your PhysSound Objects based on a template.
    5. Removed the hard-coded Hard and Soft material types and audio sets as they are no longer needed.
    6. Removed the Sound Mode option as it is no longer needed.
    VERY IMPORTANT: Unfortunately updating to this new version WILL cause you to lose some assignments such as the Hard and Soft Impact lists, the Sliding audio clips, and audio sources.

    Here are all of the updated links (The links in the original post are updated as well):

    As always feedback is greatly appreciated and of course post any bugs you find and I will fix them promptly!
     
    I am da bawss likes this.
  21. Cramonky

    Cramonky

    Joined:
    Apr 1, 2013
    Posts:
    186
    Hello all,
    Bumping this thread for an update:

    v2.1.0 Updates:
    1. Added the "Impact Normal Bias" property for PhysSound Materials. Basically this allows you to set how much the angle of an impact should be taken into account when calculating what sound to play (You can check out the Guide & Docs for more info on this).
    2. Changed the PhysSound Material inspector slightly by moving the Material Type Key drop-down to the header of the audio set (See screenshots on asset page).
    3. Added a few error messages that I missed in the last update.
     
    I am da bawss likes this.
  22. I am da bawss

    I am da bawss

    Joined:
    Jun 2, 2011
    Posts:
    2,574
    Very nice! Keep them update coming!
     
  23. I am da bawss

    I am da bawss

    Joined:
    Jun 2, 2011
    Posts:
    2,574
    Reviewed! :)
     
  24. Cramonky

    Cramonky

    Joined:
    Apr 1, 2013
    Posts:
    186
    Thanks!

    As far as updates go, I'm at the point where I can't think of anything else I want to add, so I'm completely open to suggestions for features.
     
  25. adventurefan

    adventurefan

    Joined:
    Jan 17, 2014
    Posts:
    230
    As far as adding features, footstep support would be pretty cool. I'm trying a few other systems but I think you would probably come up with an even better method judging by your work already.

    But for $10 this is a fantastic asset and deal as it is and I'll drop a review later.
     
    unitydevist likes this.
  26. Cramonky

    Cramonky

    Joined:
    Apr 1, 2013
    Posts:
    186
    Hello again,
    It's been nearly 2 months since an update (time flies!), but here is a small one that adds a neat new functionality:

    v2.2.0 Updates:
    1. Added the "Slide Pitch Mod" property, which will adjust the pitch of a sliding sound based on the object's velocity. This value usually should be very small (less than 0.1 in most cases) and works best for rolling objects.
    2. All PhysSound scripts are now contained in the "PhysSound" namespace for cleanliness and organization. So If you need to access those scripts you must import the "PhysSound" namespace.
     
    adventurefan likes this.
  27. Olafson

    Olafson

    Joined:
    Aug 7, 2012
    Posts:
    255
  28. DivergenceOnline

    DivergenceOnline

    Joined:
    Apr 19, 2015
    Posts:
    244
    Would love to integrate this asset into our game but we don't use standard unity sounds; We use SECTR audio cues.
     
  29. plumum

    plumum

    Joined:
    Feb 16, 2016
    Posts:
    2
    Hi, I studying fmod studio and wanted to know more about where our cues come from and how our designs interact with unity. So i was happy to wa tech the basic tutorial about fmod/unity integration and start to get really interested in building a sort of sandbox environment to interact with my soundings. I am really excited about your examples but am wondering if the physic parameters can be linked to fmod event sounds and parameters.
     
  30. Cramonky

    Cramonky

    Joined:
    Apr 1, 2013
    Posts:
    186
    PhysSound in its current form only uses Unity's standard AudioSources and AudioClips. However, the source code is fully available (and somewhat commented, but not officially documented) to you when you purchase the package. So it is entirely possible to modify PhysSound's code to use a 3rd party audio system.
     
  31. Cramonky

    Cramonky

    Joined:
    Apr 1, 2013
    Posts:
    186
    It's update time again! (I'll mention updates from 2.2.1 as well)

    v2.3.0 Updates:
    1. Added the Use PlayClipAtPoint option to PhysSoundObjects. This is useful if you have long impact sounds which should not be cut off when impacts happen in rapid succession.
    2. AudioSource fields will no longer be created for audio sets that don't have a slide audio clip defined.
    3. Added new objects and sounds to the demo.
    4. Fixed the title of the PhysSound Material Type Editor window.
    5. (2.2.1) Added the SetEnabled method to PhysSoundObjects. This will enable/disable both the PhysSoundObject script and any AudioSources that are associated with it, so no code will be run and no sound will be played.
    6. (2.2.1) Made some slight optimizations to PhysSoundObjects.
     
  32. Redrag

    Redrag

    Joined:
    Apr 27, 2014
    Posts:
    179
    Working great but getting this error:

    PhysSound Object Collider 5 has an audio container for an invalid Material Type! Select this object in the hierarchy to update its audio container list.
    UnityEngine.Debug:LogError(Object)
    PhysSound.PhysSoundObject:Start() (at Assets/PhysSound/Scripts/PhysSoundObject.cs:70)

    There is no audio on that object..
     
  33. Cramonky

    Cramonky

    Joined:
    Apr 1, 2013
    Posts:
    186
    Hey,
    I think I have found the source of that error. It happens when I change the PhysSound Material of an object from a material with at least 1 audio set to a material with no audio sets (For example, changing from Plastic to Ground_Hard). I'll submit a fix for that ASAP, but it may take a bit for it to be approved by the asset store.
     
  34. Redrag

    Redrag

    Joined:
    Apr 27, 2014
    Posts:
    179
    Just found an issue on the terrain. On collision exit you send a vector3.zero to physSoundBase. In the case of terrain this causes an error if there is no terrain at 0. I am using multiple tiles and feeding in the correct terrain to your script.

    You may also want to consider adding a collision ignore function based on layers.
     
  35. Cramonky

    Cramonky

    Joined:
    Apr 1, 2013
    Posts:
    186
    I've fixed the error with terrains now, and I also went ahead and added a layer mask function. I'm not sure if the layer mask would be more useful on the object or on the material though.

    I'm also working towards improving how the system functions with large single-collider objects and environments, among some other features.
     
    Last edited: Feb 27, 2016
  36. Redrag

    Redrag

    Joined:
    Apr 27, 2014
    Posts:
    179
    Many thanks for that. Have you uploaded to Asset Store or do you want to send it to me direct to try it out?

    If you are doing an update, have you considered adding support for multiple terrain tiles?
     
  37. Cramonky

    Cramonky

    Joined:
    Apr 1, 2013
    Posts:
    186
    I have not uploaded to the Asset store yet, but I plan on doing that sometime today (pretty sure the review team doesn't work on weekends anyway :p). Also it should work on multiple terrain tiles, it's just that you would have to add a PhysSoundTerrain script to each tile.
     
  38. Deleted User

    Deleted User

    Guest

    Any chance of a basic 'getting started' tutorial ? I'm having some trouble understanding how the audio sources are added, I can't get any sound whatsoever, even after dissecting the demo scene, the documentation is great, but I'd really benefit from a beginners tutorial / video ?


    EDIT : Also, on a side note, I've attached a flick script to one of the objects in the demo scene, and I'm flicking it around the scene, impact sounds play, but no sliding sounds whatsoever, why ?
     
    Last edited by a moderator: Mar 8, 2016
  39. Cramonky

    Cramonky

    Joined:
    Apr 1, 2013
    Posts:
    186
    Hey playmint,

    Would you mind posting screenshots of the PhysSoundMaterial and PhysSoundObject that are giving you trouble? Make sure everything is expanded in the PhysSoundMaterial so I can see all of the properties. There are a lot of potential reasons why sounds won't play.

    I have definitely considered making a tutorial video, but the main problem is that i don't have any decent screen capture software. I'll see what I can do about making a tutorial video.
     
    Deleted User likes this.
  40. Deleted User

    Deleted User

    Guest

    Hi, crazymonkay

    I've delved a bit deeper into the demo scenes, and I think I've figured out what I was doing wrong.

    The thing is, the documentation is fantastic, explains what each thing does perfectly. The only thing I did not know was how to implement it properly into my own scene, for instance, after studying the demo scene, it seems you have to make a prefab of the object you apply the physound object to, that is not documented anywhere that I can see and I wasn't aware it was required, secondly, it seems like you have to create an empty Audiosource component on whatever object you are also making a prefab from, again that is not documented anywhere either, so I stumbled upon that too, I've noticed in some of the objects in the demo scene, there is multiple empty audiosources, and I don't know why ?

    The thing is, right now, I think I'm up and running, but unsure if I'm using everything as it should be used, would definitely be nice to see a very simple, 'here are the basics' quick tutorial, either html / pdf or video, just to be sure I'm using this as it's meant to be used.

    I have collisions being detected now on my own object when I launch it around a scene and impacts can be heard, but audio when the object is sliding is never picked up, and I don't know why ? I'm using for test purposes the plastic physSound material, and my ground plane has a Phys Sound Object with the Ground_Soft material added.
     
    Last edited by a moderator: Mar 8, 2016
  41. Cramonky

    Cramonky

    Joined:
    Apr 1, 2013
    Posts:
    186
    You shouldn't be required to make a prefab out of any of your objects...

    But yes, one way to set up a PhysSoundObject is to manually add an AudioSource component for each Audio field like in this example:

    Another way to do it is to add only 1 AudioSource component to your object, and use the Auto Create Sources option to automatically generate any other required AudioSources:


    And then a third way to do it is to create an empty game object with an AudioSource attached, save that as a prefab, and drag-and-drop that prefab into the Template Audio field.

    I'll agree that the documentation is lacking on this subject. I'll try to add this stuff with the next release which hopefully should be soon.
     
    Deleted User likes this.
  42. Deleted User

    Deleted User

    Guest

    Hi,

    I was just using what I thought was the correct setup from the demo scene, hence the prefab, I take it I can just drag and drop the current object instead into the Template Audio section, actually I've just tried that and it seems to work fine.

    Your second method, 1 Audiosource and Auto Create Sources actually works out better for me, because now my sliding functionality is working now ! :D

    No worries, love the product, already rated it 5 stars.
     
  43. Cramonky

    Cramonky

    Joined:
    Apr 1, 2013
    Posts:
    186
    Well I'm glad everything is working now :).

    As far as updates go, I just submitted a fairly large update with some cool new features and some major improvements, so look forward to that in the coming week(s)
     
    Deleted User likes this.
  44. Cramonky

    Cramonky

    Joined:
    Apr 1, 2013
    Posts:
    186
    Update is published sooner than I expected!

    v2.4.0 Updates:

    • Improved impact detection for objects with concave mesh colliders.
    • Added the Collision Mask property to PhysSound Materials. This allows you to tell the system to only play sounds when colliding with objects on certain layer(s).
    • Added the Slide Vol Mutliplier property to PhysSound Materials. This value basically scales the slide volume based on an object's velocity. Higher values mean the slide sound will be louder at lower velocities, and vice-versa for lower values.
    • Use PlayClipAtPoint has been renamed to Use Temp Audio (Use Temporary Audio).
    • AudioSources created / used by Use Temp Audio are now pooled for increased performance.
    • Renamed the "Material Type Editor" to "PhysSound Settings"
    • Added the "Temp Audio Pool Size" option to the PhysSound Settings window. This is how many AudioSources will be instantiated and available for objects with Use Temp Audio selected to use.
    • Auto Create Sources and Use Temp Audio can now both be selected at the same time.
     
    ilmario and Arganth like this.
  45. plumum

    plumum

    Joined:
    Feb 16, 2016
    Posts:
    2
    Hi Crazymonkey, thanks for the quick reply and sorry for my ultra delayed response. I will certainly buy PhysSound. if only for enjoying the demo. I just browsed through the manual and admire your concept, implementation and interfacing. At the moment I have to focus on mastering Fmod for my exams and there are already a lot of topics to process and skills to learn. I'm looking forward to join the ride and already thank you for this great piece of work.
     
  46. Kanos

    Kanos

    Joined:
    Jun 17, 2015
    Posts:
    15
    Hi,
    First up great product.
    I have an issue where I want to adjust the base volume of all sound effects in my game.
    It appears as though the base impact volume is not publicly accessible. I know it's easy to declare it public and then cycle through the array of physsoundobjects to adjust the base volume of each one, but I don't want to make changes to your source only to have them break the next time you update it.
    In a future release could you allow the base volume of sounds to be adjusted?, or could you make the physsoundobject class extendable?
    If I have missed something in the code, that already allows this could you point it out?
     
    Last edited: Mar 22, 2016
  47. Cramonky

    Cramonky

    Joined:
    Apr 1, 2013
    Posts:
    186
    Hey Kanos,

    If you are looking to be able to adjust the volume of all SFX in your game, I would look into using Audio Mixers rather than modifying each audio source's volume directly. Audio mixers allow you to set up volume control across your entire game for any kind of audio you want like SFX, music, dialog, etc.

    Hope this helps.
     
  48. Kanos

    Kanos

    Joined:
    Jun 17, 2015
    Posts:
    15
    Doh,
    Didn't even consider that. I will look into right aways Thanks!!

    EDIT:
    Had to rewrite a chunk of code, but it worked like a charm.
    PhysSound is awesome!!!
    Thanks again.
     
    Last edited: Mar 22, 2016
  49. Jespionage

    Jespionage

    Joined:
    Aug 28, 2014
    Posts:
    3
    Hi Guys
    Loving this asset so far.
    Any chance you could put the Range struct in the utilities folder into your PhysSound namespace? It has a very general name for usage in the global namespace, and is likely to conflict with other classes or structs. Alternately rename the class to PhysSoundRange if it must be in the global namespace?
    Thanks
    Jesse
     
  50. Cramonky

    Cramonky

    Joined:
    Apr 1, 2013
    Posts:
    186
    Hi all,

    So here is another update:

    v2.5.0 Updates:
    • PhysSound can now detect 'collisions' for objects that use trigger colliders. This is useful if you need to make your rigidbody kinematic (like when you are holding it in your hand) but still want PhysSound sounds to play. Bear in mind that this detection isn't as accurate as regular collisions.
    • Added the Pitch Scale Mod property to PhysSoundMaterials. Basically with this value you can set how much the scale of your object will affect the pitch and volume of an object. Large objects will have louder, lower pitched sounds than normal while smaller objects will have less loud, higher pitched sounds.
    • Moved the Range and FoldoutList classes to the PhysSound namespace.
    Enjoy!
     
    Arganth likes this.