TEsound - simple, easy sound/music manager
-
- Prole
- Posts: 9
- Joined: Wed Jul 09, 2014 2:22 pm
Re: TEsound - simple, easy sound/music manager
That would be awesome! Thanks SiENcE!
- Cryogenical
- Prole
- Posts: 49
- Joined: Mon Apr 28, 2014 5:23 pm
Re: TEsound - simple, easy sound/music manager
SCiENCE, I think you might have broken the function TEsound.play(list) or something?
I made a list as such:
and tried to run "TEsound.play(list)", and it gave me this error:
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",
}
Re: TEsound - simple, easy sound/music manager
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.
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.
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")
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
- Cryogenical
- Prole
- Posts: 49
- Joined: Mon Apr 28, 2014 5:23 pm
Re: TEsound - simple, easy sound/music manager
I don't understand then.
How would I incorporate my list then, when I want to play it randomized?
How would I incorporate my list then, when I want to play it randomized?
Re: TEsound - simple, easy sound/music manager
Randomize before you pass the soundeffect to TESound.
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
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")
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")
- Cryogenical
- Prole
- Posts: 49
- Joined: Mon Apr 28, 2014 5:23 pm
Re: TEsound - simple, easy sound/music manager
It's only playing the 5th index.
Even with your combined code.
Even with your combined code.
- DaedalusYoung
- Party member
- Posts: 413
- Joined: Sun Jul 14, 2013 8:04 pm
Re: TEsound - simple, easy sound/music manager
You should use love.math.random, it is seeded on startup.
Re: TEsound - simple, easy sound/music manager
Oh yes, or initialize the lua generator like this.DaedalusYoung wrote:You should use love.math.random, it is seeded on startup.
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()
-
- Prole
- Posts: 14
- Joined: Sat Apr 25, 2015 7:55 pm
Re: TEsound - simple, easy sound/music manager
I just want to post here to say thanks for creating TEsound.
It's so easy and handy and wonderful!
It's so easy and handy and wonderful!
Re: TEsound - simple, easy sound/music manager
Is there a way to get the current playtime of a song?
Who is online
Users browsing this forum: No registered users and 9 guests