wav file manupalation

孤者浪人 提交于 2019-12-08 06:36:03

问题


I want get the details of the wave such as its frames into a array of integers. Using fname.getframes we can ge the properties of the frame and save in list or anything for writing into another wav or anything,but fname.getframes gives information not in integers some thing like a "/xt/x4/0w' etc..

But i want them in integer so that would be helpful for manupation and smoothening join of 2 wav files


回答1:


I don't know what library you're using, but it looks like it's probably returning a string of bytes. To get it into a list of integers, you could do something like this:

data = [ord(character) for character in data]

To convert it back, you could do something like this:

data = ''.join(chr(character) for character in data)



回答2:


If you need to convert the frame data into integers, you can create an array.array('h') (array of signed 16-bit words) and load it from the frame data using its .fromstring or .fromfile methods.

However, I'm almost sure that you can keep the frame data as they are, and manipulate them using functions in the audioop module.




回答3:


NumPy can load the data into arrays for easy manipulation. Or SciPy. I forget which.



来源:https://stackoverflow.com/questions/3021046/wav-file-manupalation

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!