Solved

MCI recording

Posted on 2000-03-28
6
375 Views
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?

Thanks,
-Dan
0
Comment
Question by:dmaroff
  • 4
  • 2
6 Comments
 
LVL 4

Accepted Solution

by:
nils pipenbrinck earned 100 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

0
 
LVL 4

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,

  Nils

0
 

Author Comment

by:dmaroff
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?

Thanks,
-Dan
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
LVL 4

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.

Nils
0
 

Author Comment

by:dmaroff
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?

Thanks,
-Dan
0
 
LVL 4

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;
} WAVEHDR;
 

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.

Nils

0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Suggested Solutions

zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
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…

809 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