Atlas for sounds.... this maybe be rare...

Hi!..

i’m sure all of you know atlas textures, what about atlas sounds?..for instance, a sound file containing 5 different sounds, from timeline 0 to timeline 10 is the first sound, from 20 to 30 is second sound… this will help a lot while you have too much same type audio clips…

i haven´t see this yet, maybe this is already integrated in Unity… ?

The reason for the texture atlas has to do with how the rendering pipeline works, I don’t know enough about sound to know if it would be of much help.

I don’t think you can play different parts of an audio clip at the same time so you’d end up with multiple instances of the same audio clip anyway.

thanks both for answering,

yeah of course spinaljack, i forgot to mention that the atlas sound contains only one type of sound but in various pitch, tones, speed, etc.

for instance:

file <hit.ogg> :
timeline 0 to 10 : weakPunchFx
timeline 15 to 25 : mediumPunchFx
timeline 30 to 40 : hardPunchFx

it could serve when you are using a hit effect,

if (Input.GetButtonDown("punch")){
     gameObject.audio.Play(0,10);
     }
else if (Input.GetButtonDown("punch2")){
     gameObject.audio.Play(15,25);
     }
}

or even randomize (let´s say there are 4 clips inside the hit.ogg):

var randomSoundClip = Random.Range(0, 3);
if (randomSoundClip == 0){
     gameObject.audio.Play(0,10);
     }
else if (randomSoundClip == 1){
     gameObject.audio.Play(15,25);
     }
//and so..

note that obviously the audio.Play’s argument is wrong :stuck_out_tongue:
maybe controlling the sound timeline like if we were controlling animation…

There’s no performance benefit to atlas sounds. The only reason texture atlas exists is because there is a performance benefit.

1 Like

Please excuse my ignorance, but what would be the advantage of that kind of set up? From what I can see, it would introduce a lot of disadvantages with no clear advantages apart from having to handle less individual files.

Say hypothetically you slightly alter “punch” and it is now 0,11 instead of 0,10. Then you would have to go, change those hard coded values - and go through your code and ensure that all other hard-coded values which appear later in the file are also updated to reflect accurate positions on the timeline.

Texture atlas offer clear and significant performance gains as a tradeoff for the annoyance of having to create and manage atlases - I can’t imagine the same would be true for the audio.

not sure about perf, but a setup composed of raw wave, like sine square tri with real time filter and oscillator will give you an infinite amount of possibilities to make some sfx eventually, but as long you use a sample for it original sound it certainly better tp keep them separated to.

using only pitch stuff wont get you really far on making sound Xd

I was searching for a solution all day long but found nothing, neither paid nor free solution. Here are some obvious benefits of such audio sprite:

  1. the time required to load 20 small audio clips vs 1 single file is noticeable

  2. the longer the audio, the better you can compress it.

Years ago I was using audiosprite from nodejs to create an audio sprite (the plugin itself was using ffmpeg tool via command line). As I recall, I was getting single audio file along with json file with track information. If there is any app with user friendly UI to create audio + josn, the code part should be very simple. If I end up creating my own simple plugin, I will update the thread.