Anyone have any ideas? Any way take care eveyone...

Moderators: Chuckt, Garth, bitfogav
Some toys have only two-bit samples and very low sampling rates and inadequate anti-alias filters (or none at all). If the dynamic range is super compressed (like AM radio is), you can get good voice intelligibility with only two bits. For what you're doing, you might want 4 or 6 bits, so you can get three or four samples in two bytes' storage with decent sound quality. Of course sampling rate is another consideration, separate from number of bits; but with good anti-alias filters, you can probably get by just fine with 6,000-8,000 samples per second. You could oversample and do some of the anti-alias filtering in software to make the hardware filters' requirements a little less stringent if desired. I'm doing that on the project mentioned above, sampling 24,000 times a second with the PIC's 8-bit A/D converter and averaging each set of four samples to record only 6,000 samples for second (for voice, not music) in the flash, and then upon playback, interpolating the oversamples and putting out 24,000 a second again, using the PIC's PWM output.How many samples do I need? and Do I need smoothing to produce a clean waveform? The answer might surprise you. Let's say you try to synthesize a sine wave with only 32 samples per cycle, or 8 samples per quarter cycle (90°). With no filtering, the first major harmonic distortion products will be the 31st and 33rd harmonics, down about 30dB from the fundamental. IOW, for a fundamental frequency above 600Hz, these will be out of the hearing range. The hottest harmonic distortion product below that is the 5th harmonic at about 54dB down from the fundamental. For a 16-sample sine wave, ie, only 4 samples per 90° (does that seem atrocious?), the first major harmonic distortion products are the 15th and 17th harmonics, down about 24db below the fundamental. The hottest harmonic distortion product below that is the 7th harmonic, at about 55dB down from the fundamental. If you go up to 64 samples per cycle, which is 16 samples per 90°, the first major harmonic distortion products are the 63rd and 65th harmonics at about 36dB below the fundamental. If you want to filter it, it will be easy, not requiring a many-order brick-wall filter, as long as you're not nearing the Nyquist frequency.
How many bits do I really need? As mentioned above, an 8-bit converter can theoretically reach a SNR of 50dB when signal is present, and have an output as quiet as that of a 24-bit converter if there's no signal, since the number won't be changing. There were some fine-sounding music cassette tapes before CDs took over, and their SNR was virtually no better than what an 8-bit converter can give you; yet the cassettes' frequency response and distortion at high record levels were quite inferior to what you can get with a good 8-bit converter and adequate sampling rate! I know it's unlikely anyone will ever use 8-bit recording for music for enjoyment, but this might put things in perspective. For things like machine control and measurements in test equipment, you will have to determine how accurate you need them, and whether external scaling and offsets will let you get by with fewer bits than you might think. There is some discussion of this in the first quarter of the front page about large look-up tables for hyperfast, accurate, 16-bit scaled-integer math. I'm definitely not against using converters of 12, 14, 16, or more bits when they are right for the application (in fact, I'm about to start shopping for a multi-channel SPI A/D of at least 12 bits), but I always like to point out what might be a pleasant unexpected discovery of what can be done with less.
Users browsing this forum: No registered users and 4 guests