Cabbage Logo
Back to Cabbage Site

How to "Feed" Meters?

Managed to setup a simple gain between audio input and output so far. LOL

Now I would like to visualize the resulting audio level by implementing a stereo peak meter with dBFS scale. (The provided meters.csd is instead featuring random values.)

I know, this may be VERY “CSound noobish” to ask:
But how do I “feed” the respective two channels, which I’d like to visualize, into the meter?!?
It doesn’t seem to be enough to connect them via the patcher.

Please forgive me my lack of knowledge(!).
At the moment my knowledge of CSound is too little to accomplish this task. :blush:
But I am willing to learn! :slightly_smiling_face:

This one takes the output of an oscillator and uses its rms value to drive the meter. Let me know if anything isn’t clear in what’s going on :wink:

meters.csd (694 Bytes)

Thx Rory! That one could be fine.
I only don’t know how to exchange the meter’s oscillator input for the input of the elements input-node.

There is a “slider-style” meter from this forum, which I brought up and running.
But I would love to have a “real” meter display instead of a moving slider.

The one, I’m talking about is this:

form caption("Input Meter Left") size(400, 310), colour(58, 110, 182), pluginID("def1") vslider bounds(24, 4, 50, 300), channel("meterL"), range(-90, 0, -90, 1, 0.1) trackerinsideradius(0.05) trackeroutsideradius(1)
</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.25				; smooth changes of peak value
  if metro(16)==1 then					; peg update of widgets
 	chnset	kdb,"meterL"
 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>

Just use inch to access the incoming signal :wink:

meters.csd (673 Bytes)

That’s so awesome, Rory! Thank you, got it. :slight_smile:

Managed to set up an input stage w/ gain adjustment and metering,
followed by an output stage w/ gain adjustment and metering so far. :smiley:

In the next step I’ll try to implement a highcut filter in a parallel path, including a wet/dry adjustment.
I’m so excited to see this thing slooooowly grow into my very first plugin. ^^

Cabbage is really fun to play around with and such a smart tool, even for a total newbie. Love it! :+1:

I’m glad you you’re enjoying it. Where did you hear about it?

I saw Klevgrand’s development tool on the KVR site and did a Google search for similar but more advanced and open software.

Cool. I hadn’t come across KRETS before. I must give it a shot. The reason I asked is because I’m notoriously bad at promoting Cabbage, so I’m always pleasantly surprised when people stumble across it!

btw: talking about meters … is there any VU meter .csd in the repository?

I don’t think any of the examples make use of a VU meter. When so many hosts provide vu metres for each plugin it doesn’t seem important. But you got yours to work right?

Oh, I did not ask for the right thing then:
I was looking for a VU meter for RMS visualisation.

Regarding VU meters, I found a discussion from 2016 in this forum: Switching images with slider

But that code does not seem to work with the images provided.
Is there any VU meter in the examples?

P.S.: Sure, the RMS meter with scale visualisation is working absolutely fine. :slight_smile:

I’m confused :laughing: You say:

And then:

Are you looking for something that actually looks like a VU meter?

Right, I’m looking to implement a VU meter to visualize the RMS values. :slight_smile:

P.S.:
User tuncark had posted his .csd and image files of a VU meter to play around with:

And you had posted some code in this post of the same thread:

Unfortunately, if I combine your code with the images provided, and feed it with audio … there is only the first image displayed and no image swapping takes place (see attached ZIP file).
VU_meter_test.zip (218.0 KB)

That thread is pretty old. I don’t think using different png images is the way to go here. Let me create another example…give me a sec…

Hold on a sec, have you tried the knobmanSlider example in the Misc menu examples?

1 Like

Ah, not several PNGs, ok. ^^

Hadn’t seen yet that the knobmanSlider example is hiding a VU meter inside. :slight_smile:
But it looks promising.

As is, it’s displaying random values.
And I have a hard time feeding it with inch + chnset


I mean, what to exchange this part of code for(?):

kVuMeter randi 1, 5
filmStrip “vuMeterIdent”, int(abs(kVuMeter)*30)*128, 128, 128

Still have to dive more into CSound.
Do you have any hint for me? :blush:

It’s Csound :laughing: The incorrect spelling of Csound is becoming more and more frequenct :thinking: But I won’t hold it against you :rofl:

So you want to change the randi for a inch:

kVuMeter inch 1
filmStrip “vuMeterIdent”, int(abs(kVuMeter)*30)*128, 128, 128

In this case you don’t have to worry about a chnset as it’s already wrapped up in the UDO.

Oh, oh … hey, that’s what I call a newbie … haha
Even the spelling of what he’s going to learn is wrong. LOL

Thank you for your hint on the inch 1 part.
Sadly, that doesn’t bring the VU meter to life for me.

As soon as I exchange the randi for the inch 1 it’s dead. :frowning:

:rofl::rofl:

Sorry that was my fault. Even non-noobs err! It should be:

a1 inch 1
kVuMeter rms a1
filmStrip "vuMeterIdent", int(abs(kVuMeter)*30)*128, 128, 128

That’s fantastic. Rory. It works! :slight_smile:
Thank you SO much.


Only thing strange is, that as soon as I amplify the level of a white noise test-signal above +5.5 dBFS the VU meter graphic starts flickering and fully disappears, if I exceed a gain of about +6 dBFS.

I guess, the .csd runs out of PNG image portions. ^^
A solution could be to add enough image parts at the “end” of the PNG file to match the highest RMS value to be displayed.

Or is there any way to keep the VU meter showing the last part of the PNG, no matter how high the RMS value? e.g. some possibility to “cap” the incoming RMS value for the VU meter?


P.S.:

NEVERMIND :slight_smile:
I found out how to adjust the “translation” of the RMS value into the VU meter display.

int(abs(kVuMeter)[adjust here])[height], [width], [height]

This is really fun and works absolutely nice. ^^
I only find it hard to adjust the behaviour of the meter …