tips
来自「linux下录音程序」· 代码 · 共 146 行
TXT
146 行
SOX usage: sox [options] from-file-args to-file-args [ effect [effect-args]]First off: the -V option makes SOX print out its idea ofwhat it is doing. -V is your friend. sox -V from-file-args to-file-argsFrom-file-args and to-file-args are the same. They are a series of options followed by a file name.The suffix on the file name usually is the file format type.The '-t xx' option overrides this and tells sox the the file format is 'xx'. The '-u/-s/-U' argumentssay that the file is in unsigned, signed, or u-law format.The '-b/-w' arguments say that the file is in byte- orword-size (2 byte) samples. The '-r number' argumentsays that the sample rate of the file is 'number'.The extensions ub, uw, sb, sw, and ul correspondto raw data files of formats unsigned byte, unsigned word, signed byte, signed word, and u-law byte.Thus, '-t ul' is shorthand for '-t raw -U -b'.These conversions clip data and thus reduce sound quality, so be careful: Word to u-law. Word to byte. U-law to byte. Reduction in sample rate.Any reduction in the sample data rate loses informationand adds noise. An increase in the data rate doesn'tlose much information, but does add noise. See thenote below on low-pass filtering.To convert U-law to something else without clipping,you'll have to convert it to (signed or unsigned) words,which will double the size of the file.AUTO files:The 'AUTO' file type reads an unknown file andattempts to discern its binary format.AIFF files:AIFF files come with complete headers and otherinfo. They can in fact have multiple soundchunks and picture chunks. SOX only readsthe first sound chunk. WAV files:WAVs use the RIFF format, which is Microsoft'sneedless imitation of AIFF. See above comments.AIFF and RIFF files need their own librarianprograms; SOX can only do a small fraction ofwhat they need.It's best if you can copy or store files inAIFF or WAV format. The sample rate and binary format are marked; also comments may be added to the file.SUN AU files:Most AU files you find are in 8khz 8-bit u-law format.This format was the first sound hardware SUN made available.Some of the files have correct headers; some do not.If the file has the header, this should convert it toanother format: sox file.au to-file-argsIf not, this reads a raw u-law 8khz file: sox -t ul -r 8000 file.au to-file-argsTo convert a file to an old-style SUN .au file: sox from-file-args -r 8000 -U -b file.auAU format can have any speed and several data sizes;you need to specify '-r 8000 -U -b' to force SOX touse the old SUN format.Mac files:Mac files come in .snd, .aiff, and .hcom formats,among others; these are the most common.SND files are in unsigned byte format with noheader. They are either 11025, 22050, or 44100 hz.The speed seems to be a "resource" and doesn'tget transported to Unix when the files are.Thus, you just have to know. sox -r 11025 -t ub file.snd to-file-args sox from-file-args -r 11025 -t ub file.sndPC files:There are several PC sound file formats. VOC iscommon; it has headers. SND and SNDR are forsome DOS sound package; I don't know much about them.WAV is the official Microsoft Windows format.WAV has format options for compressed sound;SOX doesn't implement this yet. Effects:A sound effect may be applied to the sound samplewhile it is being copied from one file to another.Copy is the default effect; i.e. do nothing.Changing the sample rate requires the 'rate'effect. This applies a simple linear interpolationto the sample. This is a poor-quality samplechanger. After doing a rate conversion,you should try doing a low-pass filter to throwaway some of the induced noise. Pick a 'center'frequency about 85% of the lower of the twofrequencies, or 42.5% of the lower of thetwo sample rates. (The maximum frequencyin a sample is 1/2 of the sample rate). sox -r 8000 file.xx -r 22050 tmp.yy sox tmp.yy file.yy lowp 3400or: sox -r 44100 file.xx -r 22050 tmp.yy sox tmp.yy file.yy lowp 9592Listen to both tmp.yy and file.yy and see if the low-pass filter helps. Be sure to do thelow-pass filter before clipping the data toa smaller binary word size. Say you have a 16-bitCD-quality (44100 hz) AIFF file that you want to convert to a Mac sound resource: sox -r 44100 file.aiff -r 11025 tmp.sw sox tmp.sw -t ub file.mac lowp 9371not: sox -r 44100 file.aiff -r 11025 tmp.ub sox tmp.ub -t ub file.mac lowp 9371because you want to do the low-pass filter while you still have sixteen-bit data.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?