Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

playing .wav files in C

Posted on 1999-01-29
2
Medium Priority
?
196 Views
Last Modified: 2010-04-15
ok....im new here....and new to C....im taking my second semester of C and was wondering if anyone knew how to use C to play .wav files....and if C has to do anything to the soundcard before it can play .wav files???
0
Comment
Question by:mister_E
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 8

Accepted Solution

by:
Answers2000 earned 200 total points
ID: 1258529
There's no standard C function for it on all platforms.

If you are writing Windows programs (including console programs say with Visual C 2/3/4/5/6) you can simply use sndPlaySound

#include <windows.h>
#include <mmsystem.h>
int main( int argc, char * argv[] )
{
sndPlaySound( "C:\\EXAMPLE\\NOISE.WAV", 0 ) ;
return 0
}

Make sure your program links to the library called winmm.lib (this should be in project settings in your compiler's IDE)

If you use string literals for the path name, don't forget any back slashes need to be doubled up, e.g. the path of the file I use above is actually C:\EXAMPLE\NOISE.WAV
0
 

Author Comment

by:mister_E
ID: 1258530
thanks for the input...does anyone know if there is a way to adjust the speed of playback????
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.

597 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question