Audio particles? (noob question)

This just popped into my head as I was walking home from the corner store tonight; there’s an empty lot on the way that’s overgrown with plants and full of crickets that sing at night.

As a disclaimer, I don’t currently use Unity (or do any game development), so I’m not sure what its capabilities in this regard are — that’s why I’m asking out of sheer curiosity. I’m half-expecting what I’m describing to be impossible for some reason involving inherent limitations of Unity or real-time game audio in general.

If you wanted to simulate standing or walking in the middle of a field full of chirping crickets, a single sound source would obviously not cut it. While you could use a stereo loop of lots of crickets, that wouldn’t hold up if the player moved, because the crickets’ apparent sound sources wouldn’t move, while the player would expect closer sounds to move more dramatically compared to farther ones.

Using a few mono emitters placed here and there would kind of do it, but not if you wanted a field full of them. So then it occurred to me: the scenario I’m thinking of is (in its end result, at least) a lot like the aural equivalent of a particle system. Lots of temporary sound sources would be instantiated at random locations as defined by an emitter, play their sample, and disappear. Maybe it’s possible to have whole bunches of them rendered together in software to avoid taking up all the available sound channels (like…uh…gluing a group of bread crumbs together into a slice-sized chunk before putting them in your toaster so each crumb doesn’t use a whole slot for itself? lol analogies). I dunno. :lol:

Another, likely wonkier example might be a room with a high, leaky ceiling. Water drips are coming from all over the area of the ceiling, with each drop being a visible particle. Now what if each of those particles played a little spat sound when they hit the floor? (Not necessarily using collision detection — if they’re all falling the same distance, you could just add the right length of silence to the start of the audio sample.)

Anyway, sorry if this idea is so pie-in-the-sky that it doesn’t make any practical sense. I was just curious, is all. :wink:

Nonono, this makes a lot of sense!

I don’t know if you can attach an audio source directly to a particle, but you can definitely spawn a lot of one shot audio effects (hey, can you say the seagull sound in the island demo? that uses randomly spawned audio sources!). This is what you’re thinking of, right?

Give me a little bit to whip up a field fuill of crickets demo. It will work, and probably exactly as you want!

I can certainly imagine it and it sounds cool. Your analogies probably need a bit of work however! :slight_smile:

Dakota’s method seems like it might work.

Create an empty game object
Attach a sound source
give the sound source a sound byte
set to play on wake, no loop, run once
setup a script to destroy the game object after sound byte length + 1 second or so, attach the script to the game object, probably use the fixed update for this part, use yield
test the item in the scene, should play the sound byte one time

create a prefab
attach the ego to the prefab
destroy the object from the scene
now simply use instantiate on the game object with random coordinates

if you have a cricket sound byte that is 2 seconds long and spawn a few of these, you should get your results you desire

Ooh, I just remembered about this thread again. Thanks for the responses! I didn’t have any particular use in mind for myself, it was just a bit of idle speculation.

Instantiating things is expensive, you’d be better off moving around an existing group of sound objects and simply recycling them :slight_smile: