(原创)多个pcm文件合并成烧录文件

多个pcm文件合并成烧录文件:

import os

basePath = "C:/Users/36459/Desktop/48kHz_16bit/"
pcmList = []
for file in os.listdir(basePath):
    if file.endswith(".pcm"):
        pcmList.append(file)

pcmList.sort(key=lambda name:int(name.split("_")[0]))

offset = 0
with open(file=basePath+"total.txt",mode='w') as totalTxt:
    with open(file=basePath+"total.bin",mode='wb') as totalPcm:
        for pcmFile in pcmList:
            with open(file = basePath+pcmFile,mode = 'rb') as pcm:
                length = pcm.seek(0,os.SEEK_END)
                pcm.seek(0,os.SEEK_SET)
                totalPcm.write(pcm.read(length))
                print(f"file:{pcmFile} start:{offset} end:{length}",file = totalTxt)
                offset+=length

知识共享许可协议
本作品采用知识共享署名-非商业性使用 4.0 国际许可协议进行许可。

站内搜索

    撩我备注-博客

    joinee

    目录结构