Convert number to signal...is it possible?

snaper's icon

Hy Guys,

Is it possible to convert a number to signal, to view it with the VU meter?

(Converting a number to "peak level"...)

vichug's icon

[sig~] ?

snaper's icon

Its not working...I've tried.

I would like to calculate the RMS from the peak value of the LIVE API. I know that I an use the average~ object for signal, but I would like to measure more channels at once.

snaper's icon

Or if I can't convert the dB amount to peak signal, how can I calculate the RMS from the dB?

snaper's icon

Yes, thats right, I have to convert the peak value to RMS.
Is there a math expression for that?

snaper's icon

First idea :

- peak data come from Live API.
- noise~ into a live,gain~
- a live.gain~ object's output is controlled by this peak data
- the output of the live.gain is into a levelmeter~
- levelmeter shows rms...

but its sooooo sloooooooow

woyteg's icon

a number into [sig~] does work perfectly fine as vichug suggested. If it's a good idea is another question.
Ever looked up RMS on wikipedia?

Christopher Dobrian's icon

There is no formula to convert peak amplitude to RMS amplitude, because they're not measuring the same thing. A sine wave with a peak amplitude of 1 has a RMS amplitude of 0.707 (-3 dB), but anything more complex than a sine wave is not so simple. Consider one second that contains nothing but a single full-amplitude click; the peak amplitude would be 1 (for the brief instant of the click) but the RMS amplitude of that one second of sound would be nearly 0 (-inf dB).

To get the RMS amplitude of a signal in dB:

audio signal you want to measure -> average~ (in rms mode) -> number~ (and then to adtodb and flonum if you want it in dB). Or...

audio signal you want to measure -> levelmeter~ -> number (or live.numbox)

showRMS.amxd
amxd
snaper's icon

Woyteg :
Yes, [sig~] does the job, for the meter object, but not for the levelmeter.

Christopher :
Correct. The problem is that I don't have signal, just peak values in dB (or in 0..1), from the Live API. I could convert it to signal with sig for the meter object, and it shows the correct amount, but can't make it work with the levelmeter object.
For example, with a sine wave, the Live mixer shows -12dB, I can get this info from the API, then send it into a meter object, (trough a sig), and it shows -12dB. But if I try to send the same converted signal into a levelmeter (what can make an RMS as output), I get +3dB....

Christopher Dobrian's icon

My point is, forget the LiveAPI, you have the signal right there to measure in Max for Live, so just measure it, no? (Place a M4L device such as mine in the Master audio channel.) For any time-varying wave (i.e. anything other than a static classic waveform), there's no simple way to derive RMS amplitude from peak amplitude.

snaper's icon

Thats true, but the request from the customer was that he would like to see multiple channels rms at once...

vichug's icon

[sig~] does work fine with levelmeter~ here

snaper's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Vichug : thanks, tried it, maybe Im too tired an miss something obvious...
Could you take a look?

vichug's icon

Of course !
...well apart that i'm using live 8 with m4l 5 and i tested this patch with max 6 and a similar patch with m4l 5 (maybe a m4l 6 deprecation ?), that you need to turn dac on for this to work (obviously, anyway inside live it should be always on by default afaik), and that the negative and negative values are equal (that's probably intended, i jsut can't say for sure), this patch works as expected

snaper's icon

You mean, that levelmeter and meter gives you the same result in dB?

vichug's icon
Max Patch
Copy patch and select New From Clipboard in Max.

i had not checked the values, i thought your problem was that you had no signal.
Anyway :

the difference is of unexact 3 dB between the two outputs. Meter~ gives a peak value as absollute signal level, whereas levelmeter~ gives RMS value in dB. The difference may come from there ?