Solved

MCI recording

Posted on 2000-03-28
6
369 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
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…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

895 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

18 Experts available now in Live!

Get 1:1 Help Now