Jump to content

Recommended Posts

Posted (edited)

Waveform.thumb.png.b1d0a6168268c476c4eb32fc98c2cf7c.png

This is an update or derivative work of Beege 's Scrolling Line Graph UDF

https://www.autoitscript.com/forum/topic/109599-scrolling-line-graph-udf

 

I noticed a few issues for my use case with the UDF one being that adding a sample required updating the waveform

High CPU usage went hand in hand with that requirement

Another issue was just how long updating took to complete

I've hopefully rectified that with this version

 

There are a few changes (only 1 line per graph for instance)

  • The addition of a function AddSample (uses graphics paths to speed up drawing samples on update)
  • Gridlines are only generated once
  • A sample finished line can be added
  • UpdateGraph allows you to compress the discarded portion of the graph (it looks kinda cool but uses more CPU)
  • Lower Cpu usage
  • Uses real Control Ids - it is a label control underneath so you get click events and can display text when control is disabled

Example (Waveform.au3)

  Reveal hidden contents

 

Example 2 (peak.au3)

  Reveal hidden contents

UDF

  Reveal hidden contents

Updated:

Previous Downloads [38 / 38/ 0]

SSLG.au3Fetching info... waveform.au3Fetching info... Peak.au3Fetching info...

Edited by Bilgus
Add screenshot, Update Code, Update Code, Update Code
Posted (edited)

Since I have this extra post here I'll go into some of the details

As you recall (or maybe you have no idea) Begee's original code only updated one point on each graph redraw

This lead to some pretty high CPU usage if you wanted to add lots of points

My idea was to allow adding multiple points before redrawing the graph.......

  Reveal hidden contents

 

Edited by Bilgus
updates
Posted (edited)

Code In first post updated

  • Grids are now scaled to proper size 
  • Got rid of CloneBitmap on every graphics update (far less page faults now)
  • Allow use of ARGB for colors or RGB
  • Faster redraw (~10-20 ms) 
  • Y coords are now scaled using GDI+
  • Option to fill bottom portion of graph - Fixed scaling issue
Edited by Bilgus
Posted

I noticed that my control flickers a lot more than his original 

I removed the BitBlt calls in favor of the GDI+ DrawImage so I could get rid of creating a new HBitmap each update

Looks to me like BitBlt does a better job

I'll upload a version fixing this issue and still without creating a new HBitmap in a day or two

Why am I trying to keep from creating a new bitmap each update you ask?

-- PageFaults --

While they are soft pagefaults it still means the program is churning memory so I want to try and decrease as much as possible

The other advantage is lower memory and processor usage

 

Oh I also have added the ability to resize the control now

It just deletes the old buffers and recreates them but it works :)

Posted

SSLG code has been updated

Turns out BitBlt is faster than _GDIPlus_DrawImage even after you do an extra copy to a GDI HBitmap

Weird, Never would have guessed...

  • BitBlt used for final drawing to control
  • Added ability to resize the graph on window resize (try it in the example)
  • SSLG is much more well behaved after this update
  • There are now two buffers that get swapped every other graph update this gets us a free copy of the last image
  • Grid lines resize automatically on control resize
  • All sample scaling now handled with graphics path

GDI+ has a lot of heap allocated memory behind the scenes about the only thing that still has a lot of allocations in SSLG

is when you enable bCompress for the old samples otherwise you should see very few page faults

Posted (edited)

Well I added another example peak.au3 it uses the Windows sound AudioMeterInfo.GetPeakValue code and displays it in a SSLG graph

See for Trancex's original code: https://www.autoitscript.com/forum/topic/142523-master-loudnessvolume-via-peak-meter-windows-7-64-bit/?tab=comments#comment-1003940

 

Unfortunately I found a few more bugs which are (fortunately) now fixed

  • AddSample did not check if UpdateGraph was currently running causing the graph to be cleared
  • If Grid was enabled SetResizeGraph did not draw new gridlines after the resize
  • Couple of error numbers were changed to match between AddSample and UpdateGraph
  • Increments are now recalculated after IncrementsSize is calculated

 

 

Edited by Bilgus

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...