📄 audio.h
字号:
#ifndef __AUDIO_H__
#define __AUDIO_H__
#if 0//def WIN32
#include <windows.h>
#include <mmsystem.h>
#include <mmreg.h>
#include <msacm.h>
#endif
/***************************** Audio System *********************************/
#define WAVE_FORMAT_MEIJINLPC 0x2004 /* MEIJIN LPC Codec */
#define WAVE_FORMAT_WMA 0x0161
#if 1//ndef _WIN32
#define WAVE_FORMAT_UNKNOWN 0x0000 /* Microsoft Corporation */
#define WAVE_FORMAT_PCM 0x0001 /* Microsoft Corporation */
#define WAVE_FORMAT_ADPCM 0x0002 /* Microsoft Corporation */
#define WAVE_FORMAT_IEEE_FLOAT 0x0003 /* Microsoft Corporation */
/* IEEE754: range (+1, -1] */
/* 32-bit/64-bit format as defined by */
/* MSVC++ float/double type */
#define WAVE_FORMAT_IBM_CVSD 0x0005 /* IBM Corporation */
#define WAVE_FORMAT_ALAW 0x0006 /* Microsoft Corporation */
#define WAVE_FORMAT_MULAW 0x0007 /* Microsoft Corporation */
#define WAVE_FORMAT_OKI_ADPCM 0x0010 /* OKI */
#define WAVE_FORMAT_DVI_ADPCM 0x0011 /* Intel Corporation */
#define WAVE_FORMAT_IMA_ADPCM (WAVE_FORMAT_DVI_ADPCM) /* Intel Corporation */
#define WAVE_FORMAT_MEDIASPACE_ADPCM 0x0012 /* Videologic */
#define WAVE_FORMAT_SIERRA_ADPCM 0x0013 /* Sierra Semiconductor Corp */
#define WAVE_FORMAT_G723_ADPCM 0x0014 /* Antex Electronics Corporation */
#define WAVE_FORMAT_DIGISTD 0x0015 /* DSP Solutions, Inc. */
#define WAVE_FORMAT_DIGIFIX 0x0016 /* DSP Solutions, Inc. */
#define WAVE_FORMAT_DIALOGIC_OKI_ADPCM 0x0017 /* Dialogic Corporation */
#define WAVE_FORMAT_MEDIAVISION_ADPCM 0x0018 /* Media Vision, Inc. */
#define WAVE_FORMAT_YAMAHA_ADPCM 0x0020 /* Yamaha Corporation of America */
#define WAVE_FORMAT_SONARC 0x0021 /* Speech Compression */
#define WAVE_FORMAT_DSPGROUP_TRUESPEECH 0x0022 /* DSP Group, Inc */
#define WAVE_FORMAT_ECHOSC1 0x0023 /* Echo Speech Corporation */
#define WAVE_FORMAT_AUDIOFILE_AF36 0x0024 /* */
#define WAVE_FORMAT_APTX 0x0025 /* Audio Processing Technology */
#define WAVE_FORMAT_AUDIOFILE_AF10 0x0026 /* */
#define WAVE_FORMAT_DOLBY_AC2 0x0030 /* Dolby Laboratories */
#define WAVE_FORMAT_GSM610 0x0031 /* Microsoft Corporation */
#define WAVE_FORMAT_MSNAUDIO 0x0032 /* Microsoft Corporation */
#define WAVE_FORMAT_ANTEX_ADPCME 0x0033 /* Antex Electronics Corporation */
#define WAVE_FORMAT_CONTROL_RES_VQLPC 0x0034 /* Control Resources Limited */
#define WAVE_FORMAT_DIGIREAL 0x0035 /* DSP Solutions, Inc. */
#define WAVE_FORMAT_DIGIADPCM 0x0036 /* DSP Solutions, Inc. */
#define WAVE_FORMAT_CONTROL_RES_CR10 0x0037 /* Control Resources Limited */
#define WAVE_FORMAT_NMS_VBXADPCM 0x0038 /* Natural MicroSystems */
#define WAVE_FORMAT_CS_IMAADPCM 0x0039 /* Crystal Semiconductor IMA ADPCM */
#define WAVE_FORMAT_ECHOSC3 0x003A /* Echo Speech Corporation */
#define WAVE_FORMAT_ROCKWELL_ADPCM 0x003B /* Rockwell International */
#define WAVE_FORMAT_ROCKWELL_DIGITALK 0x003C /* Rockwell International */
#define WAVE_FORMAT_XEBEC 0x003D /* Xebec Multimedia Solutions Limited */
#define WAVE_FORMAT_G721_ADPCM 0x0040 /* Antex Electronics Corporation */
#define WAVE_FORMAT_G728_CELP 0x0041 /* Antex Electronics Corporation */
#define WAVE_FORMAT_MPEG 0x0050 /* Microsoft Corporation */
#define WAVE_FORMAT_MPEGLAYER3 0x0055 /* ISO/MPEG Layer3 Format Tag */
#define WAVE_FORMAT_CIRRUS 0x0060 /* Cirrus Logic */
#define WAVE_FORMAT_ESPCM 0x0061 /* ESS Technology */
#define WAVE_FORMAT_VOXWARE 0x0062 /* Voxware Inc */
#define WAVE_FORMAT_CANOPUS_ATRAC 0x0063 /* Canopus, co., Ltd. */
#define WAVE_FORMAT_G726_ADPCM 0x0064 /* APICOM */
#define WAVE_FORMAT_G722_ADPCM 0x0065 /* APICOM */
#define WAVE_FORMAT_DSAT 0x0066 /* Microsoft Corporation */
#define WAVE_FORMAT_DSAT_DISPLAY 0x0067 /* Microsoft Corporation */
#define WAVE_FORMAT_SOFTSOUND 0x0080 /* Softsound, Ltd. */
#define WAVE_FORMAT_RHETOREX_ADPCM 0x0100 /* Rhetorex Inc */
#define WAVE_FORMAT_CREATIVE_ADPCM 0x0200 /* Creative Labs, Inc */
#define WAVE_FORMAT_CREATIVE_FASTSPEECH8 0x0202 /* Creative Labs, Inc */
#define WAVE_FORMAT_CREATIVE_FASTSPEECH10 0x0203 /* Creative Labs, Inc */
#define WAVE_FORMAT_QUARTERDECK 0x0220 /* Quarterdeck Corporation */
#define WAVE_FORMAT_FM_TOWNS_SND 0x0300 /* Fujitsu Corp. */
#define WAVE_FORMAT_BTV_DIGITAL 0x0400 /* Brooktree Corporation */
#define WAVE_FORMAT_OLIGSM 0x1000 /* Ing C. Olivetti & C., S.p.A. */
#define WAVE_FORMAT_OLIADPCM 0x1001 /* Ing C. Olivetti & C., S.p.A. */
#define WAVE_FORMAT_OLICELP 0x1002 /* Ing C. Olivetti & C., S.p.A. */
#define WAVE_FORMAT_OLISBC 0x1003 /* Ing C. Olivetti & C., S.p.A. */
#define WAVE_FORMAT_OLIOPR 0x1004 /* Ing C. Olivetti & C., S.p.A. */
#define WAVE_FORMAT_LH_CODEC 0x1100 /* Lernout & Hauspie */
#define WAVE_FORMAT_NORRIS 0x1400 /* Norris Communications, Inc. */
#define MMSYSERR_NOERROR 0
#define MMSYSERR_ERROR 1 /* unspecified error */
#define MMSYSERR_BADDEVICEID 2 /* device ID out of range */
#define MMSYSERR_NOTENABLED 3 /* driver failed enable */
#define MMSYSERR_ALLOCATED 4 /* device already allocated */
#define MMSYSERR_INVALHANDLE 5 /* device handle is invalid */
#define MMSYSERR_NODRIVER 6 /* no device driver present */
#define MMSYSERR_NOMEM 7 /* memory allocation error */
#define MMSYSERR_NOTSUPPORTED 8 /* function isn't supported */
#define MMSYSERR_BADERRNUM 9 /* error value out of range */
#define MMSYSERR_INVALFLAG 10 /* invalid flag passed */
#define MMSYSERR_INVALPARAM 11 /* invalid parameter passed */
#define MMSYSERR_HANDLEBUSY 12 /* handle being used */
/*
* extended waveform format structure used for all non-PCM formats. this
* structure is common to all non-PCM formats.
*/
typedef struct {
WORD wFormatTag; /* format type */
WORD nChannels; /* number of channels (i.e. mono, stereo...) */
DWORD nSamplesPerSec; /* sample rate */
DWORD nAvgBytesPerSec; /* for buffer estimation */
WORD nBlockAlign; /* block size of data */
WORD wBitsPerSample; /* number of bits per sample of mono data */
} WAVEFORMAT;
typedef struct WaveHeader_t{
UINT8 RIFF[4];
UINT32 dwFileLen;
UINT8 Format[8];
UINT32 dwFormatSize;
WAVEFORMAT wfmt;
UINT8 data[4];
UINT32 dwDataLen;
} WAVEFILEHDR;
typedef struct {
WORD wFormatTag; /* format type */
WORD nChannels; /* number of channels (i.e. mono, stereo...) */
DWORD nSamplesPerSec; /* sample rate */
DWORD nAvgBytesPerSec; /* for buffer estimation */
WORD nBlockAlign; /* block size of data */
WORD wBitsPerSample; /* number of bits per sample of mono data */
WORD cbSize; /* the count in bytes of the size of */
/* extra information (after cbSize) */
} WAVEFORMATEX;
// WAVE_FORMAT_MPEGLAYER3 format sructure
//
typedef struct {
WAVEFORMATEX wfx;
WORD wID;
DWORD fdwFlags;
WORD nBlockSize;
WORD nFramesPerBlock;
WORD nCodecDelay;
} MPEGLAYER3WAVEFORMAT;
#define MPEGLAYER3_WFX_EXTRA_BYTES 12
#define MPEGLAYER3_ID_UNKNOWN 0
#define MPEGLAYER3_ID_MPEG 1
#define MPEGLAYER3_ID_CONSTANTFRAMESIZE 2
#define MPEGLAYER3_FLAG_PADDING_ISO 0x00000000
#define MPEGLAYER3_FLAG_PADDING_ON 0x00000001
#define MPEGLAYER3_FLAG_PADDING_OFF 0x00000002
#endif // _WIN32
typedef struct tagWaveFileHeader{
UINT8 RIFF[4];
UINT32 uFileLen;
UINT8 Format[8];
UINT32 uWFMT_Size;
WAVEFORMATEX wfx;
UINT8 data[4];
UINT8 uDataLen[4];
} WAVEFILEHEADER;
#define WAVEFORMATEX_MAXLEN (sizeof(WAVEFORMATEX)+34)
#define AUDIO_PLAY 0
#define AUDIO_RECORD 1
/***************************** Audio Driver *********************************/
typedef struct {
DWORD dwAudioCommand;
WAVEFORMATEX *pwfx;
VOID *dwCallback;
DWORD dwCallbackInstance;
DWORD fdwOpen;
} AUDIODS_OPEN;
/*********************** Audio Compression Manager **************************/
#if 1//ndef _WIN32
typedef void * HACMSTREAM;
typedef void * HWAVEOUT;
#define ACM_STREAMCONVERTF_BLOCKALIGN 0x00000004
#define ACM_STREAMCONVERTF_START 0x00000010
#define ACM_STREAMCONVERTF_END 0x00000020
#define ACM_STREAMSIZEF_SOURCE 0x00000000L
#define ACM_STREAMSIZEF_DESTINATION 0x00000001L
#define ACM_STREAMSIZEF_QUERYMASK 0x0000000FL
typedef struct {
DWORD cbStruct; // sizeof(ACMSTREAMHEADER)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -