1
\$\begingroup\$

I want to start a project where i'll sample directly from the audio jack. Now i don't know what the sampling frequency should be. I don't know what is the maximum frequency of sound, i don't know it it is straight analog volumes, or if a special protocol is used.

So, anyone knows what frequency do i have to sample?

EDIT: The purpose is to record all traffic from the audio jack and store it to an SD card

\$\endgroup\$
  • \$\begingroup\$ There is no maximum frequency of sound. Humans can hear up to about 18-20kHz though. You have not described your application, the quality (and therefore the sampling rate needed) requirements, or anything else that can help us direct you to a 'solution'. Human voices for example can be sampled at 16khz because they contain useful information at up to 8kHz. If you are recording musical scores, you will want much better sampling than that! If you are playing back the sound, it's also important to know what your output frequency will be, try to match that with the input quality. \$\endgroup\$ – KyranF Oct 16 '14 at 14:19
  • \$\begingroup\$ I want to sample all the sounds that will be coming off from the audio jack. In a sense, record the music from the audio jack \$\endgroup\$ – user1584421 Oct 16 '14 at 14:40
  • 1
    \$\begingroup\$ what will you then do with the sound? what is the end goal? this is important. Please update your original question with new information as well, so others can see it more clearly \$\endgroup\$ – KyranF Oct 16 '14 at 14:47
  • \$\begingroup\$ Practically speaking, 44100 samples per second and 16 bit depth is a longstanding and useful standard. It may be overkill for your needs, but it should easily be sufficient for "audio" (vs "ultrasound") and the noise levels in a first attempt at building something like this yourself. \$\endgroup\$ – Chris Stratton Oct 16 '14 at 14:56
1
\$\begingroup\$

Nyquist showed you have to sample at a rate at least twice the highest frequency you care about. This captures the information in your signal, but also causes artifacts from the frequencies above half the sample rate to show up in your sampled signal. These are called aliases. You therefore need to first eliminate the frequencies that will cause aliases, then sample.

Since no filter has a infinitely sharp cutoff, there will be some frequency range above the highest frequency you care about and below the frequency the anti-aliasing filter attenuates enough for you to get the signal to noise ratio you care about.

Analog filters are usually fairly gentle in their falloff. One approach is to apply a slow-falloff analog filter, sample at a high rate, then digitally filter that with a sharp filter to allow re-sampling at a lower rate. That last step is often called decimation.

For example, let's say you are after good quality voice and you're highest frequency of interest is 8 kHz. You might put a two-pole R-C filter on the signal with each pole at 12 kHz. You might sample the result at 100 kHz, which means anything past 50 kHz had better be attenuated below your noise floor. The analog filter will reduce 50 kHz by 25 dB, which you decide is good enough in this case since you know there will be very little content above 50 kHz to start with.

Theoretically you can take this 100 kHz sample stream and decimate it to 16 kHz, since that's twice the highest frequency you care about. Even a sharp filter, like convolving with a 1000 point sinc, needs some room to work with. Let's say 1/2 octave (that's really sharp), so the absolute minimum sample frequency after decimation would be 23 kHz (8 kHz plus 1/2 octave is 11.3 kHz, times 2 is 22.6 kHz).

You gave no spec on what kind of sound you want to sample, so you'll have to extrapolate to your requirements on your own.

\$\endgroup\$
1
\$\begingroup\$

There is no 'just record everything' sampling frequency.

Whatever sampling frequency you choose will have an effect on the type of distortion you get in the signal you record.

However, if you're not sure then you should just go with the common standard of 44100hz. If you're interested in recording audio humans can hear, that'll cover it, and the hardware in your laptop is probably optimized for a sampling frequency similar to that.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.