Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi all,
Vanilla are planning an update to the site on April 24th (next Wednesday). It is a major PHP8 update which is expected to boost performance across the site. The site will be down from 7pm and it is expected to take about an hour to complete. We appreciate your patience during the update.
Thanks all.

How sampling works?

Options
  • 08-04-2015 8:56pm
    #1
    Registered Users Posts: 673 ✭✭✭


    I'm trying to generate high frequencies in an android app and could do with some help. I've set the sample rate to 44100 and three frequencies to 2,000, 35,000 and 55,000. Although its emitting a high pitched tone, its very audible.

    I've increased the sample rate to 48000 but any higher and the app crashes. I don't think it's hardware limitations.


Comments

  • Registered Users Posts: 743 ✭✭✭KeithTS


    So you're attempting to output 2k, 33k and 55k tones?
    Theoretically the highest frequency which can be represented is 1/2 of the sample rate.

    So, if you have a 44kHz sample rate, the highest tone you can generate is 22kHz.

    If you're generating higher frequencies than allowed aliasing will occur. The high pitch you hear is probably the 33kHz being heard as an 11kHz tone.

    Out of interest, what other sample rate are you trying?


  • Registered Users Posts: 673 ✭✭✭Marsden


    I tried a load at this stage Kieth, I read about the sample rate needing double the frequency so jumped up to 110k then noticed there was no sound. I went back and forth on a load of different hz till I realized sound just disappeared when the sample was > 48k. So 48 I could still hear all three but 48,001 they all just disappeared, then the app will crash.

    If I'm right about setting the sample at 110kHz and the other frequencies as they were then it must be something in the android API I'm doing wrong. I know there's a way to generate this frequency on a phone but thought maybe I had the calculations wrong.


  • Registered Users Posts: 743 ✭✭✭KeithTS


    Well there's a couple of things here, the sample rate will be configured somewhere in hardware, whether it's the processor or DSP really depends on the hardware. A frequency will be generated from an oscillator, then any clocks etc. are typically derived using this. The norms are 44.1kHz and 48kHz. You can't just pick an arbitrary value, there are set values used depending on the device.

    The newer versions (5.0 and up) support 96kHz but the older versions do not afaik.

    How do you know there is a way to generate the 55kHz on a phone? What is the aim of the project?

    Just for the record, although the theory states that the max frequency is half of the sampling rate, in practice a ratio of 1/2.2 or therebouts is used. You'd never really aim for the maximum value in a system so in a 44.1kHz system you'd typically set the maximum frequency as 20kHz and not 22.5kHz.


  • Registered Users Posts: 1,621 ✭✭✭Turbulent Bill


    Remember that the maximum human-audible frequency is about 20kHz (hence the use of 44 and 48kHz sampling), I assume you're using an instrument to detect the generated tone?


Advertisement