MCI recording

Posted on 2000-03-28
Medium Priority
Last Modified: 2013-12-03
Im writing a program in which I want to record a 3-5 second sample with a mic and shoot it across the net.  However, it seems that the MCI API doesn't have a way of letting the programmer read the data of a recorded sample.  From what I understand, you need to use the mciSendCommand() to save the data to disk with a .wav extension, but this is something Id like to avoid.

My question is, can I access the newly recorded buffer of data without commiting it to disk?

Question by:dmaroff
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
  • 4
  • 2

Accepted Solution

nils pipenbrinck earned 400 total points
ID: 2668835
you got the point :)

you can't access the data from recorded waveforms if you use the mci api. There are two more apis that let you sample waveform, and booth offer access to the data.

The first one is the mmsystem api. You can simply open a input device with WaveInOpen and use a one of the notification mechanisms to get the data.

I usually use window messages or callback functions. It's straight forward to get a code running that samples from the mic and feeds the data into your callback..

Another option is to use directsound. You can create a IDirectSoundCapture object and use it to capture from a mic.. You can - again - get the data and process it in your code without writing it to a file first.

I would use the mmsystem api. DirectX doesn't really add functionality, and the directsound api might fail on old nt systems.

Hope this helps,

  Nils Pipenbrinck


Expert Comment

by:nils pipenbrinck
ID: 2668847
aeh.. something important:

directsound has a advantage over wavein: it has a lower latency.

DirectSound may(!) give you the sampled soundstream faster than wavein because it's closer to the hardware. On most systems directsound uses wavein internally, so there is no real difference..

Just in case latency is important for you,



Author Comment

ID: 2669785
Yea, Im working right now on using the wave API.  Its a real pain to use.  Lots of detail.  Is there a book written to help with using this API?

Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.


Expert Comment

by:nils pipenbrinck
ID: 2669857
no, but there is plenty example code if you have the full sdk or the msdn library..

It might look like a lot of work, but after all it's nothing more than 100 lines of code.. you'll do it in one day.


Author Comment

ID: 2670083
Is there a way I can set the amount of seconds of recording time I can let the waveInStart() function record for.  I noticed that the WAVEHDR structure allows you to set the max amount of data but all I really want to do in the end is record at:

8 bit sample rate * 11khz samples per second, for about 5-7 seconds.  The user will have this amount of time to talk into the mic.  

Im transferring this over the net so I want it to be small, like around 10 - 15 kilobytes tops.  Im just recording voice, so I dont need super high quality.

Also, how do I extract the data once it has been recorded?


Expert Comment

by:nils pipenbrinck
ID: 2670605
this is the wavehdr structure:

typedef struct {
    LPSTR  lpData;
    DWORD  dwBufferLength;
    DWORD  dwBytesRecorded;
    DWORD  dwUser;
    DWORD  dwFlags;
    DWORD  dwLoops;
    struct wavehdr_tag * lpNext;
    DWORD  reserved;

the data is located at lpData, and it's dwbufferLength bytes long. You can just transfer it.

btw. microsoft has a good api for sound compression built in.. maybe you should crunch the data using truespeech or so before transfering it.. acmStreamConvert in the help is a good place to start.



Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

If you have ever found yourself doing a repetitive action with the mouse and keyboard, and if you have even a little programming experience, there is a good chance that you can use a text editor to whip together a sort of macro to automate the proce…
This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

762 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