Solved

playing .wav files in C

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

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…
An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.

760 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now