Solved

MCI recording

Posted on 2000-03-28
6
379 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
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
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…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

730 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