Cabbage Logo
Back to Cabbage Site

Help how to create a decibel level meter?

Need to create a RMS an Peak meter in dBFS scale. any idea? thanks

Maybe this is start? Meters are just displayed using sliders but I’m sure you can come up with something prettier using images or gentables.

<Cabbage>
form caption("Untitled") size(400, 310), colour(58, 110, 182), pluginID("def1")
vslider bounds(25,5, 20, 300), channel("meter"), range(-90, 0, -90)
vslider bounds(75,5, 20, 300), channel("meter_peak"), range(-90, 0, -90)

    </Cabbage>
    <CsoundSynthesizer>
    <CsOptions>
    -n -d -+rtmidi=NULL -M0 -m0d 
    </CsOptions>
    <CsInstruments>
    ; Initialize the global variables. 
    sr = 44100
    ksmps = 8
    nchnls = 2
    0dbfs = 1


    instr 1
     aInL	inch	1
     krms	rms		aInL					; scan rms
     kdb	=		dbfsamp(krms)			; convert to db
     kpeak	init	-90						; initialise peak value
     if metro(0.5)==1 then					; reset peak hold
      kpeak	=	-90
     endif
     kpeak	=		kdb>kpeak?kdb:kpeak		; compare stored peak value with current db value
     kpeakP	port	kpeak,0.05				; smooth changes of peak value
      if metro(16)==1 then					; peg update of widgets
     	chnset	kdb,"meter"
     	chnset	kpeakP,"meter_peak"
     endif
    endin

    </CsInstruments>
    <CsScore>
    ;causes Csound to run for about 7000 years...
    f0 z
    ;starts instrument 1 and runs it for a week
    i1 0 [60*60*24*7] 
    </CsScore>
    </CsoundSynthesizer>

Hey there,

If anyone is interested, here’s a metering simulation using checkboxes.

Metering.csd (6.5 KB)

Description in comment header.

Cheers!

That looks nice. Here’s another approach that uses tables. It could be reduced even further if I hadn’t bothered with indicators for when peak amplitude is reached. Let me know if you have any questions about, it’s not very well commented! Metering2.csd (1.7 KB)

This looks cool! Quite a low footprint on this. Also, why does colour gradient not work when table size is greater than 2? It says so in the manual too, but I just wanted to know the reason.

Because I limited it to 2 for the purpose of VU meters. Cabbage2 will probably just have a dedicated VU meter widget. Everything will be better in Cabbage 2! :wink:

Hi…The best audio to measure in my opinion is white noise because its full-frequency. It’s also worth moving around a bit and take readings at different spots. Sometimes the room can cause standing waves and frequencies almost silent at one spot can be much louder even a foot away.

printed circuit board

Hi! I’m brand new to Cabbage and am trying to figure out how to build a simple peak meter?

All the meter plug-ins on the market display way too much useless information (itoa-peak sampling, phase coherence, etc.), and I like simple linear peak-meters, not the old-style “Analog VU Meter” look.

I downloaded the Metering2.csd, opened it in Cabbage, clicked on make instrument, it looks perfect, I exported it as an AU component and put it in my OSX components library.

I opened up my DAW (Motu DP for Mac), it validated the component.

I inserted it on a track, but it doesn’t do anything?

Sorry for this “Noob” question, but what am I doing wrong? or is this just part of the code I would need to build a peak-meter in Cabbage?

Many thanks!

Hi @NRKorsakov, sorry for the delay in getting back to you. The latest version of Cabbage has VU meters built into it. They are pretty minimal, but should do the trick. I’ve modified the example posted above to use the new vumeter widgets.

Metering2.csd (1.1 KB)

Let me know if you have any problems.

Whoa!!! Thank you so much! That was so kind I really appreciate it!

Cabbage is beyond cool.

I’m so looking forward to exploring it, and this will be my starting point.

Thanks again, Rory!