Solved

WAV Compression

Posted on 1998-08-02
3
834 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
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…

776 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