You are currently offline, waiting for your internet to reconnect
Questions about Windows 10? Click here

How To Use GSM Compression in Low-level Wave Recording

This article has been archived. It is offered "as is" and will no longer be updated.
Summary
Realtime GSM recording using the low-level waveXXX API can be accomplishedby filling in an appropriated struct and then calling waveInOpen() with theWAVE_MAPPER option so that the GSM format specified in the struct will beused.
More information
Along with the usual set of low-level waveXXX calls used in recording, andillustrated in such samples as DDREC, the code fragments shown belowprovide information on the steps needed to record audio compressed in theGSM format.

Either make the following definitions in one of the project's header filesor make sure the project has a path to an existing header file, such asMMREG.H, with these definitions. The key points here are to defineWAVE_FORMAT_GSM610 as a hexadecimal 31, and to set up a GSM structure thatconsists of a WAVEFORMATEX struct followed by a WORD:
   #define WAVE_FORMAT_GSM610 (0x0031)   typedef struct gsm610waveformat_tag   {         WAVEFORMATEX    wfx;         WORD            wSamplesPerBlock;   } GSM610WAVEFORMAT;   typedef GSM610WAVEFORMAT FAR *LPGSM610WAVEFORMAT;				
Declare a handle for memory allocation and a pointer to a GSM610WAVEFORMATstruct similar to the following:
   HANDLE hgsmwavefmt;   LPGSM610WAVEFORMAT pgsmwavefmt;				
Allocate and lock memory for the GSM610WAVEFORMAT struct similar tothe following:
   hgsmwavefmt = GlobalAlloc(GMEM_MOVEABLE,      (UINT)(sizeof(GSM610WAVEFORMAT)));   pgsmwavefmt =     (LPGSM610WAVEFORMAT)GlobalLock(hgsmwavefmt);				
Fill in the GSM610WAVEFORMAT struct's members using the values shown inassigning data to the struct's members. The exception is that pgsmwavefmt->wfx.nSamplesPerSec can be a rate other than 8000, in which casepgsmwavefmt->wfx.nAvgBytesPerSec is computed as (pgsmwavefmt->wfx.nSamplesPerSec)/320*65. When using a value for pgsmwavefmt->wfx.nSamplesPerSec other than 8000, be sure it is a multiple of the 320block size, and falls within the limits supported by the sound card. Forexample, pgsmwavefmt->wfx.nSamplesPerSec = 9920 is valid because it is amultiple of 320 and does not fall below the minimum sampling rate of 8000found on many sound cards:
   pgsmwavefmt->wfx.wFormatTag = WAVE_FORMAT_GSM610;   pgsmwavefmt->wfx.nChannels = 1;   pgsmwavefmt->wfx.nSamplesPerSec = 8000;   pgsmwavefmt->wfx.nAvgBytesPerSec = 1625;   pgsmwavefmt->wfx.nBlockAlign = 65;   pgsmwavefmt->wfx.wBitsPerSample = 0;   pgsmwavefmt->wfx.cbSize = 2;   pgsmwavefmt->wSamplesPerBlock = 320;				
Call waveInOpen() with the WAVE_MAPPER option, and be sure the thirdparameter is just the address of the GSM610WAVEFORMAT struct'sWAVEFORMATEX struct:
   waveInOpen(&hwavein, (UINT)WAVE_MAPPER,      (LPWAVEFORMATEX)&(pgsmwavefmt->wfx),      (DWORD)(UINT)hwnd, (DWORD)NULL,     CALLBACK_WINDOW);				
3.51 4.00
Properties

Article ID: 153866 - Last Review: 01/10/2015 11:04:10 - Revision: 6.0

  • kbnosurvey kbarchive kbmm KB153866
Feedback