could not render this.
This page should probably be re-written, broken down into sub-pages, cleaned up, etc. Anyone want to do it? Go ahead! SOUNDFILE CONVERSION Changing a soundfile to a different sample rate or bit depth while maintaining maximum quality is not necessarily easy. The general principles have nothing to do with Linux specifically, and can be found elsewhere on the 'net, so I'll summarize: 1.Keep the bit depth as high as possible for as long as possible in your processing chain. If you're going to end up with the usual 16-bit integers, use more resolution than that for everything up to the very end; long ints, floats, doubles, whatever. This strategy will reduce re-quantization noise. 2.When you do eventually go to a lower bit depth (e.g. converting 16-bit to 8-bit), consider adding dither. Dither is a very small amount of random noise that masks uglier quantization noise and, oddly enough, improves the perceived resolution (so you can actually hear stuff happening below the lowest bit, like reverb tails). Doing (Sox can now do some kind of dithering with its mask effect; please note that I have not really tested it and have no idea how good it is. Anyone?) 3.Stick to sampling rates that are integer multiples of the rate you want to end up with. For example, don't sample at 48 kHz of 96 kHz if you're going to end up at 44.1 kHz; just work at 44.1 or consider going up to 88.2 kHz ... unless you trust the tool you use for sample rate conversion to do a really really good job. While the higher sample rate gives you more treble to work, and gives you some headroom against aliasing if you're doing digital synthesis, the problem is that if you have to downsample to your final product by a non-integer amount, there will be lots of interpolation and filtering of some kind going on, and some people say that's worse than just starting with the final sample rate. Your mileage may vary. Another situation in which people like using 48 kHz is when the signal will go through some analog processing (such as mastering with expensive tweaked-out vintage compressors or some such) before the final 44.1 kHz product, in which case digital resampling is not an issue and some people think that initially working at 48 kHz is a bit better than 44.1. 4.To avoid aliasing, filter out everything above the Nyquist frequency before downsampling (or make sure your resampling tool does this for you). The Nyquist frequency is 1/2 the sampling rate you want to end up with. For instance, before converting 44.1k to 22.05k, filter out everything above 11.025k. 5.Don't normalize all the time! If you need a normalized signal, normalize once AFTER you've done everything else, just before converting to the final output bit depth. (That's assuming your signal is floating-point up until the very end; if your signal must become an integer at some point, you may need to tweak levels to get the most resolution from the integer samples.) This strategy will help reduce unnecessary re-quantization noise. One place to get more information is the rec.audio.pro FAQ at http://www.cs.ruu.nl/wais/html/na-dir/AudioFAQ/pro-audio-faq.html. Another great source of information on digital audio, with articles on many topics including normalization and dithering, is the Digital Domain site at www.digido.com/. Most of the information in this section was cribbed from those sources. The ubiquitous tool for these jobs on Unix systems is SoX. SoX is at: http://home.sprynet.com/~cbagwell/sox.html SoX works, but you need a recent version. Early versions of SoX had a reputation for poor sample-rate conversion. This has been addressed. Also, there are now alternatives to SoX - see Joachim Thiemann's note about AFsp below. As of now (September 2000), SoX version 12.17 supports three methods of sample rate conversion. It's important to use the right one. Synopsis (as of SoX 12.16 - I haven't checked out 12.17 yet): linear is fastest, and worst sounding (lots of aliasing). resample is probably best-sounding. Old bugs in resample seem to have been removed in version 12.16 and further improvements were made in 12.17. polyphase is slowest, and not generally as accurate as resample, but has been improved in version 12.17. Sox now also provides simple 1/2 bit dithering via the mask effect. Noise-shaped dithering is not currently an option. (To learn more than you ever wanted to know about dither, do a dejanews search for dither in rec.audio.pro.) Joachim Thiemann <joachim_AT_tspece.mcgill.ca> wrote to complain that SoX did not handle some soundcard sampling rates well because the soundcard gives a sampling rate that is several percent off from the requested rate and SoX would resample it poorly. Chris Bagwell, maintainer of SoX, reports that this has been fixed in SoX 12.17 (September 2000) so all SoX users should upgrade! Anyway, here's Joachim's original complaint (from 1999) and his own solution: "...The solution to the problem is to either resample the file to a "nice" division of 44.1kHz, like 22050Hz or 11025Hz, or to simply play the 8kHz file at 8018Hz rate - the <0.225% difference in playback speed is not perceptible. For the latter solution I had to write my own replacement for "play" (<100 lines of C)." " --- The following is a blatant plug for our own software :-) We here at the McGill signal processing lab have our own Audio processing code - see http://www.tsp.ece.mcgill.ca/software/index.html - which allowed me to write the above replacement for "play" in so little code. Also, the ResampAudio utility (part of the AFsp package) does a _much_ better job at resampling than Sox does (and we can prove it, too! ;-)"
This page has been write-protected for site robustness
See
HowDoIEdit
or
TextFormattingRules
for more help
(login required)