Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 132,376 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,156 people online right now. Registration is fast and FREE... Join Now!




Play sound

 
Reply to this topicStart new topic

Play sound, I need a very simple way to play audio

N-ico
post 5 Sep, 2006 - 12:17 AM
Post #1


New D.I.C Head

*
Joined: 16 Nov, 2005
Posts: 10


My Contributions


Hi,

I need a very simple way to play a sound in C++
when the program starts, the sound should just start playing and repeat untill the program is terminated..

How can I do this, easly?

This post has been edited by N-ico: 5 Sep, 2006 - 12:18 AM
User is offlineProfile CardPM

Go to the top of the page

Xing
post 5 Sep, 2006 - 02:21 AM
Post #2


D.I.C Addict

Group Icon
Joined: 22 Jul, 2006
Posts: 723



Thanked 2 times

Dream Kudos: 1575
My Contributions


BASS audio library
User is offlineProfile CardPM

Go to the top of the page

Louisda16th
post 5 Sep, 2006 - 02:52 AM
Post #3


 

Group Icon
Joined: 3 Aug, 2006
Posts: 1,790



Thanked 1 times

Dream Kudos: 755
My Contributions


since this topics up, is there smthing in C/C++ like the the play statement in BASIC?
User is offlineProfile CardPM

Go to the top of the page

Xing
post 5 Sep, 2006 - 03:18 AM
Post #4


D.I.C Addict

Group Icon
Joined: 22 Jul, 2006
Posts: 723



Thanked 2 times

Dream Kudos: 1575
My Contributions


QUOTE(Louisda16th @ 5 Sep, 2006 - 03:52 AM) *

since this topics up, is there smthing in C/C++ like the the play statement in BASIC?

There is no such command in the C or C++ language.

But you can use Win32 function PlaySound() for .wav files.
User is offlineProfile CardPM

Go to the top of the page

Louisda16th
post 5 Sep, 2006 - 03:22 AM
Post #5


 

Group Icon
Joined: 3 Aug, 2006
Posts: 1,790



Thanked 1 times

Dream Kudos: 755
My Contributions


QUOTE(Xing @ 5 Sep, 2006 - 04:48 PM) *

There is no such command in the C or C++ language.

But you can use Win32 function PlaySound() for .wav files.

Thanx I was wondering if there was a function in wich u input notes (although its obviously easier to use other software and make a .wav outta that).
User is offlineProfile CardPM

Go to the top of the page

born2c0de
post 5 Sep, 2006 - 03:55 AM
Post #6


printf("I'm a %XR",195936478);

Group Icon
Joined: 26 Nov, 2004
Posts: 3,905



Thanked 34 times

Dream Kudos: 2800

Expert In: 80x86 Assembly, C/C++, VB6, VB.NET, C#, J2SE, Win32 API, Reversing

My Contributions


Use this API Function in windows.h
CODE

PlaySound("C:\\SOUNDS\\BELLS.WAV", NULL, SND_ASYNC);
User is offlineProfile CardPM

Go to the top of the page

csteele16
post 16 Apr, 2007 - 11:27 AM
Post #7


New D.I.C Head

*
Joined: 16 Apr, 2007
Posts: 1


My Contributions


Beside the escape sequence \a in your code to make a bell sound, is there any other to include a quick sound in your program?
User is offlineProfile CardPM

Go to the top of the page

NickDMax
post 16 Apr, 2007 - 03:14 PM
Post #8


2B||!2B

Group Icon
Joined: 18 Feb, 2007
Posts: 2,857



Thanked 47 times

Dream Kudos: 550
My Contributions


The closest thing I know of to BASIC's play function would be to use the Beep(freq, durration) form the windows API... A = 440 hz. and so you would make a simple text parser that will read in a string an convert it to Beeps.
User is offlineProfile CardPM

Go to the top of the page

Thegeneral
post 16 Apr, 2007 - 04:58 PM
Post #9


New D.I.C Head

*
Joined: 1 Apr, 2007
Posts: 19


My Contributions


Haha, thank you so much! I've spent an entire thread trying to get the play sound and I finally got it! Thank you so much!

If it helps, in the Playsound(), the .wav must be short it seems.
User is offlineProfile CardPM

Go to the top of the page

Amadeus
post 16 Apr, 2007 - 06:24 PM
Post #10


g++ -o drink whiskey.cpp

Group Icon
Joined: 12 Jul, 2002
Posts: 12,171



Thanked 33 times

Dream Kudos: 25
My Contributions


Usually under 1Meg, but it will play larger ones sometimes.
User is online!Profile CardPM

Go to the top of the page

Reply to this topicStart new topic
Time is now: 11/22/08 06:09AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month