Page 1 of 1

play wave files independently and simultaneously?

PostPosted: September 19th, 2005, 2:13 pm
by Mohammad Ahmadzadeh
Is there any way to play some wave files independently and simultaneously?
See this figure:
a.wav |.....................XXXXXXXXXXXXXXXX
b.wav |XXXXXX...........XXXXXX......XXXXXX
c.wav |..........XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
d.wav |.................XXXXXXXXXXXXXXXXXXXXXX

PostPosted: September 22nd, 2005, 3:13 pm
by Radagast
There has to be way to do so. Try components available on this page or Delphi's TMediaPlayer (if it doesn't have such option try using more than one component). If it doesn't help read about some additional libraries. DirectSound (or Audio - I don't remember), Allegro*, OpenAL*, OpenML. The last three are cross-platform. They deffinitely have needed options.
* free only for non-commercial use.

PostPosted: September 23rd, 2005, 3:47 pm
by Mohammad Ahmadzadeh
Thank you Radagast for your help.

PostPosted: April 21st, 2006, 10:32 pm
by werdnareid
You could extend the tthread object to play a sound file by dynamically creating a component that plays sound(tmediaplayer). You would create a thread for each file you want to play.

While conceptually I think this sould work I have not tried it myself. The only question I have is if the tmediaplayer needs a twindowcontrol object before it will work

PostPosted: April 21st, 2006, 11:17 pm
by Kambiz
werdnareid wrote:You could extend the tthread object to play a sound file by dynamically creating a component that plays sound(tmediaplayer). You would create a thread for each file you want to play.

While conceptually I think this sould work I have not tried it myself. The only question I have is if the tmediaplayer needs a twindowcontrol object before it will work


IMHO, This method has some disadvantages:
  • The threads do not start and execute simultaneously. Therefore synchronization of the sounds becomes a big issue.
  • Some audio drivers can only playback one audio stream.
  • Needs unnecessary amount of CPU and memory usage.

PostPosted: April 22nd, 2006, 1:33 am
by werdnareid
Kambiz wrote:
werdnareid wrote:You could extend the
IMHO, This method has some disadvantages:
  • The threads do not start and execute simultaneously. Therefore synchronization of the sounds becomes a big issue.
  • Some audio drivers can only playback one audio stream.
  • Needs unnecessary amount of CPU and memory usage.

1:Needs unnecessary amount of CPU and memory. This will happen if the design is poor i have done some poor tthreads myself.

2:Some audio drivers can only playback one audio stream.
This is new to me, so thanks for the info on that .

3:The threads do not start and execute simultaneously. Therefore synchronization of the sounds becomes a big issue.
This is also true, my aim was not to present tthreads a bullet prof solution, but to have it out there a potential solution.
synchronization is always the item to watch when dealing with tthread, but the issue them not starting at the same time seems to be doable with some thought. in any case a standard application has only one main thread so in my view it's not possible to start playing all the files at the same time any way as two.start will have to wait until one.start has fired resulting in the same issue your mentioned of not been syncronised. with a thread you can start the thread suspended then find a way to fire them at the same time