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. How to get the total time of the wav file.

How to get the total time of the wav file.

Scheduled Pinned Locked Moved C / C++ / MFC
6 Posts 2 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.
  • D Offline
    D Offline
    Deepu Antony
    wrote on last edited by
    #1

    Hi all How to get the total time of a wav file. Please help me

    D 1 Reply Last reply
    0
    • D Deepu Antony

      Hi all How to get the total time of a wav file. Please help me

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      Perhaps looking through the WAV format[^] would be of help, or maybe a quick search[^].

      "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

      "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

      D 1 Reply Last reply
      0
      • D David Crow

        Perhaps looking through the WAV format[^] would be of help, or maybe a quick search[^].

        "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

        "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

        D Offline
        D Offline
        Deepu Antony
        wrote on last edited by
        #3

        Thanks for the reply If i am having the forumala Sampling rate * Bits Per Sample * Channels)/(Bits Per Byte) = Bytes Per Second. eg If we are playing audio at 44,100Hz and we have 16 bit audio and 2 channels, Collapse (44100 * 16 * 2)/8 = 176400 Bytes Per Second Is there is any use. I can read the file size also from the header. But what i actually need is the total time of the wav file.From header data, Is there is any method for calculating this or Is there is any MFC classes for handling multimedia so that i can use any functions for getting the time period.

        D 1 Reply Last reply
        0
        • D Deepu Antony

          Thanks for the reply If i am having the forumala Sampling rate * Bits Per Sample * Channels)/(Bits Per Byte) = Bytes Per Second. eg If we are playing audio at 44,100Hz and we have 16 bit audio and 2 channels, Collapse (44100 * 16 * 2)/8 = 176400 Bytes Per Second Is there is any use. I can read the file size also from the header. But what i actually need is the total time of the wav file.From header data, Is there is any method for calculating this or Is there is any MFC classes for handling multimedia so that i can use any functions for getting the time period.

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          Deepu Antony wrote:

          Is there is any use.

          :confused: I believe the formula is: FileSize / (SampleRate * BytesPerSample)

          "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

          "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

          D 2 Replies Last reply
          0
          • D David Crow

            Deepu Antony wrote:

            Is there is any use.

            :confused: I believe the formula is: FileSize / (SampleRate * BytesPerSample)

            "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

            "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

            D Offline
            D Offline
            Deepu Antony
            wrote on last edited by
            #5

            That information i got from code project article [^]

            1 Reply Last reply
            0
            • D David Crow

              Deepu Antony wrote:

              Is there is any use.

              :confused: I believe the formula is: FileSize / (SampleRate * BytesPerSample)

              "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

              "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

              D Offline
              D Offline
              Deepu Antony
              wrote on last edited by
              #6

              Thanks for giving your time.It was very easy. The only thing has to do is to get the length of file name and divide it by bytes per second. int length =file.GetLength()-44;//Header size int dwTotSeconds =length/16000; //16000 bytes per second.

              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