:confused: hi!
How to output sound using C++ program?
is there any function to output sound in C++ program??
can anyone help me to solve my problem???
Printable View
:confused: hi!
How to output sound using C++ program?
is there any function to output sound in C++ program??
can anyone help me to solve my problem???
Code:#include<unknownos.h>
#include<whatcompiler.h>
int main()
{
unknownos::Sound thebeeper;
thebeeper.IdioticFreqSet(10000);
thebeeper.StupidAmplitudeSet(10000);
thebeeper.MakeSarcasticSound();
whatcompiler::End();
return PSCYCHICRETVAL;
}
um can that post be deleted its complete spam al you SHOULD have said is,
what os,
what compiler,
we really can only give you some helpfull sites to certain codes that may or maynot even help you.
ok well anyway as i recall there should be one in the faq
http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?answer=1043876931&id=1031248558
:) :) :)
I'm going to assume you're using C++, of course, compiler, for the MOST part, it doesnt matter.....
Lets see, I suggest you take a look into openGL or directX, either one is used very widely, and it would be suggested you learn both in the long run :d
DirectX or OpenGL just for a sound? I don't think so. I agree it would be good to learn in the long run but that library would not be a good choice if you're JUST going to use sound. Try this:
You also need to link the library by typing -lwinmm in the commands when calling compiler. winmm stands for Windows Multi-Media(winmm). So only if you're doing Windows programming should you use this.Code:#include <windows.h>
#include <mmsystem.h>
int main()
{
PlaySound("sound.wav",NULL,SND_ASYNC|SND_FILENAME);
return 0;
}
Would that work in a console app? It doesn't seem to work for me. I made sure to include theQuote:
Originally Posted by jmd15
#pragma comment(lib,"winmm.lib"); and also tried it with "lwinmm.lib".
I've also tried sndPlaySound() and all sorts of crap like that before...but never had any luck with it.
If you just want to play a sound, try this:
Code:cout << "\a";
That plays a beep, or whatever the Windows DEFAULT-SOUND is. Try
. . . And that should beep at 100 Hertz untill you reboot, or recompile with nosound() instead of sound(100)Code:#include <pc.h>
int main() {
sound(100);
return 0;
}
With what compiler? DJGPP, and ...?
Windows functions (or ANSII ones) are your best bet (unless you're using Linux).
Code:#include <windows.h>
int main()
{
Beep(1568, 200);
Beep(1568, 200);
Beep(1568, 200);
Beep(1245, 1000);
Beep(1397, 200);
Beep(1397, 200);
Beep(1397, 200);
Beep(1175, 1000);
return 0;
}
The OP didn't even stick around to read the first reply -
Just a bunch of pointless speculation and noise.