把双声道alaw编码文件拆分为两个单声道PCM文件

 #include <stdio.h>
#include <string.h>
#include <sys/stat.h>

typedef unsigned short uint16;
typedef unsigned int uint32;

#pragma pack(push, 1)

// pcm文件头
typedef struct
{
    uint32 ChunkID;             //00H 4 char "RIFF"标志
    uint32 ChunkSize;           //04H 4 long int 文件长度 文总长-8
    uint32 Format;              //08H 4 char "WAVE"标志
    uint32 SubChunk1ID;         //0CH 4 char "fmt "标志
    uint32 SubChunk1Size;       //10H 4 0x10000000H(PCM)过渡字节(不定)
    uint16 AudioFormat;         //14H 2 int 格式类别(0x01H为PCM形式的声音数据) 0x0100H
    uint16 NumChannels;         //16H 2 int 通道数,单声道为1,双声道为2
    uint32 SampleRate;          //18H 4 int 采样率(每秒样本数),表示每个通道的播放速度,
    uint32 ByteRate;            //1CH 4 long int 波形音频数据传送速率,其值Channels×SamplesPerSec×BitsPerSample/8
    uint16 BlockAlign;          //20H 2 int 数据块的调整数(按字节算的),其值为Channels×BitsPerSample/8
    uint16 BitsPerSample;       //22H 2 每样本的数据位数,表示每个声道中各个样本的数据位数。如果有多个声道,对每个声道而言,样本大小都一样。
    uint32 DataTag;               //24H 4 char 数据标记符"data"
    uint32 DataLen;                            //28H 4 long int 语音数据的长度(文长-44)
}PCM_HEAD, *PPCM_HEAD;

// a-law文件头 size:44
typedef struct
{
    uint32 ChunkID;             //00H 4 char "RIFF"标志
    uint32 ChunkSize;           //04H 4 long int 文件长度 文总长-8
    uint32 Format;              //08H 4 char "WAVE"标志
    uint32 SubChunk1ID;         //0CH 4 char "fmt "标志
    uint32 SubChunk1Size;       //10H 4 0x12000000H(ALAW)
    uint16 AudioFormat;         //14H 2 int 格式类别 0x0600H
    uint16 NumChannels;         //16H 2 int 通道数,单声道为1,双声道为2
    uint32 SampleRate;          //18H 4 int 采样率(每秒样本数),表示每个通道的播放速度,
    uint32 ByteRate;            //1CH 4 long int 波形音频数据传送速率,其值Channels×SamplesPerSec×BitsPerSample/8
    uint16 BlockAlign;          //20H 2 int 数据块的调整数(按字节算的),其值为Channels×BitsPerSample/8
    //uint16 BitsPerSample;       //22H 2 每样本的数据位数&#
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值