TEsound - simple, easy sound/music manager

Showcase your libraries, tools and other projects that help your fellow love users.

Awesome?

Yes! Thank you!
54
75%
Yes, but I don't need it.
16
22%
No. (Please tell me why)
2
3%
 
Total votes: 72

User avatar
Taehl
Dreaming in associative arrays
Posts: 1025
Joined: Mon Jan 11, 2010 5:07 am
Location: CA, USA
Contact:

TEsound - simple, easy sound/music manager

Post by Taehl »

Tired of not being able to overlap sounds in Love? Or maybe you just can't figure out the love.audio module? Ensayia and I wrote this module to make sound and music easy.

Mini-tutorial!

Q) What do I have to do to use it?
1) Put TEsound.lua in your game's folder.
2) At the top of main.lua, add require"TEsound".
3) In love.update(), add TEsound.cleanup(). That's it! TEsound will automatically manage sound channels (sounds can overlap) and memory.

Q) How do I just play a sound?
A) All you need to do is TEsound.play(filepath), where filepath is a string like "sounds/boom.ogg".

Q) I have three different jump sounds, how can I play one at random?
A) TEsound.play(list), where list is a table like {"jump1.ogg", "jump2.ogg", "jump3.ogg"}

Q) Can I make it constantly play randomized music?
A) Sure! TEsound.playLooping(list). When one song ends, a new one from the list will automatically start playing.

Q) Now how do I stop the music? / What are sound tags?
A) The best way is to use TEsound's "tagging" feature. Simply put, TEsound lets you add one or more tags to each sound that's playing, and you can call various functions on all sounds with a given tag. So you could do this:
TEsound.playLooping("song1.ogg", "music")
TEsound.stop("music")
Sounds can have multiple tags if you desire (use a list: TEsound.play(sound, {"something", "whatever", "lol"}), and multiple sounds can share tags (if you call something like TEsound.pitch("sfx", .5), all sounds with the "sfx" tag will immediately be low-pitched). Tags can also be unique, in case you want to work with a specific sound.

Q) What if I want to change the volume/pitch of all sounds?
A) That's what the special "all" tag is for. You don't need to give the tag to sounds, it's automatically applied to them. So if you wanted to cut the volume of everything in half, you just need to TEsound.tagVolume("all",.5).

Q) I want to let the player choose different volume levels for sound effects, music, and voice-acting. Can TEsound handle it?
A) Yep! You can set a volume multiplier for any tag with TEsound.tagVolume(tag, volume). Tag-volume changes take immediate effect (even on sounds that are already playing!). So you could use TEsound.tagVolume("voice", .75), and any sound with the "voice" tag would play at .75 volume. This is multiplied by the sound's own volume and what the "all" tag is set to - if you TEsound.play("splat.ogg", "sfx", .5), and you've set the "sfx" and "all" tags to .6 and 1 volume, then the sound would play at .3 volume.

Q) How do I pronounce the name of your module? "Tee ee sound"?
A) That works, but I, personally, say "teh sound" ;)

Q) Anything else I should know?
A) Each function has several more optional parameters - I've just covered the basics here. Check out the documentation for a full list of functions and their parameters.

Ready for sound and music to finally be easy to use? Download the module, and check out the wiki page for more documentation.

EDIT) Updated it slightly - I streamlined it by merging playRandom into play, and playRandomLooping into playLooping (just pass them a list instead of a single filepath). Updated documentation accordingly.
EDIT2) Updated it slightly again - make pitch work identically to volume, and added special "all" tag functionality. Updated documentation accordingly.
Last edited by Taehl on Fri Jan 14, 2011 2:43 am, edited 4 times in total.
Earliest Love2D supporter who can't Love anymore. Let me disable pixel shaders if I don't use them, dammit!
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
User avatar
nevon
Commander of the Circuloids
Posts: 938
Joined: Thu Feb 14, 2008 8:25 pm
Location: Stockholm, Sweden
Contact:

Re: TEsound - simple, easy sound/music manager

Post by nevon »

This seems rather useful. So far I've gotten by with a fairly rudimentary sound manager, but this definitely seems more versatile. What license is it being released under?
User avatar
Lap
Party member
Posts: 256
Joined: Fri Apr 30, 2010 3:46 pm

Re: TEsound - simple, easy sound/music manager

Post by Lap »

Another win for procrastination! I kept putting off making something to manage the looping music and sound effects....glad I did.
User avatar
Taehl
Dreaming in associative arrays
Posts: 1025
Joined: Mon Jan 11, 2010 5:07 am
Location: CA, USA
Contact:

Re: TEsound - simple, easy sound/music manager

Post by Taehl »

License? Feh, I don't know. Guess it'll be zlib, like Love itself. But if your game ends up making a lot of money, maybe you could please consider sending a little bit of it my way? ;)

EDIT) Clarified wording.
Last edited by Taehl on Sun Jan 09, 2011 4:45 pm, edited 1 time in total.
Earliest Love2D supporter who can't Love anymore. Let me disable pixel shaders if I don't use them, dammit!
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
User avatar
nevon
Commander of the Circuloids
Posts: 938
Joined: Thu Feb 14, 2008 8:25 pm
Location: Stockholm, Sweden
Contact:

Re: TEsound - simple, easy sound/music manager

Post by nevon »

Liberal licensing makes my heart smile. :nyu:
User avatar
Taehl
Dreaming in associative arrays
Posts: 1025
Joined: Mon Jan 11, 2010 5:07 am
Location: CA, USA
Contact:

Re: TEsound - simple, easy sound/music manager

Post by Taehl »

I'm glad. So, I guess with that out of the way, this thread can be used for bug reports (hah, unlikely!), feature requests / suggestions for improvement, questions about usage, and so forth. Or, hey, if everything just works (hopefully the case), I won't say no to praise. :P
Earliest Love2D supporter who can't Love anymore. Let me disable pixel shaders if I don't use them, dammit!
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: TEsound - simple, easy sound/music manager

Post by Robin »

Taehl wrote:License? Feh, I don't know. Guess it'll be zlib, like Love itself.
Excellent choice.
Taehl wrote:Maybe with the added condition that if you use it for a game that ends up making a lot of money, I ask you to consider sending a little bit of it my way. ;)
Please don't do that. Put it somewhere apart from the license, it could confuse people to no end.
Help us help you: attach a .love.
User avatar
Taehl
Dreaming in associative arrays
Posts: 1025
Joined: Mon Jan 11, 2010 5:07 am
Location: CA, USA
Contact:

Re: TEsound - simple, easy sound/music manager

Post by Taehl »

Fine, fine. It was mostly a joke.
Earliest Love2D supporter who can't Love anymore. Let me disable pixel shaders if I don't use them, dammit!
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
User avatar
Taehl
Dreaming in associative arrays
Posts: 1025
Joined: Mon Jan 11, 2010 5:07 am
Location: CA, USA
Contact:

Re: TEsound - simple, easy sound/music manager

Post by Taehl »

Small update: I've made pitch-changing work exactly like volume-changing, hence two new functions: TEsound.tagPitch and TEsound.findPitch. I've also added a special "all" tag which automatically works on all sounds (they don't need to be assigned the tag) in ADDITION to their own volume/pitch and tag volume/pitch (if any). In other words, the volume/pitch a sound plays at is (sound's level * set tag * "all" tag). So basically, changing the "all" tag is a master volume/pitch control (using TEsound.tagVolume("all",.5) will halve the volume of all sounds, for example).
Earliest Love2D supporter who can't Love anymore. Let me disable pixel shaders if I don't use them, dammit!
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
User avatar
TechnoCat
Inner party member
Posts: 1611
Joined: Thu Jul 30, 2009 12:31 am
Location: Milwaukee, WI
Contact:

Re: TEsound - simple, easy sound/music manager

Post by TechnoCat »

Could you add this to the wiki please? http://love2d.org/wiki/Category:Libraries?action=purge
Post Reply

Who is online

Users browsing this forum: Amazon [Bot] and 3 guests