TEsound - simple, easy sound/music manager

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

Awesome?

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

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

Re: TEsound - simple, easy sound/music manager

Post by JaredSartin » Mon Aug 25, 2014 6:45 pm

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 » Thu Aug 28, 2014 5:46 pm

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: 791
Joined: Thu Jul 24, 2008 2:25 pm
Location: Berlin/Germany
Contact:

Re: TEsound - simple, easy sound/music manager

Post by SiENcE » Sat Sep 20, 2014 11:38 am

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 » Mon Sep 22, 2014 5:53 pm

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: 791
Joined: Thu Jul 24, 2008 2:25 pm
Location: Berlin/Germany
Contact:

Re: TEsound - simple, easy sound/music manager

Post by SiENcE » Mon Oct 06, 2014 12:00 pm

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 » Mon Oct 06, 2014 7:15 pm

It's only playing the 5th index.
Even with your combined code.

User avatar
DaedalusYoung
Party member
Posts: 402
Joined: Sun Jul 14, 2013 8:04 pm

Re: TEsound - simple, easy sound/music manager

Post by DaedalusYoung » Mon Oct 06, 2014 7:32 pm

You should use love.math.random, it is seeded on startup.

User avatar
SiENcE
Party member
Posts: 791
Joined: Thu Jul 24, 2008 2:25 pm
Location: Berlin/Germany
Contact:

Re: TEsound - simple, easy sound/music manager

Post by SiENcE » Mon Oct 06, 2014 8:22 pm

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 » Sun Jun 07, 2015 12:46 am

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 » Wed Oct 07, 2015 4:58 pm

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

Post Reply

Who is online

Users browsing this forum: No registered users and 9 guests