Solved

WAV Compression

Posted on 1998-08-02
3
840 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

If you have ever found yourself doing a repetitive action with the mouse and keyboard, and if you have even a little programming experience, there is a good chance that you can use a text editor to whip together a sort of macro to automate the proce…
This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
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…

733 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