Solved

playing .wav files in C

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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
In desperate need of help 8 132
Read file descriptor 3 in C 14 104
chcp 65001 File encoding 66 230
How to install SVN Command Line Client? 5 39
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 opening and writing to files in the C programming language.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.

948 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

22 Experts available now in Live!

Get 1:1 Help Now