Playing sounds in parallel

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
obey
Prole
Posts: 16
Joined: Sun Jun 09, 2013 3:18 pm

Playing sounds in parallel

Post by obey » Sun Jun 30, 2013 7:12 pm

It seems like my sound plays synchronously, but some times I'd like to play them together.
Is that possible? or am I doing something wrong?

User avatar
raidho36
Party member
Posts: 1899
Joined: Mon Jun 17, 2013 12:00 pm

Re: Playing sounds in parallel

Post by raidho36 » Sun Jun 30, 2013 7:24 pm

What exactly do you mean? Paralell is same as synchronously to begin with, so I fail to see the point.

obey
Prole
Posts: 16
Joined: Sun Jun 09, 2013 3:18 pm

Re: Playing sounds in parallel

Post by obey » Sun Jun 30, 2013 7:37 pm

raidho36 wrote:What exactly do you mean? Paralell is same as synchronously to begin with, so I fail to see the point.
I mean:

(Sounds)
^
|_[Sound 1 ]_____________________
|__________[Sound 2_____]________
|______________[Sound 3_______]__
________________________________> (time)

Sound 2 and 3 are "playing in parallel", how can I achieve that?

User avatar
micha
Inner party member
Posts: 1083
Joined: Wed Sep 26, 2012 5:13 pm

Re: Playing sounds in parallel

Post by micha » Sun Jun 30, 2013 8:03 pm

You need to create a source for each of the sounds and then you can play them parallel.

If this is not what you mean, then can you please post a .love file that shows, that you have got already?

obey
Prole
Posts: 16
Joined: Sun Jun 09, 2013 3:18 pm

Re: Playing sounds in parallel

Post by obey » Sun Jun 30, 2013 8:55 pm

micha wrote:You need to create a source for each of the sounds and then you can play them parallel.

If this is not what you mean, then can you please post a .love file that shows, that you have got already?
Can I play sound1 twice? because currently, it needs to stop first.

User avatar
bartbes
Sex machine
Posts: 4944
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Playing sounds in parallel

Post by bartbes » Sun Jun 30, 2013 8:58 pm

He's saying you need to create a new source for it.
Basically, you can think of a source as a music instrument, it can only play one thing at a time.

obey
Prole
Posts: 16
Joined: Sun Jun 09, 2013 3:18 pm

Re: Playing sounds in parallel

Post by obey » Sun Jun 30, 2013 9:02 pm

bartbes wrote:He's saying you need to create a new source for it.
Basically, you can think of a source as a music instrument, it can only play one thing at a time.
Thanks, it works.

User avatar
raidho36
Party member
Posts: 1899
Joined: Mon Jun 17, 2013 12:00 pm

Re: Playing sounds in parallel

Post by raidho36 » Sat Jul 27, 2013 7:45 am

Will it then reuse already loaded samples?

User avatar
bartbes
Sex machine
Posts: 4944
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Playing sounds in parallel

Post by bartbes » Sat Jul 27, 2013 3:29 pm

What do you mean?

If you mean whether it will use the same decoded data, then the answer is yes and no. It will if you pass it the same SoundData, it won't if you're streaming from a Decoder. The latter would also be very impractical, especially considering a streaming Source only keeps a relatively small buffer and streams from disk (or memory, I guess).

User avatar
raidho36
Party member
Posts: 1899
Joined: Mon Jun 17, 2013 12:00 pm

Re: Playing sounds in parallel

Post by raidho36 » Sat Jul 27, 2013 4:30 pm

Well yes, I mean decoded data, the samples. Of course I wouldn't want to play multiple streams in parallel, not under normal circuimstances, but even then not reusing samples makes perfect sense as streaming discards them almost immediately, and because of very narrow buffer frame there's no reason to even try to reuse it since that will fail, like, 99.999% of all times (that estimation might be generous actually).

That answers my question. I thought so, since LÖVE goes with the same principle as Lua about memory in general. Another minor question is must I create new sources from SoundData to reuse samples, or just passing newSource same filename will do?

Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests