如何在 Windows 中将 ADPCM 转换为 wav?

如何在 Windows 中将 ADPCM 转换为 wav?

我的 ADPCM 数据帧格式如下

ADPCM 的帧格式为

# byte   |   Contents
----------------------------------------------------------
0        | Encoder state: LSByte of 1st PCM value in frame
1        | Encoder state: MSByte of 1st PCM value in frame
2        | Encoder state: ADPSM step table index
3 - 258  | ADPCM encoded 16 bit PCM values

我如何在 Windows 7 中将此 ADPCM 信号解码为可听见的 .wav 格式?我试过得到解决方案对于 python 来说,但是现在我愿意做任何事情。

答案1

使用python:

import wave
import sys
import audioop
import binascii

# Get the fragments of ADPCM data:
# Here, blocks is an array of 259byte data represented as strings which is parsed
# from the ADPCM data file, write this according to the structure of your ADPCM file
block = getAdpcmFragments(adpcm_file_path)

#Set parameters for the wavefile according to your audio stream
wave_file = wave.open(wave_file_path, 'wb')
wave_file.setparams((2,2,16000, 0, 'NONE', 'NONE'))

# Using ASCII to Binary from the binascii lib to convert strings represented as e.g
# 4A, 6F etc into actual binary values. Then I am writing the linear PCM data from 
# adpcm2lin to the wav-file. 
state = None 
for this in block:
pcm, state = audioop.adpcm2lin(binascii.a2b_hex(this), 4, state)
wave_file.writeframes(pcm)

相关内容