Play sound

I need a very simple way to play audio

Page 1 of 1

9 Replies - 65720 Views - Last Post: 16 April 2007 - 07:24 PM Rate Topic: -----

#4 N-ico  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 10
  • Joined: 16-November 05

Re: Play sound

Posted 05 September 2006 - 01:17 AM

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: 05 September 2006 - 01:18 AM

Was This Post Helpful? 1

#5 Xing  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 19
  • View blog
  • Posts: 725
  • Joined: 22-July 06

Re: Play sound

Posted 05 September 2006 - 03:21 AM

BASS audio library
Was This Post Helpful? 0
  • +
  • -

#6 Louisda16th  Icon User is offline

  • dream.in.assembly.code
  • member icon

Reputation: 15
  • View blog
  • Posts: 1,967
  • Joined: 03-August 06

Re: Play sound

Posted 05 September 2006 - 03:52 AM

since this topics up, is there smthing in C/C++ like the the play statement in BASIC?
Was This Post Helpful? 0
  • +
  • -

#7 Xing  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 19
  • View blog
  • Posts: 725
  • Joined: 22-July 06

Re: Play sound

Posted 05 September 2006 - 04:18 AM

View PostLouisda16th, on 5 Sep, 2006 - 03:52 AM, said:

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.
Was This Post Helpful? 0
  • +
  • -

#8 Louisda16th  Icon User is offline

  • dream.in.assembly.code
  • member icon

Reputation: 15
  • View blog
  • Posts: 1,967
  • Joined: 03-August 06

Re: Play sound

Posted 05 September 2006 - 04:22 AM

View PostXing, on 5 Sep, 2006 - 04:48 PM, said:

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).
Was This Post Helpful? 0
  • +
  • -

#9 born2c0de  Icon User is offline

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

Reputation: 180
  • View blog
  • Posts: 4,667
  • Joined: 26-November 04

Re: Play sound

Posted 05 September 2006 - 04:55 AM

Use this API Function in windows.h
PlaySound("C:\\SOUNDS\\BELLS.WAV", NULL, SND_ASYNC);


Was This Post Helpful? 0
  • +
  • -

#10 csteele16  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 16-April 07

Re: Play sound

Posted 16 April 2007 - 12:27 PM

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?
Was This Post Helpful? 0
  • +
  • -

#11 NickDMax  Icon User is offline

  • Can grep dead trees!
  • member icon

Reputation: 2250
  • View blog
  • Posts: 9,245
  • Joined: 18-February 07

Re: Play sound

Posted 16 April 2007 - 04:14 PM

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.
Was This Post Helpful? 1

#12 Thegeneral  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 19
  • Joined: 01-April 07

Re: Play sound

Posted 16 April 2007 - 05:58 PM

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.
Was This Post Helpful? 0
  • +
  • -

#13 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,507
  • Joined: 12-July 02

Re: Play sound

Posted 16 April 2007 - 07:24 PM

Usually under 1Meg, but it will play larger ones sometimes.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1