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

JaredSartin
Prole
Posts: 9
Joined: Wed Jul 09, 2014 2:22 pm

Re: TEsound - simple, easy sound/music manager

Post by JaredSartin »

That would be awesome! Thanks SiENcE!
User avatar
Cryogenical
Prole
Posts: 49
Joined: Mon Apr 28, 2014 5:23 pm

Re: TEsound - simple, easy sound/music manager

Post by Cryogenical »

SCiENCE, I think you might have broken the function TEsound.play(list) or something?
I made a list as such:

Code: Select all

list = {"assets/music/matryoshkachorus.mp3",
     "assets/music/senbonzakurachorus.mp3",
     "assets/music/noushouchorus.mp3", 
     "assets/music/headphoneactorchorus.mp3", 
     "assets/music/nyanchorus.mp3", 
     "assets/music/rimokonchorus.mp3",
    }
and tried to run "TEsound.play(list)", and it gave me this error:Image
User avatar
SiENcE
Party member
Posts: 805
Joined: Thu Jul 24, 2008 2:25 pm
Location: Berlin/Germany
Contact:

Re: TEsound - simple, easy sound/music manager

Post by SiENcE »

Hey,

sorry for the later answer, i was on vacation.

You first have to make a Sounddata from this.

Like this, and than pass it to the play function.

Code: Select all

love.sound.newSoundData("sfx.wav")
I made this because it's totally stupid to reload a sound from disk every time you want to play it!

Also I disabled playback of tables. Just remove the -- before "if type ...". I don't know why I made this, maybe there where some errors.

Code: Select all

	-- arrays not supported, because loading of sounds had to be done before
--	if type(sound) == "table" then sound = sound[math.random(#sound)] end
User avatar
Cryogenical
Prole
Posts: 49
Joined: Mon Apr 28, 2014 5:23 pm

Re: TEsound - simple, easy sound/music manager

Post by Cryogenical »

I don't understand then.
How would I incorporate my list then, when I want to play it randomized?
User avatar
SiENcE
Party member
Posts: 805
Joined: Thu Jul 24, 2008 2:25 pm
Location: Berlin/Germany
Contact:

Re: TEsound - simple, easy sound/music manager

Post by SiENcE »

Randomize before you pass the soundeffect to TESound.

Code: Select all

list = {
     [1]="assets/music/matryoshkachorus.mp3",
     [2]="assets/music/senbonzakurachorus.mp3",
     [3]="assets/music/noushouchorus.mp3", 
     [4]="assets/music/headphoneactorchorus.mp3", 
     [5]="assets/music/nyanchorus.mp3", 
     [6]="assets/music/rimokonchorus.mp3",
    }

local soundnumber = math.random( #list)
TEsound.play( love.sound.newSoundData( list[soundnumber] ) , "sfx")
But better is to load all soundeffects at the start of the game using "love.sound.newSoundData" and than later in your game pass this SoundData to TEsound.play . My sample is bad, because every time you play a sound, your sound is loaded and converted to SoundData and than in TESound converted to a audio "Source".

Something like this:

Code: Select all

local loadedsounds =  {}
for k,v in pairs(list) do
	table.insert(loadedsounds, k, love.sound.newSoundData(v) )
end

--later in the game use this to play a sound
local soundnumber = math.random( #loadedsounds )
TEsound.play( loadedsounds[ soundnumber ] , "sfx")
User avatar
Cryogenical
Prole
Posts: 49
Joined: Mon Apr 28, 2014 5:23 pm

Re: TEsound - simple, easy sound/music manager

Post by Cryogenical »

It's only playing the 5th index.
Even with your combined code.
User avatar
DaedalusYoung
Party member
Posts: 413
Joined: Sun Jul 14, 2013 8:04 pm

Re: TEsound - simple, easy sound/music manager

Post by DaedalusYoung »

You should use love.math.random, it is seeded on startup.
User avatar
SiENcE
Party member
Posts: 805
Joined: Thu Jul 24, 2008 2:25 pm
Location: Berlin/Germany
Contact:

Re: TEsound - simple, easy sound/music manager

Post by SiENcE »

DaedalusYoung wrote:You should use love.math.random, it is seeded on startup.
Oh yes, or initialize the lua generator like this.

Code: Select all

	-- Initialize the pseudo random number generator
	-- The first random number you get is not really 'randomized' (at least in Windows 2K and OS X).
	-- To get better pseudo-random number just pop some random number before using them for real:
	math.randomseed(os.time())
	math.random(); math.random(); math.random()
hiccupface
Prole
Posts: 14
Joined: Sat Apr 25, 2015 7:55 pm

Re: TEsound - simple, easy sound/music manager

Post by hiccupface »

I just want to post here to say thanks for creating TEsound.

It's so easy and handy and wonderful! :neko:
User avatar
TheMeq
Citizen
Posts: 56
Joined: Fri Sep 02, 2011 9:56 pm
Location: Nottingham, UK

Re: TEsound - simple, easy sound/music manager

Post by TheMeq »

Is there a way to get the current playtime of a song?
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 1 guest