Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Vu meter (Read 3090 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Vu meter

Hi  guys, i'm trying to make a simple Vu meter

i'm using a modified progressbar to show the results

code
Code: [Select]
  left := 0;
  right := 0;

  Vis.GetSamples(50, samples, len); // get 50ms of 16bit samples, put the result in samples, len is the size of result in bytes

  len := len div 2;
  // find max value in left band and put it in "left"
  // find max value in right band an put it in "right"
  // ...

  ind.PositionL := Round( 100 * (left / 32768)); // scale the peaks
  ind.PositionR := Round( 100 * (right / 32768)); // and show then on the progressbars


it "works", but not well (lot of 100% peaks in very quiet music... for example)

finding the peaks in the waveform like that is the right way?
A friend told me that this is only one type of Vu Meter, and there are other types that measure dB, .... .

Vu meter

Reply #1
Hi  guys, i'm trying to make a simple Vu meter

i'm using a modified progressbar to show the results

it "works", but not well (lot of 100% peaks in very quiet music... for example)

finding the peaks in the waveform like that is the right way?
A friend told me that this is only one type of Vu Meter, and there are other types that measure dB, .... .


A VU Meter is a specific type of meter. From VU meter article on wikipedia:
Quote
The typical VU scale is from ?20 to +3. The rise and fall times of the meter are both 300 milliseconds, meaning that if a constant sine wave of amplitude 0 VU is applied suddenly, the meter will take 300 milliseconds to reach the 0 on the scale. It behaves as a full-wave averaging instrument, and is not optimal for measuring peak levels.

The behaviour of VU meters is defined in ANSI C16.5-1942, British Standard BS 6840, and IEC 60268-17.


Different meters serve different purposes. It sounds like you have a peak-hold type meter (although I know nothing about programming). A peak hold meter is useful when recording to see if you have clipped the input to your digital recorder, but does not represent the signal level very well. Peak hold meters respond to peaks instantaneously and hold them for a few seconds.

Often digital meters measure the peak level on a sample by sample basis and then 'decay' at a certain rate. This gives a better visualisation of the level than just registering the peak level instantaneously (or in blocks).

If you want to display the perceived loudness of the signal then you are in for quite a bit of study as this is quite complicated.

Vu meter

Reply #2
I can't follow the programming either...  I'm only an "amateur" programmer, I don't know what programming language you're using, and I don't know anything about the functions you're using... 

It's not unusual to get 0dB peaks with "quiet music".

I suggest that you (temporarily) display your raw data (i.e. one group of 50 samples) and the value of left and right.  Then, you'll know if the data is valid.

A 16-bit WAV file uses signed integers (between -32,768 and +32,767).  Make sure that your find max function is handling the negative values properly. 


Quote
If you want to display the perceived loudness of the signal then you are in for quite a bit of study as this is quite complicated.
True, but it's not that hard to make a very useful meter that shows the peak (perhaps with a slow decay) and also show a moving average.

Vu meter

Reply #3
Hi guys, i discovered that my GetSamples function was inserting some noise in the waveform

i fixed it and it's working quite well this way (finding the peaks on the waveform)

Quote
If you want to display the perceived loudness of the signal then you are in for quite a bit of study as this is quite complicated.
True, but it's not that hard to make a very useful meter that shows the peak (perhaps with a slow decay) and also show a moving average.

what's your ideia?

Vu meter

Reply #4
Getting 50ms of data for a peak meter is a bit too much. (more usual values are 5ms).
With that amount of samples, you would better be going with an RMS meter.  It is the sum of the squares of the values, then divide by the amount of samples, and then do the square root. (http://en.wikipedia.org/wiki/Root_mean_square)




Vu meter

Reply #5

Getting 50ms of data for a peak meter is a bit too much. (more usual values are 5ms).
With that amount of samples, you would better be going with an RMS meter.  It is the sum of the squares of the values, then divide by the amount of samples, and then do the square root. (http://en.wikipedia.org/wiki/Root_mean_square)

When calculating it this way you must be sure that there is no DC bias. If instead you calculate the RMS deviation about the mean then you are filtering out the low frequencies. Best to  calculate the RMS deviation about the long-term average of the mean.

 

Vu meter

Reply #6
Thanks for the reply guys, i will try both maths here