?
Solved

playing .wav files in C

Posted on 1999-01-29
2
Medium Priority
?
194 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
The goal of this video is to provide viewers with basic examples to understand recursion 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.
Suggested Courses

752 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