Solved

MCI recording

Posted on 2000-03-28
6
366 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 4

Expert Comment

by:nils pipenbrinck
Comment Utility
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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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.…
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…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

763 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

7 Experts available now in Live!

Get 1:1 Help Now