Page 5 of 6

Re: TEsound - simple, easy sound/music manager

Posted: Mon Aug 25, 2014 6:45 pm
by JaredSartin
That would be awesome! Thanks SiENcE!

Re: TEsound - simple, easy sound/music manager

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

Re: TEsound - simple, easy sound/music manager

Posted: Sat Sep 20, 2014 11:38 am
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

Re: TEsound - simple, easy sound/music manager

Posted: Mon Sep 22, 2014 5:53 pm
by Cryogenical
I don't understand then.
How would I incorporate my list then, when I want to play it randomized?

Re: TEsound - simple, easy sound/music manager

Posted: Mon Oct 06, 2014 12:00 pm
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")

Re: TEsound - simple, easy sound/music manager

Posted: Mon Oct 06, 2014 7:15 pm
by Cryogenical
It's only playing the 5th index.
Even with your combined code.

Re: TEsound - simple, easy sound/music manager

Posted: Mon Oct 06, 2014 7:32 pm
by DaedalusYoung
You should use love.math.random, it is seeded on startup.

Re: TEsound - simple, easy sound/music manager

Posted: Mon Oct 06, 2014 8:22 pm
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()

Re: TEsound - simple, easy sound/music manager

Posted: Sun Jun 07, 2015 12:46 am
by hiccupface
I just want to post here to say thanks for creating TEsound.

It's so easy and handy and wonderful! :neko:

Re: TEsound - simple, easy sound/music manager

Posted: Wed Oct 07, 2015 4:58 pm
by TheMeq
Is there a way to get the current playtime of a song?