Thread: how to playing WAV in C

  1. #1
    Registered User
    Join Date
    Oct 2009
    Posts
    4

    Unhappy how to playing WAV in C

    Code:
    #include <windows.h>
    #include <mmsystem.h>
    #include <stdio.h>
    #include <conio.h>
    #include <Winmm.lib>
    #pragma comment(lib, "Winmm.lib")
    int main()
    {
        
        printf("test sound");
        PlaySound("C:\1.wav",NULL,SND_ASYNC|SND_FILENAME);
        Sleep(1000);
        return 0;
        getch();
    }
    error
    winmm.lib:no such file or diretory

    [Build Error][C:/testsound.o]Error1


    or

    Code:
    #include <windows.h>
    #include <mmsystem.h>
    #include <stdio.h>
    #include <conio.h>
    #pragma comment(lib, "Winmm.lib")
    int main()
    {
        
        printf("test sound");
        PlaySound("C:\1.wav",NULL,SND_ASYNC|SND_FILENAME);
        Sleep(1000);
        return 0;
        getch();
    }
    compile Done but build exe
    file exe 16 kb but wav 50mb
    I run exe.....Nothing happens



    \ in strings needs to be escaped. Use / or \\ instead.


    Quzah.

    thank you.i play done.But


    I want to play without sound WAV On the computer.
    Exe is just a play
    I want WAV and exe mixed.

    help me plaese
    Last issue
    Last edited by mazaoa; 10-09-2009 at 06:46 PM.

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    \ in strings needs to be escaped. Use / or \\ instead.


    Quzah.
    Hope is the first step on the road to disappointment.

  3. #3
    Make Fortran great again
    Join Date
    Sep 2009
    Posts
    1,413
    looks like you need coredll.lib?

    PlaySound

    I'd try FMOD or Audiere instead

  4. #4
    Registered User
    Join Date
    Oct 2009
    Posts
    4
    Quote Originally Posted by quzah View Post
    \ in strings needs to be escaped. Use / or \\ instead.


    Quzah.
    ok thank you


    I want to play without sound WAV On the computer.
    Exe is just a play

  5. #5
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    Quote Originally Posted by mazaoa View Post
    ok thank you


    I want to play without sound WAV On the computer.
    Exe is just a play
    You mean embed the wave file in the exe? Sure, just add it to the resource and change the parameters you pass to PlaySound().

  6. #6
    Registered User
    Join Date
    Oct 2009
    Posts
    4
    Quote Originally Posted by zacs7 View Post
    You mean embed the wave file in the exe? Sure, just add it to the resource and change the parameters you pass to PlaySound().
    I mean embed file WAV in exe. If I'll copy exe without have file WAV.I want exe run.

    summary.
    I must have One file exe.
    run exe Have program and WAV.with out not have 2 file WAV and exe

    Sorry very very
    A sample to see better
    English, not bold.
    I use google Translate

    Thank you very much.

  7. #7
    Registered User
    Join Date
    Apr 2007
    Posts
    137
    Quote Originally Posted by mazaoa View Post
    I mean embed file WAV in exe. If I'll copy exe without have file WAV.I want exe run.
    A sample to see better
    Samples for that have be published for ~20 years.
    See on MSDN (SDK samples) or re-ask on old (but advanced )Win32 group
    (C and C++ mainly)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Playing wav
    By uhhstepup in forum C++ Programming
    Replies: 4
    Last Post: 10-09-2009, 10:59 AM
  2. Playing a wav file while a thread is running
    By etzarfat in forum C Programming
    Replies: 0
    Last Post: 08-25-2009, 04:05 AM
  3. Replies: 5
    Last Post: 07-30-2003, 03:04 PM
  4. Wav edit programmation for dos with DJGPP
    By sprudhom in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 07-17-2003, 07:35 AM
  5. Playing a wav file in C language
    By tvkswamy in forum C Programming
    Replies: 1
    Last Post: 09-13-2001, 10:01 AM