Solved

WAV Compression

Posted on 1998-08-02
3
827 Views
Last Modified: 2013-12-03
I used this call to open a MM handle for sample recording

WAVEFORMATEX wINEX;
WAVEIN wIN;

   wINEX.wFormatTag = WAVE_FORMAT_PCM;
      wINEX.nChannels = 2;
      wINEX.nSamplesPerSec = 16000;
      wINEX.wBitsPerSample = 8; //  8,16
      wINEX.nBlockAlign = (wINEX.wBitsPerSample * wINEX.nChannels) / 8;
      wINEX.nAvgBytesPerSec = wINEX.nSamplesPerSec * wINEX.nBlockAlign;
      wINEX.cbSize = 0;

      f = waveInOpen(
                  &wIN,
                  WAVE_MAPPER,
                  &wINEX,
                  (unsigned long)waveInProc,
                  0,
                  CALLBACK_FUNCTION);

I decided to use ADPCM for a better compression , but if I select WAVE_FORMAT_ADPCM to wFormatTag , the waveInOpen returns an error code : 32 . What's happening ?

And of course , if you have a suggestion for a better compression , tell me .

Thanks
0
Comment
Question by:WxW
  • 2
3 Comments
 
LVL 23

Accepted Solution

by:
chensu earned 10 total points
ID: 1412917
You need to set the WAVEFORMATEX properly. For example,

// Format Tag: WAVE_FORMAT_ADPCM
// Channels: 1
// Samples Per Second: 11,025
// Avg Bytes Per Second: 5,666
// Block Alignment: 256
// Bits Per Sample: 4
// Extra Format Information: 32 bytes
// Offset Data Bytes
   0xF4, 0x01, 0x07, 0x00, 0x00, 0x01, 0x00, 0x00,
   0x00, 0x02, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00,
   0xC0, 0x00, 0x40, 0x00, 0xF0, 0x00, 0x00, 0x00,
   0xCC, 0x01, 0x30, 0xFF, 0x88, 0x01, 0x18, 0xFF

You may use an utility to convert a PCM wave file to an ADPCM wave file. Then, use the RiffWalk utility (it comes with the Platform SDK) to see its header information.

0
 
LVL 6

Author Comment

by:WxW
ID: 1412918
Thanks chensu . But tell me . 1st. How I calculate the variables of WAVEFORMATEX because when specifying for example 8000 hz , it is not working . 2nd From where I get the extra bytes values ?
0
 
LVL 23

Expert Comment

by:chensu
ID: 1412919
You can find the specification in MSDN Library on MSDN CDs or online (http://www.microsoft.com/msdn).

Microsoft Developer Network\Tools and Technologies\Multimedia Standards Update\New Multimedia\Document\Data Types and Data Techniques\New WAVE Types
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

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.…
With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
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…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

706 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