Create audio file from samples of amplitude

随声附和 提交于 2019-12-24 04:32:42

问题


If I have a text file of sample amplitudes (0-26522), how can I create a playable audio file from them?

I have a vague recollection of tinkering with .pcm files and 8-bit samples way back in the nineties.

Is there any software to automatically create an audio file (PCM or other format) from my samples? I found SoX, but I even after looking at the documentation I can't figure out if it can do what I want, and if so how...


回答1:


GUI audio workstation called Audacity that lets you do this

File -> Import -> Raw Data

Encoding:   Signed 16-bit PCM    // even though your ints are unsigned it still works
Byte order:  little endian
Channels     1 channel mono

then just hit Import

to confirm this works, in a text editor I just did a ( cut N paste followed by select all paste,paste,paste,paste ) of below list of ints about 10 times to generate several thousand ints in a vertical column ... this is my toy input file ... after above Import just save by doing

File -> Export Audio

where you choose which output format ( mp3, aac, PCM, ...) once I did this the output mp3 is playable ... using my toy input file I did hear a sine tone

3
305
20294
11029
585
3
305
20294
11029
585
3
305
20294
11029
585


来源:https://stackoverflow.com/questions/43546491/create-audio-file-from-samples-of-amplitude

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