SoundClips - a sound handler that carves multiple sounds out of one

Hi, I have made a very simple module that essentially just plays and stops sounds at specific timestamps, allowing you to virtually carve multiple sounds out of one sound object. It behaves similarly to a texture map, where all textures are clustered up into one image. This is basically the same thing but with sounds instead.

Usage

The usage is very simple, the module returns a constructor function to create a “family” of clips, under the same sound. It takes in the sound object itself and an array of timestamps. The structure of each clip’s timestamps is "start-end", so if your clip started 1.5 seconds and ended at 3.6, it would look like "1.5-3.6" The constructor function will return a table of clips, indexed by their respective timestamps. The clips have one basic function, Clip:Play(). It will simply play the

Here is some sample code:

local newFamily = require(SoundClips)

local timestamps = {
	"1.35-4";
	"2-3.5";
}

local clips = newFamily(SoundId, timestamps)

clips["2-3.5"]:Play()

wait(5)

clips["1.35-4"]:Play()

Notes

  • You can play as many clips as you want at once

  • Treat the numbers in the timestamps as you would treat numbers in tonumber(), this means that you can do a little bit of fiddling with the numbers to make them look cleaner. However; the clips must be indexed the exact same way you wrote the timestamp; i.e. if you wrote your timestamp as "1 - 2", you must index it as "1 - 2".

  • Please feel free to suggest any features.

Thank you for reading and I hope my script serves you well!

6 Likes

image

Is this a typo?

I feel like the only reason I would use this is if I could play multiple clips simultaneously as one could combine all of their audio into one large file to mitigate the upload limit and split it using this.

1 Like
  1. No, its not a typo, I made it like that to showcase that you can have it one way or the other

  2. That’s a good point and I didn’t really think of that while making it. I will add it in right now, thank you for that!

Edit: I just realized, its actually a typo ignore that

1 Like

I have edited the script so that it is now possible to play as many clips as you want at once, even if they are of the same family. Thank you again for this!

1 Like

This is extremely useful, I need to import a lot of small sounds but dont want to upload each one of them. You saved me from a lot of pain :+1: