<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Custom peak meter doesn&#x27;t work in a DAW]]></title><description><![CDATA[<p dir="auto">Please excuse my amatuerish code 🥲</p>
<pre><code>Content.makeFrontInterface(332, 550);
Engine.loadFontAs("{PROJECT_FOLDER}Fonts/Px437_Portfolio_6x8.ttf", "Portfolio_6x8");

const var PeakIn = Synth.getEffect("PeakIn");
const var PeakOut = Synth.getEffect("PeakOut");
const var Gate = Synth.getEffect("Gate");
const var HPF = Synth.getEffect("HPF");
const var Dynamics = Synth.getEffect("Dynamics");

const var inputPanel = Content.addPanel("pnlInput", 130, 111);
const var outputPanel = Content.addPanel("pnlOutput", 275, 111);

const var MAX_PEAK_HOLD_FRAMES = 45;
const var MAX_PEAK_DECAY_RATE = 0.5;

Content.setPropertiesFromJSON("pnlInput", {
    "width": 15,
    "height": 333,
    "opaque": false
});

Content.setPropertiesFromJSON("pnlOutput", {
    "width": 15,
    "height": 333,
    "opaque": false
});

inputPanel.data.currentLevel = -60.0;
inputPanel.data.maxPeakdB = -60.0;
inputPanel.data.holdCounter = 0;

outputPanel.data.currentLevel = -60.0;
outputPanel.data.maxPeakdB = -60.0;
outputPanel.data.holdCounter = 0;

inline function dbToY(db, panelHeight)
{
    local clamped = Math.range(db, -60.0, 6.0);
    local percent = (clamped - (-60.0)) / (6.0 - (-60.0));
    return panelHeight - (percent * panelHeight);
};

inputPanel.setPaintRoutine(function(g)
{
    local w = this.getWidth();
    local h = this.getHeight();

    local floor = Content.getComponent("knbFloor").getValue();
    local slack = Content.getComponent("knbSlack").getValue();
    local fade = Content.getComponent("knbFade").getValue();
    local slackLevel = floor + slack;
    local fadeInLevel = floor + fade * 9;
    local fadeOutLevel = slackLevel - fade * 9;
    
    local rawLevel = PeakIn.getCurrentLevel(1);
    local LeveldB = (rawLevel &gt; 0) ? Engine.getDecibelsForGainFactor(rawLevel) : -60.0;
    
    local peak = dbToY(LeveldB, h);
    local maxPeakY = dbToY(this.data.maxPeakdB, h);
    local floorY = dbToY(floor, h);
    local slackY = dbToY(slackLevel, h);
    local fadeInY = dbToY(fadeInLevel, h);
    local fadeOutY = dbToY(fadeOutLevel, h);
    
	g.setColour(0xFF433151);
	g.fillRect([3, maxPeakY - 1, 9, 2]);
	
	g.setColour(0xFFE5007F);
	g.fillRect([3, peak, 9, h - peak]);
    
    g.setColour(Colours.withAlpha(Colours.green, 0.2));
    g.fillRect([0, floorY, w, slackY - floorY]);

    g.setColour(Colours.withAlpha(Colours.whitesmoke, 0.5));
	g.fillRect([0, fadeInY - 1, w, 2]);
	
    g.setColour(Colours.withAlpha(Colours.whitesmoke, 0.5));
	g.fillRect([0, fadeOutY - 1, w, 2]);
	
    g.setColour(Colours.withAlpha(Colours.red, 1));
    g.fillRect([0, slackY - 1, w, 2]);
    
    g.setColour(Colours.withAlpha(Colours.green, 1));
    g.fillRect([0, floorY - 1, w, 2]);
});

outputPanel.setPaintRoutine(function(g)
{
    local w = this.getWidth();
    local h = this.getHeight();
    
	local rawLevel = PeakOut.getCurrentLevel(1);
	local LeveldB = (rawLevel &gt; 0) ? Engine.getDecibelsForGainFactor(rawLevel) : -60.0;
	
    local peak = dbToY(LeveldB, h);
    local maxPeakY = dbToY(this.data.maxPeakdB, h);
	
	g.setColour(0xFFE5007F);
	g.fillRect([3, maxPeakY - 1, 9, 2]);
		
	g.setColour(0xFF433151);
	g.fillRect([3, peak, 9, h - peak]);
});

inputPanel.setTimerCallback(function()
{
    local rawLevel = PeakIn.getCurrentLevel(1);
    local leveldB = (rawLevel &gt; 0) ? Engine.getDecibelsForGainFactor(rawLevel) : -60.0;
    
    if (leveldB &gt; this.data.maxPeakdB)
    {
	    this.data.maxPeakdB = leveldB;
	    this.data.holdCounter = 0;
    }
    else {
	    this.data.holdCounter += 1;
	    
	    if (this.data.holdCounter &gt; MAX_PEAK_HOLD_FRAMES)
	    	this.data.maxPeakdB = Math.max(leveldB, this.data.maxPeakdB - MAX_PEAK_DECAY_RATE);
    }

    this.repaint();
});

outputPanel.setTimerCallback(function()
{
    local rawLevel = PeakOut.getCurrentLevel(1);
    local leveldB = (rawLevel &gt; 0) ? Engine.getDecibelsForGainFactor(rawLevel) : -60.0;
    
    if (leveldB &gt; this.data.maxPeakdB)
    {
	    this.data.maxPeakdB = leveldB;
	    this.data.holdCounter = 0;
    }
    else {
	    this.data.holdCounter += 1;
	    
	    if (this.data.holdCounter &gt; MAX_PEAK_HOLD_FRAMES)
	    	this.data.maxPeakdB = Math.max(leveldB, this.data.maxPeakdB - MAX_PEAK_DECAY_RATE);
    }

    this.repaint();
});

inputPanel.startTimer(30);
outputPanel.startTimer(30);
</code></pre>
<p dir="auto">I honestly have no frickin idea how to even fix this, also why is it louder in my DAW? AudioLooper is already at 0dB</p>
<p dir="auto"><a href="https://files.catbox.moe/ox00kr.mp4" rel="nofollow ugc">https://files.catbox.moe/ox00kr.mp4</a></p>
]]></description><link>https://forum.hise.audio/topic/14988/custom-peak-meter-doesn-t-work-in-a-daw</link><generator>RSS for Node</generator><lastBuildDate>Mon, 10 Aug 2026 06:53:54 GMT</lastBuildDate><atom:link href="https://forum.hise.audio/topic/14988.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 10 Aug 2026 01:21:54 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Custom peak meter doesn&#x27;t work in a DAW on Mon, 10 Aug 2026 03:43:20 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://forum.hise.audio/uid/5209">@Kalliopei</a> I changed all locals inside the paint routines to vars and compiled your code stripped down, added ENABLE_ALL_PEAK_METERS=1 in the project and it works inside Logic</p>
<p dir="auto"><img src="/assets/uploads/files/1786333392522-custom-vu.gif" alt="custom vu.gif" class=" img-fluid img-markdown" /></p>
]]></description><link>https://forum.hise.audio/post/122432</link><guid isPermaLink="true">https://forum.hise.audio/post/122432</guid><dc:creator><![CDATA[ulrik]]></dc:creator><pubDate>Mon, 10 Aug 2026 03:43:20 GMT</pubDate></item><item><title><![CDATA[Reply to Custom peak meter doesn&#x27;t work in a DAW on Mon, 10 Aug 2026 03:08:43 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://forum.hise.audio/uid/5209">@Kalliopei</a> In the video there is warnings about using locals inside paint routines, you should use var instead, maybe that could be the reason?</p>
]]></description><link>https://forum.hise.audio/post/122431</link><guid isPermaLink="true">https://forum.hise.audio/post/122431</guid><dc:creator><![CDATA[ulrik]]></dc:creator><pubDate>Mon, 10 Aug 2026 03:08:43 GMT</pubDate></item></channel></rss>