Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Drawing a histogram plot  (Read 2213 times)

0 Members and 1 Guest are viewing this topic.

MarkJohnson94

  • Newbie
  • *
  • Posts: 20
    • View Profile
Drawing a histogram plot
« on: August 07, 2014, 06:09:21 pm »
Hi there,

I have been working on an audio analysis library and I am currently working on a histogram of the loudness of the audio samples for the track. I have already developed a waveform viewer that has a few hundred points which are all connected by lines and this looks very nice. However for the histogram, I would like to have hundreds of individual lines which I can set the height of to display my histogram.

Is there any nice way to do this without having to create hundreds of individual objects? I'm a bit stuck for ideas.

Thanks for any help,
Mark

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Drawing a histogram plot
« Reply #1 on: August 07, 2014, 06:12:18 pm »
Creating a few hundred objects - one for each column in the histogram seems like the simplest and easiest solution to me. Nothing more than a basic loop and a few calculations. What don't you like about that approach?

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Drawing a histogram plot
« Reply #2 on: August 07, 2014, 06:39:17 pm »
I would suggest using a VertexArray, probably the same way your waveform viewer did (mine did).
Remember to use Lines (not LinesStrip) as the primitive type so that each pair of vertices define the line.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

MarkJohnson94

  • Newbie
  • *
  • Posts: 20
    • View Profile
Re: Drawing a histogram plot
« Reply #3 on: August 11, 2014, 03:00:26 pm »
Perfect. Jesper I understand your approach is probably better and thanks for the reply, I just wanted to know if there was a simple line or two of code that I could use to achieve the effect I needed, and using Lines not LinesStrip works great, so thanks Hapax.

 

anything