play wave files independently and simultaneously?

Please discuss general Delphi programming topics here.

play wave files independently and simultaneously?

Postby Mohammad Ahmadzadeh » September 19th, 2005, 2:13 pm

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
Cheerio

Mohammad Ahmadzadeh
Mohammad Ahmadzadeh
Active Member
Active Member
 
Posts: 7
Joined: September 15th, 2005, 7:25 am
Location: Iran

Postby Radagast » September 22nd, 2005, 3:13 pm

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.
Radagast
Active Member
Active Member
 
Posts: 24
Joined: May 1st, 2005, 9:32 pm
Location: Poland

Postby Mohammad Ahmadzadeh » September 23rd, 2005, 3:47 pm

Thank you Radagast for your help.
Cheerio

Mohammad Ahmadzadeh
Mohammad Ahmadzadeh
Active Member
Active Member
 
Posts: 7
Joined: September 15th, 2005, 7:25 am
Location: Iran

Postby werdnareid » April 21st, 2006, 10:32 pm

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
werdnareid
Active Member
Active Member
 
Posts: 22
Joined: August 6th, 2003, 5:35 pm

Postby Kambiz » April 21st, 2006, 11:17 pm

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.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm

Postby werdnareid » April 22nd, 2006, 1:33 am

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
werdnareid
Active Member
Active Member
 
Posts: 22
Joined: August 6th, 2003, 5:35 pm


Return to Delphi Programming

Who is online

Users browsing this forum: No registered users and 11 guests

cron