modify_wav.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:AssembleAudio 作者: The-White-Wolf 项目源码 文件源码
def editScottWav(filename, edit):
    #Edits the scott file 'filename', optionally re-naming
    #the file.
    addr = {
        "note" : 369, "title" : 72, "artist" : 335, "audio_id" : 115,
        "year" : 406, "end" : 405, "intro" : 403, "eom" : 152,
        "s_date" : 133, "e_date" : 139, "s_hour" : 145, "e_hour": 146
        }

    try:
        with open(filename, 'rb+') as f:
            for name, data in edit:
                f.seek(addr[name])
                if isinstance(data, str):
                    f.write(bytes(data, 'utf-8'))
                else:
                    num_bytes = len(str(abs(data)))
                    f.write((data).to_bytes(num_bytes, byteorder='little'))

    except IOError:
        print("---EditScott cannot open {}. ---".format(filename))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号