[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Recording and Play Wave file IN VC++4.0

Posted on 1997-12-27
6
Medium Priority
?
468 Views
Last Modified: 2008-03-03
Dear
     
  I want to play and record wave file VC++4.0
 What is the function call coding and paramters?
 Thank You for help      
0
Comment
Question by:logout
[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
6 Comments
 
LVL 7

Accepted Solution

by:
galkin earned 40 total points
ID: 1177095
To play wav files use PlaySound Win32 multimedia function. Be sure to build you project with winmm.lib and when compiling include mmsystem.h


0
 

Author Comment

by:logout
ID: 1177096
Dear
     Which lib function need to be called?
0
 
LVL 7

Expert Comment

by:galkin
ID: 1177097
The function is PlaySound implemented in winmm.dll which can be found in system directory. Corresponding lib file is winmm.lib that comes with windows SDK or VC++ or BC++.Header file needed is mmsystem.h which also comes with Windows SDK, VC++ or BC++ and can be found in include directory.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 1

Expert Comment

by:andla
ID: 1177098
Recording sounds.

DWORD recordWAVEFile(DWORD dwMilliSeconds);

DWORD recordWAVEFile(DWORD dwMilliSeconds)
{
    UINT wDeviceID;
    DWORD dwReturn;
    MCI_OPEN_PARMS mciOpenParms;
    MCI_RECORD_PARMS mciRecordParms;
    MCI_SAVE_PARMS mciSaveParms;
    MCI_PLAY_PARMS mciPlayParms;
 
    /*
     * Open a waveform device with a new file for recording.
     */
    mciOpenParms.lpstrDeviceType = "waveaudio";
    mciOpenParms.lpstrElementName = "";
    if (dwReturn = mciSendCommand(0, MCI_OPEN,
            MCI_OPEN_ELEMENT | MCI_OPEN_TYPE,
            (DWORD)(LPVOID) &mciOpenParms)) {
        /*
         * Failed to open device. Don't close it; just return
         * error.
         */
        return dwReturn;
    }
 
    /* Device opened successfully. Get the device ID. */
    wDeviceID = mciOpenParms.wDeviceID;
 
    /*
     * Begin recording and record for the specified number
     * of milliseconds. Wait for recording to complete before
     * continuing. Assume the default time format for the
     * waveform device (milliseconds).
     */
    mciRecordParms.dwTo = dwMilliSeconds;
    if (dwReturn = mciSendCommand(wDeviceID, MCI_RECORD,
            MCI_TO | MCI_WAIT, (DWORD)(LPVOID) &mciRecordParms)) {
        mciSendCommand(wDeviceID, MCI_CLOSE, 0, NULL);
        return dwReturn;
    }
 
    /* Play the recording and query user to save the file. */
    mciPlayParms.dwFrom = 0;
    if (dwReturn = mciSendCommand(wDeviceID, MCI_PLAY,
            MCI_FROM | MCI_WAIT,
            (DWORD)(LPVOID) &mciPlayParms)) {
        mciSendCommand(wDeviceID, MCI_CLOSE, 0, NULL);
        return dwReturn;
    }
            HWND hMainWnd;
            hMainWnd=hwnd;
    if (MessageBox(hMainWnd, "Do you want to save this recording?",
            "", MB_YESNO) == IDNO) {
        mciSendCommand(wDeviceID, MCI_CLOSE, 0, NULL);
        return 0;
    }
 
    /*
     * Save the recording to a file named TEMPFILE.WAV. Wait for
     * the operation to finish before continuing.
     */
    mciSaveParms.lpfilename = "tempfile.wav";
    if (dwReturn = mciSendCommand(wDeviceID, MCI_SAVE,
            MCI_SAVE_FILE | MCI_WAIT,
            (DWORD)(LPVOID) &mciSaveParms)) {
        mciSendCommand(wDeviceID, MCI_CLOSE, 0, NULL);
        return dwReturn;
    }
 
    return 0;
}

0
 

Author Comment

by:logout
ID: 1177099
DWORD dwMilliSeconds is parameter.
Does that parameter need to assign a value
0
 

Expert Comment

by:dylanwolf
ID: 2297634
What's the deference between mci function and wavein function?
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

650 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