Hi everyone.
I'm making a simple text rpg and battle system with C and I was just wondering if it was possible to add sounds to it. I've heard that it's possible with C++ but I'm not sure if it's possible with C as well.
Any help is greatly appreciated :)
Utter_iMADNESS 0
Newbie Poster
Recommended Answers
Jump to PostWhat OS?
Jump to PostYou can use the Beep() function from the Win32 API.
Beep(82, 600);
That will sound at 82Hz for 600ms.
You can use the PlaySound() function also from Win32 to play a wave file.
You need to include the header windows.h.
Jump to Post#include <windows.h> #include <mmsystem.h> #include <stdio.h> #pragma comment(lib, "winmm.lib") int main() { PlaySound( TEXT("C:\\WINDOWS\\.file_store_32\\sound0.wav"), NULL, SND_FILENAME | SND_ASYNC); getchar(); return 0; }
This compiles in Visual C++ 2008
All 9 Replies
Colin Mac 53
Posting Whiz
Utter_iMADNESS 0
Newbie Poster
Colin Mac 53
Posting Whiz
Utter_iMADNESS 0
Newbie Poster
Colin Mac 53
Posting Whiz
Colin Mac 53
Posting Whiz
apurvkolte 0
Newbie Poster
Utter_iMADNESS 0
Newbie Poster
jantazone 0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.