mirror of
https://github.com/Boof2015/prism.git
synced 2026-08-12 05:10:51 +02:00
VU VST
This commit is contained in:
@@ -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")
|
||||
|
||||
@@ -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>();
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
Reference in New Issue
Block a user