Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. finding Audio Level

finding Audio Level

Scheduled Pinned Locked Moved C / C++ / MFC
questiontutorial
8 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    atimpoo
    wrote on last edited by
    #1

    Hi All, Can anyone know how to find the audio level from the microphone? Basically I want to splitup the audio level from no audio(if the person is silent) to very high level... How can i get the frequency?? Thanks, Poornima

    N R N 3 Replies Last reply
    0
    • A atimpoo

      Hi All, Can anyone know how to find the audio level from the microphone? Basically I want to splitup the audio level from no audio(if the person is silent) to very high level... How can i get the frequency?? Thanks, Poornima

      N Offline
      N Offline
      Nishad S
      wrote on last edited by
      #2

      Have a look at http://www.codeproject.com/audio/waveInFFT.asp[^] - NS -

      1 Reply Last reply
      0
      • A atimpoo

        Hi All, Can anyone know how to find the audio level from the microphone? Basically I want to splitup the audio level from no audio(if the person is silent) to very high level... How can i get the frequency?? Thanks, Poornima

        R Offline
        R Offline
        Remco Hoogenboezem
        wrote on last edited by
        #3

        Hello Poornima, You could also try the FFTW subroutine library. The functions are easy to use and competitive with vendor tuned code. :) http://www.fftw.org/

        A 1 Reply Last reply
        0
        • R Remco Hoogenboezem

          Hello Poornima, You could also try the FFTW subroutine library. The functions are easy to use and competitive with vendor tuned code. :) http://www.fftw.org/

          A Offline
          A Offline
          atimpoo
          wrote on last edited by
          #4

          Thanks a lot for the guidance. :)

          1 Reply Last reply
          0
          • A atimpoo

            Hi All, Can anyone know how to find the audio level from the microphone? Basically I want to splitup the audio level from no audio(if the person is silent) to very high level... How can i get the frequency?? Thanks, Poornima

            N Offline
            N Offline
            normanS
            wrote on last edited by
            #5

            What do you want - audio level (volume) or audio tone (frequency) or both? FFT will give you frequency and a volume-related value at each frequency. If you want only volume, you could calculate an average peak-to-peak value for some period as an estimate.

            A 1 Reply Last reply
            0
            • N normanS

              What do you want - audio level (volume) or audio tone (frequency) or both? FFT will give you frequency and a volume-related value at each frequency. If you want only volume, you could calculate an average peak-to-peak value for some period as an estimate.

              A Offline
              A Offline
              atimpoo
              wrote on last edited by
              #6

              Hey, I dont understand your question...:( Frequncy and volume are interelated rite... I mean frequency directly proportional to audio ??? do clear me If i am wrong.

              N 2 Replies Last reply
              0
              • A atimpoo

                Hey, I dont understand your question...:( Frequncy and volume are interelated rite... I mean frequency directly proportional to audio ??? do clear me If i am wrong.

                N Offline
                N Offline
                normanS
                wrote on last edited by
                #7

                Volume is how loud the sound is (a soft sound, like someone wispering, has low volume, a loud sound, like a fighter aircraft engine, has high volume.) Frequency is the pitch or tone of a sound - a double bass plays notes which have a low frequency (a low cycle per second or Herz value) while a penny whistle plays notes which have a high frequency. The frequency and the volume of a sound are not really related, although human perception does come into it. The normal PC software volume control only controls volume, it does not affect frequency. From your original question, I think you were trying to decide whether a sound was soft or loud, i.e. volume. My point was that you should be able to determine this in a simpler way than doing an FFT.

                1 Reply Last reply
                0
                • A atimpoo

                  Hey, I dont understand your question...:( Frequncy and volume are interelated rite... I mean frequency directly proportional to audio ??? do clear me If i am wrong.

                  N Offline
                  N Offline
                  normanS
                  wrote on last edited by
                  #8

                  Let's say you have a block of audio data from the microphone (you could use the WaveIn functions - see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/multimed/htm/_win32_waveform_functions.asp[^] .) The data block has a number of characteristics which you specify, such as block length (50 or 100 milliseconds is reasonable), sampling rate (22 kHz should be OK), sample size (8 or 16 bit per sample), stereo or mono (microphone is probably mono.) The general procedure I would follow would be:

                  Long SumOfSamples = 0
                  Long SumOfSquaredDifferences = 0

                  // First determine the average sound level
                  // I don't know whether audio data is represented as unsigned or signed values -
                  // you may have to look at the values in a data block to decide what to use!
                  For count = 1 to numberSamplesInBlock
                  SumOfSamples += soundSample[count]

                  AverageSoundLevel = SumOfSamples / numberSamplesInBlock

                  // Now work out the average of how far every sample is from the average level
                  For count = 1 to numberSamplesInBlock
                  ThisSampleDifference = sample[count] - AverageSoundLevel
                  SumOfSquaredDifferences += ThisSampleDifference * ThisSampleDifference

                  AverageDifference = SquareRoot(SumOfSquaredDifferences) / numberSamplesInBlock

                  // Now decide whether the data block is loud or soft or in-between
                  If AverageDifference < softSoundThreshold
                  Display "The Sound Is Soft"
                  Else if AverageDifference > loudSoundThreshold
                  Display "The Sound Is Loud"
                  Else
                  Display "The Sound Is Between Soft And Loud Limits"

                  // Determine the softSoundThreshold and loudSoundThreshold by recording
                  // sounds using the microphone and looking at their AverageDifference values

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups