How to code a program that can play sound

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Oct 2004
Posts: 22
Reputation: kakilang is an unknown quantity at this point 
Solved Threads: 0
kakilang's Avatar
kakilang kakilang is offline Offline
Newbie Poster

How to code a program that can play sound

 
0
  #1
Oct 27th, 2004
below is the simple source code

#include <iostream>
using namespace std;

int main()
{
cout<<"Hello"<<endl;
system("pause");
return 0;
}??

how to let program play some music when the program
print the word "Hello"??
Let's say the song file name is "hello.mpg".
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,602
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 713
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Code Goddess

Re: How to code a program that can play sound

 
0
  #2
Oct 27th, 2004
  1. #include <stdmagic>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. magically_do_something_platform_and_implementation_specific(PLAY_MUSIC, "hello.mpg");
  8. }
By the way, what OS and compiler are you using? :rolleyes:
I'm here to prove you wrong.
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 22
Reputation: kakilang is an unknown quantity at this point 
Solved Threads: 0
kakilang's Avatar
kakilang kakilang is offline Offline
Newbie Poster

Re: How to code a program that can play sound

 
0
  #3
Oct 27th, 2004
i use windows xp and dev c++ 4.9.9.0 compiler
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 3,971
Reputation: vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice 
Solved Threads: 920
Moderator
vegaseat's Avatar
vegaseat vegaseat is offline Offline
DaniWeb's Hypocrite

Re: How to code a program that can play sound

 
0
  #4
Oct 27th, 2004
Not quite ZZ Top but it's a start!
The Windows Api has a little thing called Beep(), try it ...

  1. // simple sounds via Beep(frequency_hrz, duration_ms)
  2.  
  3. #include <iostream>
  4. #include <windows.h> // WinApi header file
  5.  
  6. using namespace std;
  7.  
  8. int main(int argc, char *argv[])
  9. {
  10. Beep(523.2511,500); // 523.2511 hertz (C5) for 500 milliseconds
  11. Beep(587.3295,500);
  12. Beep(659.2551,500);
  13. Beep(698.4565,500);
  14. Beep(783.9909,500);
  15.  
  16. cin.get(); // wait
  17. return 0;
  18. }
There are nicer things like sound(), that use the sound chip and midi voices. A little tough for C++. If you want to test it, get BCX free from:

http://www.rjpcomputing.com/programm.../devsuite.html

get used to BCXDX and learn to fly with sound and graphics! There are lots of sample files. This goes beyond the usual boring calculator and employee database stuff! You are still learning C/C++ though.
May 'the Google' be with you!
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 22
Reputation: kakilang is an unknown quantity at this point 
Solved Threads: 0
kakilang's Avatar
kakilang kakilang is offline Offline
Newbie Poster

Re: How to code a program that can play sound

 
0
  #5
Oct 28th, 2004
thx Vegaseat the program successdfully run and the beep sound is funny
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 22
Reputation: kakilang is an unknown quantity at this point 
Solved Threads: 0
kakilang's Avatar
kakilang kakilang is offline Offline
Newbie Poster

Re: How to code a program that can play sound

 
0
  #6
Oct 28th, 2004
Vegaseat do u know how to link the music or sound like "Hello.mpg"

when the compiler executed until cout<<"Hello"<<endl; and play some sound or music
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC