Solved

playing .wav files in C

Posted on 1999-01-29
2
193 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 50 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

Independent Software Vendors: 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

This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
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.

707 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