|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
|
Announcements
Chapters
Services
Feature Zones
|
Note: This is an unedited contribution. If this article is inappropriate,
needs attention or copies someone else's work without reference then please
Report This Article
IntroductionI've been searching a lot for a easy to use VU meter to use in a simple Audio player/recorder, but I havn'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 unfortunatly 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 CodeI started out from a 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 desent price tag was ugly! I did find some extremly beautiful gauge meters, but almost 700$ is way beond my budget! So the only way was the hard way, started last week, (on my spare time!) this was fun! I havn'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 in the weekend, but at a fixed size, and I couldnt make the background transparent, so I wasn't quite satisfied yet (I don't lie if I tell you that I had a lot of trouble getting the math:s together for the analog meter). To solve the background I found the example code in C# Help for a round button, setting a region, and that did the trick, finaly! 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 is 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 codeI've done my best to make it easy to use, First, drag the DLL to your Toolbox, then you could place a VuMeter on your Form. To set it up the way you wan't it go to the proporties and look in Analog Meter, VU Meter and VU Meter - Colors. BackColor, Font and Size is also in use. Analog Meter proporties: 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 is 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 is 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 ;) 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 in how to record to a MP3 file from C#, I'd be happy to get some help.
History
|
||||||||||||||||||||||