This commit is contained in:
Boof2015
2026-05-27 18:55:41 -04:00
parent b877541882
commit ddae07c985
9 changed files with 316 additions and 2 deletions
+2
View File
@@ -57,6 +57,7 @@ function(add_prism_scope TARGET PRODUCT PLUGIN_CODE SCOPE_DEFINE)
Source/PluginEditor.cpp
${PRISM_NATIVE_DIR}/spectrum.cpp
${PRISM_NATIVE_DIR}/oscilloscope.cpp
${PRISM_NATIVE_DIR}/vumeter.cpp
${PRISM_NATIVE_DIR}/dsp_utils.cpp)
target_include_directories(${TARGET} PRIVATE Source ${PRISM_NATIVE_DIR})
@@ -94,3 +95,4 @@ endfunction()
add_prism_scope(PrismSpectrum "Prism Spectrum" Pspc "")
add_prism_scope(PrismOscilloscope "Prism Oscilloscope" Posc "PRISM_SCOPE_OSCILLOSCOPE=1")
add_prism_scope(PrismVUMeter "Prism VU Meter" Pvum "PRISM_SCOPE_VUMETER=1")
+4 -1
View File
@@ -1,6 +1,7 @@
#include "PluginEditor.h"
#include "SpectrumEngine.h"
#include "OscilloscopeEngine.h"
#include "VUMeterEngine.h"
#include <cstring>
#if ! PRISM_USE_DEV_SERVER
@@ -18,7 +19,9 @@ namespace
std::unique_ptr<ScopeEngine> makeEngine()
{
#if defined(PRISM_SCOPE_OSCILLOSCOPE) && PRISM_SCOPE_OSCILLOSCOPE
#if defined(PRISM_SCOPE_VUMETER) && PRISM_SCOPE_VUMETER
return std::make_unique<VUMeterEngine>();
#elif defined(PRISM_SCOPE_OSCILLOSCOPE) && PRISM_SCOPE_OSCILLOSCOPE
return std::make_unique<OscilloscopeEngine>();
#else
return std::make_unique<SpectrumEngine>();
+54
View File
@@ -0,0 +1,54 @@
#pragma once
#include "ScopeEngine.h"
#include "vumeter.h" // reused, unmodified, from native/src
/**
* VU meter engine. Pushes stereo audio into the reused `Visualizer::VUMeterAnalyzer`
* (RMS integration + ballistics + peak hold + correlation, all sample-accurate) and
* emits the resulting scalar snapshot each frame. No base64 needed — the frame is a
* handful of numbers. getSnapshot() advances peak decay on the steady clock, so the
* meter still settles when audio momentarily stops.
*/
class VUMeterEngine : public ScopeEngine
{
public:
const char* scopeId() const override { return "vumeter"; }
juce::Identifier frameEventId() const override { return frameId; }
void setSampleRate(double sampleRate) override
{
vu.setSampleRate((float) sampleRate);
}
void configure(const juce::var&) override
{
// VU settings (mode/orientation/needleChannels/referenceDb) are render-side only.
}
void process(const float* left, const float* right, int numSamples) override
{
if (numSamples <= 0)
return;
vu.pushSamples(left, right, (size_t) numSamples);
}
juce::var buildFrame(double sampleRate) override
{
const auto snap = vu.getSnapshot();
auto* obj = new juce::DynamicObject();
obj->setProperty("sampleRate", sampleRate);
obj->setProperty("vuLDb", snap.vuLDb);
obj->setProperty("vuRDb", snap.vuRDb);
obj->setProperty("barLDb", snap.barLDb);
obj->setProperty("barRDb", snap.barRDb);
obj->setProperty("peakLDb", snap.peakLDb);
obj->setProperty("peakRDb", snap.peakRDb);
obj->setProperty("correlation", snap.correlation);
return juce::var(obj);
}
private:
const juce::Identifier frameId { "vumeterFrame" };
Visualizer::VUMeterAnalyzer vu;
};