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. Plotting the wav file

Plotting the wav file

Scheduled Pinned Locked Moved C / C++ / MFC
4 Posts 3 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.
  • M Offline
    M Offline
    Maynka
    wrote on last edited by
    #1

    Hi, I am trying to plot the wavform of wav file.In my case the wavfile consists of 6112 samples and having 8 bits per sample.byterate is 4395 bytes /s.Roughly it is equal to about 1.39 seconds of sample data.I want to plot this giving time on x axis and the sample amplitude on y axis. I am not able to normalize such that 6112 samples can be represented on the scale of 0 to 1.39 seconds.Any hints or suggestions are welcome. Regards, Mayank

    J C 2 Replies Last reply
    0
    • M Maynka

      Hi, I am trying to plot the wavform of wav file.In my case the wavfile consists of 6112 samples and having 8 bits per sample.byterate is 4395 bytes /s.Roughly it is equal to about 1.39 seconds of sample data.I want to plot this giving time on x axis and the sample amplitude on y axis. I am not able to normalize such that 6112 samples can be represented on the scale of 0 to 1.39 seconds.Any hints or suggestions are welcome. Regards, Mayank

      J Offline
      J Offline
      jhwurmbach
      wrote on last edited by
      #2

      What exactly is your problem? To calculate the X (-time) axis of the spectrum from the sample rate and the sample number? time = samplerate * sampleno


      Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal.
      George Orwell, "Keep the Aspidistra Flying", Opening words

      1 Reply Last reply
      0
      • M Maynka

        Hi, I am trying to plot the wavform of wav file.In my case the wavfile consists of 6112 samples and having 8 bits per sample.byterate is 4395 bytes /s.Roughly it is equal to about 1.39 seconds of sample data.I want to plot this giving time on x axis and the sample amplitude on y axis. I am not able to normalize such that 6112 samples can be represented on the scale of 0 to 1.39 seconds.Any hints or suggestions are welcome. Regards, Mayank

        C Offline
        C Offline
        carrivick
        wrote on last edited by
        #3

        To plot this properly you need to establish the range of values represented by each x-axis pixel and then plot a vertical line. Unless the plot area allows more than one pixel per sample. struct Plot { int y_min; int y_max; } samples_per_xaxis_pixels = number_of_samples / display_width; Plot * plot_array = new Plot[ display_width / number_of_samples ]; for(int x=0,i=0;xplot_array[i].y_max?samples_array[x]:plot_array[i].y_max; } } And then plot it !

        M 1 Reply Last reply
        0
        • C carrivick

          To plot this properly you need to establish the range of values represented by each x-axis pixel and then plot a vertical line. Unless the plot area allows more than one pixel per sample. struct Plot { int y_min; int y_max; } samples_per_xaxis_pixels = number_of_samples / display_width; Plot * plot_array = new Plot[ display_width / number_of_samples ]; for(int x=0,i=0;xplot_array[i].y_max?samples_array[x]:plot_array[i].y_max; } } And then plot it !

          M Offline
          M Offline
          Maynka
          wrote on last edited by
          #4

          Hi, Thanks for your reply.Actually in my case the samples=6112(with wach sample amplitude value between 0 and 255) and on x axis i have to represent these 6112 samples in a total of 1.39 seconds.Roughly if i divide x axis into parts of 100 ms then there are 13 such parts in which i have to divide 6112 samples,so if the display_width in the above case comes out to be 13 . Thanks and Regards, Mayank

          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