Click here to Skip to main content
Click here to Skip to main content

Analog and LED Meter

, 10 Sep 2009 CPOL
Rate this:
Please Sign up or sign in to vote.
VU or Level meter, LED or Analog display
Sample Image - VuMeter_Demo.jpg

Introduction

I've been searching a lot for an easy to use VU meter to use in a simple Audio player/recorder, but I haven't been lucky. I found some samples of LED meters, but not quite what I wanted.

It's good that I'm a bit stubborn, but unfortunately I'm also a complete beginner in C#, but that is the language I want to learn so I started my little project 2 weeks ago. This is the result.

The Code

I started out from a System.Windows.Forms.UserControl. I decided that the size should be calculated from the number of LED:s being used (I started with the LED, and added the analog this weekend), and added properties for LED size and spacing. The colors are user selectable in three different areas (up to 32 LED:s in each) with different settings for LED on and off so they could have a glow when idle.

BackColor is used for the border round the LED:s.

The LED:s are made up of filled rectangles, with a solid brush, easy to use and didn't take much time to get working, next I added the possibility to enable a PeakHold with selectable Hold time, and then I wanted to have a vertical version also. This solution is quite ugly, but it works ok.

As I wanted to use the LED:s for a VU meter, I wanted both analog and logarithmic scale (Log10) so that came next, and this was a bit tricky for me, but I made it and was very happy with my solution, but then suddenly I got the idea: But I want an old style analog meter, so I started searching, but found nothing (for free anyway), and the meters that had a decent price tag were ugly! I did find some extremely beautiful gauge meters, but almost 700$ is way beyond my budget!

So the only way was the hard way. I started last week, (on my spare time!) this was fun! I haven't learnt so much in many years, and I'm learning new things every day now, and I did get results!

I got the analog meter running over the weekend, but at a fixed size, and I couldn't make the background transparent, so I wasn't quite satisfied yet (I do not lie if I tell you that I had a lot of trouble getting the maths together for the analog meter). To solve the background, I found the example code in C# Help for a round button, set a region, and that did the trick, finally! But it would be nice to be able to have a different size, the TI-66 (I know its old, but it has nostalgic value for me) did some number crunching, and I began to change in the code, suddenly terrified that I hadn't made a backup before the changes, my test application didn't work anymore?!?! What to do, ctrl-z a wonderful key-combination, but when I found the error (I set the size to 0,0 by mistake) I just had to re-enter everything again. And now, tonight, I'm quite satisfied with my work, so the next thing was getting MP3 recording to work (don't now how yet, but I'm leaning towards BASS) so I could get some practical use of my wonderful meters.

Using the Code

I've done my best to make it easy to use. Here is a small explanation of how to use it.

First, drag the DLL to your Toolbox, then you could place a VuMeter on your Form.

To set it up the way you want it, go to the properties and look in Analog Meter, VU Meter and VU Meter - Colors. BackColor, Font and Size are also in use.

Analog Meter Properties

  • Analog Meter - True or False (default False) tells the meter if it should be LED or analog.
  • DialBackGround, is the color of the dial. DialTextNegativ, Positive and Zero is what color the text above the dial should have dependant on the value (text uses DialTextPositive).
  • NeedleColor and PeakNeedleColor are of course the color of the needle and peak indicator.
  • ShowDial Only - True or False (default False) removes the background around the meterdial so you could place it above some nice meter image or anything else you want.
  • ShowTextInDial - True or False (default True) tells if the text (values) should be shown in the dial, and the values are placed in TextInDial (a String array) and all the values are distributed in the upper part of the dial.
  • VuText is a text you could have in the dial (Default VU).

In the VU Meter category, you find more options:

  • Led1(2 and 3) Count number of LED:s in each area (default 6, 6 and 4) max value 32 for each area and minimum 0 (but there must be 1 LED in one of the areas) this is also the number of indicators that are shown in the analog dial.
  • LedSize (default 6;14) size of each led in pixels, same size is used in the analog meter so to get smaller "ticks" change the size here.
  • LedSpace (default 3) pixels between LED:s and also width of border around LED:s.
  • Level input level to meter determines number of LED:s to light or position of needle in analog view.
  • LevelMax (default 65535) Max input value also the level that turns on all the LED:s.
  • MeterScale Analog or Log10 (default Log10) what math to use when calculating Level.
  • PeakHold True or False (default True) if you should use PeakIndicator.
  • Peakms (default 1000) number of ms to hold peak value (max 10000).
  • VerticalBar True or False (default False) if you want a vertical LED-bar instead.
  • VU Meter - Colors, you figure it out for yourself Wink | ;)

Added October 25th

Section Analog

  • UseLedLight True or False (default False) if the Led:s in the dial should follow the needle.
  • ShowLedPeak True or False (default False) if the Peak indicator should be shown in Led also.
  • If you like this analog and digital meter, please give comments and feedback on the code and the component. If anyone out there could give me some help on how to record to a MP3 file from C#, I'd be happy to get some help.

History

  • October 22nd, 2006 - Article submitted
  • October 24th, 2006 - Updated, thanks to BruceN
  • October 25th, 2006 - Added extra features (Leds in Analog dialbar lights up)
  • February 21st, 2007 - Added properties-AssemblyInfo.cs to source code
  • December 1st, 2007 - Adapted the project to Visual C# Express 2008, new source code
  • September 10th, 2009 - Changed source to include all subfolders

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

No Biography provided

Comments and Discussions

 
QuestionGood Work! Pinmemberfirewood00114-Nov-14 21:19 
QuestionVisual Studio 2008 under WIndows 7 PinmemberAndersEtteplan10-Oct-13 4:09 
GeneralMy vote of 4 PinmemberSergio Andrés Gutiérrez Rojas23-Sep-11 14:19 
GeneralMy vote of 5 PinmemberDennis Betten2-Nov-10 23:34 
QuestionHow to Use Peek like DEMO? Pinmemberjbahn19-Aug-10 22:54 
AnswerRe: How to Use Peek like DEMO? PinmemberKent Andersson20-Aug-10 6:29 
GeneralSome Changes PinmemberReymonARG18-Feb-10 22:59 
GeneralRe: Some Changes PinmemberKent Andersson19-Feb-10 10:05 
GeneralRe: Some Changes PinmemberReymonARG19-Feb-10 11:25 
GeneralThank you !!! PinmemberRiccardo.Bertoli27-Dec-09 12:33 
NewsProperties\Resources.resx is missing PinmemberW5JDX23-Sep-09 14:32 
GeneralVS 2008 PinmemberPierre659-Sep-09 23:50 
GeneralRe: VS 2008 PinmemberKent Andersson10-Sep-09 7:39 
GeneralRe: VS 2008 Pinmembertlhintoq14-Sep-09 19:38 
AnswerRe: VS 2008 Pinmembertlhintoq14-Sep-09 20:03 
GeneralRe: VS 2008 PinmemberKent Andersson14-Sep-09 20:37 
GeneralRe: VS 2008 Pinmemberscaynet5-Apr-10 21:18 
GeneralThank you! Pinmemberavarone14-Nov-08 11:25 
QuestionDo you have any info?? Pinmemberejoee21-Aug-08 15:20 
Generalinput value less than LevelMax scale Pinmembermartinsvicente21-Jul-08 11:17 
AnswerRe: input value less than LevelMax scale Pinmembertlhintoq14-Sep-09 22:22 
GeneralLicense of ussage Pinmemberchuchuk28-Mar-08 12:02 
GeneralMissing files Pinmembershark15465-Dec-07 6:41 
QuestionMissing VU-Meter.wmf Pinmemberallengoodwin12-Mar-07 9:59 
AnswerRe: Missing VU-Meter.wmf PinmemberKent Andersson12-Mar-07 11:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.150301.1 | Last Updated 10 Sep 2009
Article Copyright 2006 by Kent Andersson
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid