Merge branch 'custom-resolution-framerate' into develop

pull/281/head
James H Ball 2025-01-26 21:02:19 +00:00
commit 8f67d26199
21 zmienionych plików z 140 dodań i 45 usunięć

Plik binarny nie jest wyświetlany.

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 21 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 25 KiB

Plik binarny nie jest wyświetlany.

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 6.3 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 25 KiB

Plik binarny nie jest wyświetlany.

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 84 KiB

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 465 KiB

Plik binarny nie jest wyświetlany.

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 79 KiB

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 4.7 MiB

Plik binarny nie jest wyświetlany.

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 33 KiB

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 1.5 MiB

Plik binarny nie jest wyświetlany.

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 56 KiB

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 4.1 MiB

Plik binarny nie jest wyświetlany.

Przed

Szerokość:  |  Wysokość:  |  Rozmiar: 64 KiB

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 3.6 MiB

Wyświetl plik

@ -43,8 +43,8 @@ CommonPluginEditor::CommonPluginEditor(CommonAudioProcessor& p, juce::String app
visualiserSettings.setColour(juce::ResizableWindow::backgroundColourId, Colours::dark);
recordingSettings.setLookAndFeel(&getLookAndFeel());
recordingSettings.setSize(350, 230);
recordingSettingsWindow.centreWithSize(350, 260);
recordingSettings.setSize(350, 280);
recordingSettingsWindow.centreWithSize(350, 320);
#if JUCE_WINDOWS
// if not standalone, use native title bar for compatibility with DAWs
recordingSettingsWindow.setUsingNativeTitleBar(processor.wrapperType == juce::AudioProcessor::WrapperType::wrapperType_Standalone);

Wyświetl plik

@ -17,7 +17,11 @@ EffectComponent::EffectComponent(Effect& effect, int index) : effect(effect), in
slider.setSliderStyle(juce::Slider::LinearHorizontal);
slider.setTextBoxStyle(juce::Slider::TextBoxRight, false, TEXT_BOX_WIDTH, slider.getTextBoxHeight());
slider.setNumDecimalPlacesToDisplay(4);
if (effect.parameters[index]->step == 1.0) {
slider.setNumDecimalPlacesToDisplay(0);
} else {
slider.setNumDecimalPlacesToDisplay(4);
}
lfoSlider.setSliderStyle(juce::Slider::LinearHorizontal);
lfoSlider.setTextBoxStyle(juce::Slider::TextBoxRight, false, TEXT_BOX_WIDTH, lfoSlider.getTextBoxHeight());

Wyświetl plik

@ -15,18 +15,15 @@ AudioBackgroundThread::~AudioBackgroundThread() {
}
void AudioBackgroundThread::prepare(double sampleRate, int samplesPerBlock) {
if (isThreadRunning()) {
stop();
}
bool threadShouldBeRunning = shouldBeRunning;
setShouldBeRunning(false);
isPrepared = false;
int requestedDataSize = prepareTask(sampleRate, samplesPerBlock);
consumer = std::make_unique<BufferConsumer>(requestedDataSize);
isPrepared = true;
if (shouldBeRunning) {
start();
}
setShouldBeRunning(threadShouldBeRunning);
}
void AudioBackgroundThread::setShouldBeRunning(bool shouldBeRunning, std::function<void()> stopCallback) {

Wyświetl plik

@ -58,7 +58,7 @@ void main() {
if (uRealScreen > 0.5) {
vec4 reflection = texture2D(uTexture4, vTexCoord);
vec4 screenGlow = texture2D(uTexture5, vTexCoord);
scatter += max4(screenGlow * reflection * max(1.0 - uAmbient, 0.0), vec4(0.0));
scatter += max4(screenGlow * reflection * max(1.0 - 0.5 * uAmbient, 0.0), vec4(0.0));
}
float light = line.r + uGlow * 1.5 * screen.g * screen.g * tightGlow.r;

Wyświetl plik

@ -6,6 +6,8 @@
RecordingSettings::RecordingSettings(RecordingParameters& ps) : parameters(ps) {
#if SOSCI_FEATURES
addAndMakeVisible(quality);
addAndMakeVisible(resolution);
addAndMakeVisible(frameRate);
addAndMakeVisible(losslessVideo);
addAndMakeVisible(recordAudio);
addAndMakeVisible(recordVideo);
@ -16,6 +18,11 @@ RecordingSettings::RecordingSettings(RecordingParameters& ps) : parameters(ps) {
quality.setSliderOnValueChange();
quality.setRangeEnabled(false);
resolution.setSliderOnValueChange();
resolution.setRangeEnabled(false);
frameRate.setSliderOnValueChange();
frameRate.setRangeEnabled(false);
recordAudio.onClick = [this] {
if (!recordAudio.getToggleState() && !recordVideo.getToggleState()) {
recordVideo.setToggleState(true, juce::NotificationType::sendNotification);
@ -66,6 +73,8 @@ void RecordingSettings::resized() {
#if SOSCI_FEATURES
losslessVideo.setBounds(area.removeFromTop(rowHeight));
quality.setBounds(area.removeFromTop(rowHeight).expanded(6, 0));
resolution.setBounds(area.removeFromTop(rowHeight).expanded(6, 0));
frameRate.setBounds(area.removeFromTop(rowHeight).expanded(6, 0));
recordAudio.setBounds(area.removeFromTop(rowHeight));
recordVideo.setBounds(area.removeFromTop(rowHeight));
auto row = area.removeFromTop(rowHeight);

Wyświetl plik

@ -13,6 +13,10 @@ public:
RecordingParameters() {
qualityParameter.disableLfo();
qualityParameter.disableSidechain();
resolution.disableLfo();
resolution.disableSidechain();
frameRate.disableLfo();
frameRate.disableSidechain();
}
private:
@ -36,6 +40,22 @@ public:
BooleanParameter recordAudio = BooleanParameter("Record Audio", "recordAudio", VERSION_HINT, true, "Record audio along with the video.");
BooleanParameter recordVideo = BooleanParameter("Record Video", "recordVideo", VERSION_HINT, sosciFeatures, "Record video output of the visualiser.");
EffectParameter resolution = EffectParameter(
"Resolution",
"The resolution of the recorded video. This only changes when not recording.",
"resolution",
VERSION_HINT, 1024, 128, 2048, 1.0
);
Effect resolutionEffect = Effect(&resolution);
EffectParameter frameRate = EffectParameter(
"Frame Rate",
"The frame rate of the recorded video. This only changes when not recording.",
"frameRate",
VERSION_HINT, 60.0, 10, 240, 0.01
);
Effect frameRateEffect = Effect(&frameRate);
juce::String compressionPreset = "fast";
@ -49,6 +69,12 @@ public:
auto qualityXml = settingsXml->createNewChildElement("quality");
qualityEffect.save(qualityXml);
auto resolutionXml = settingsXml->createNewChildElement("resolution");
resolutionEffect.save(resolutionXml);
auto frameRateXml = settingsXml->createNewChildElement("frameRate");
frameRateEffect.save(frameRateXml);
}
// opt to not change any values if not found
@ -72,6 +98,12 @@ public:
if (auto* qualityXml = settingsXml->getChildByName("quality")) {
qualityEffect.load(qualityXml);
}
if (auto* resolutionXml = settingsXml->getChildByName("resolution")) {
resolutionEffect.load(resolutionXml);
}
if (auto* frameRateXml = settingsXml->getChildByName("frameRate")) {
frameRateEffect.load(frameRateXml);
}
}
}
@ -95,6 +127,14 @@ public:
// not supported by all media players)
return 50 * (1.0 - quality) + 1;
}
int getVideoToolboxQuality() {
if (parameters.losslessVideo.getBoolValue()) {
return 100;
}
double quality = juce::jlimit(0.0, 1.0, parameters.qualityEffect.getValue());
return 100 * quality;
}
bool recordingVideo() {
return parameters.recordVideo.getBoolValue();
@ -114,11 +154,21 @@ public:
}
return parameters.customSharedTextureServerName;
}
int getResolution() {
return parameters.resolution.getValueUnnormalised();
}
double getFrameRate() {
return parameters.frameRate.getValueUnnormalised();
}
RecordingParameters& parameters;
private:
EffectComponent quality{parameters.qualityEffect};
EffectComponent resolution{parameters.resolutionEffect};
EffectComponent frameRate{parameters.frameRateEffect};
jux::SwitchButton losslessVideo{&parameters.losslessVideo};
jux::SwitchButton recordAudio{&parameters.recordAudio};

Wyświetl plik

@ -284,7 +284,7 @@ int VisualiserComponent::prepareTask(double sampleRate, int bufferSize) {
audioRecorder.setSampleRate(sampleRate);
int desiredBufferSize = sampleRate / FRAME_RATE;
int desiredBufferSize = sampleRate / recordingSettings.getFrameRate();
return desiredBufferSize;
}
@ -411,7 +411,7 @@ void VisualiserComponent::setRecording(bool recording) {
tempVideoFile = std::make_unique<juce::TemporaryFile>(".mp4");
juce::String resolution = std::to_string(renderTexture.width) + "x" + std::to_string(renderTexture.height);
juce::String cmd = "\"" + ffmpegFile.getFullPathName() + "\"" +
" -r " + juce::String(FRAME_RATE) +
" -r " + juce::String(recordingSettings.getFrameRate()) +
" -f rawvideo" +
" -pix_fmt rgba" +
" -s " + resolution +
@ -421,6 +421,14 @@ void VisualiserComponent::setRecording(bool recording) {
" -y" +
" -pix_fmt yuv420p" +
" -crf " + juce::String(recordingSettings.getCRF()) +
#if JUCE_MAC
#if JUCE_ARM
// use software encoding on Apple Silicon
" -c:v hevc_videotoolbox" +
" -q:v " + juce::String(recordingSettings.getVideoToolboxQuality()) +
" -tag:v hvc1" +
#endif
#endif
" -vf vflip" +
" \"" + tempVideoFile->getFile().getFullPathName() + "\"";
@ -717,6 +725,19 @@ void VisualiserComponent::renderOpenGL() {
// we have a new buffer to render
if (sampleBufferCount != prevSampleBufferCount) {
prevSampleBufferCount = sampleBufferCount;
if (!record.getToggleState()) {
// don't change resolution or framerate if recording
if (recordingSettings.getResolution() != renderTexture.width) {
setResolution(recordingSettings.getResolution());
}
if (recordingSettings.getFrameRate() != currentFrameRate) {
currentFrameRate = recordingSettings.getFrameRate();
prepare(sampleRate, -1);
setupArrays(RESAMPLE_RATIO * sampleRate / recordingSettings.getFrameRate());
}
}
juce::CriticalSection::ScopedLockType lock(samplesLock);
if (settings.parameters.upsamplingEnabled->getBoolValue()) {
@ -746,7 +767,7 @@ void VisualiserComponent::renderOpenGL() {
}
renderingSemaphore.release();
stopwatch.addTime(juce::RelativeTime::seconds(1.0 / FRAME_RATE));
stopwatch.addTime(juce::RelativeTime::seconds(1.0 / recordingSettings.getFrameRate()));
}
// render texture to screen
@ -821,12 +842,12 @@ void VisualiserComponent::setupTextures() {
glBindFramebuffer(GL_FRAMEBUFFER, frameBuffer);
// Create textures
lineTexture = makeTexture(1024, 1024);
lineTexture = makeTexture(recordingSettings.getResolution(), recordingSettings.getResolution());
blur1Texture = makeTexture(512, 512);
blur2Texture = makeTexture(512, 512);
blur3Texture = makeTexture(128, 128);
blur4Texture = makeTexture(128, 128);
renderTexture = makeTexture(1024, 1024);
renderTexture = makeTexture(recordingSettings.getResolution(), recordingSettings.getResolution());
screenOpenGLTexture.loadImage(emptyScreenImage);
screenTexture = { screenOpenGLTexture.getTextureID(), screenTextureImage.getWidth(), screenTextureImage.getHeight() };
@ -839,11 +860,13 @@ void VisualiserComponent::setupTextures() {
glBindFramebuffer(GL_FRAMEBUFFER, 0); // Unbind
}
Texture VisualiserComponent::makeTexture(int width, int height) {
Texture VisualiserComponent::makeTexture(int width, int height, GLuint textureID) {
using namespace juce::gl;
GLuint textureID;
glGenTextures(1, &textureID);
// replace existing texture if it exists, otherwise create new texture
if (textureID == 0) {
glGenTextures(1, &textureID);
}
glBindTexture(GL_TEXTURE_2D, textureID);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, width, height, 0, GL_RGBA, GL_FLOAT, nullptr);
@ -860,10 +883,20 @@ Texture VisualiserComponent::makeTexture(int width, int height) {
return { textureID, width, height };
}
void VisualiserComponent::setResolution(int width) {
using namespace juce::gl;
lineTexture = makeTexture(width, width, lineTexture.id);
renderTexture = makeTexture(width, width, renderTexture.id);
}
void VisualiserComponent::drawLineTexture(const std::vector<float>& xPoints, const std::vector<float>& yPoints, const std::vector<float>& zPoints) {
using namespace juce::gl;
fadeAmount = juce::jmin(1.0, std::pow(0.5, settings.getPersistence()) * 0.4);
double persistence = std::pow(0.5, settings.getPersistence()) * 0.4;
persistence *= 60.0 / recordingSettings.getFrameRate();
fadeAmount = juce::jmin(1.0, persistence);
activateTargetTexture(lineTexture);
fade();
drawLine(xPoints, yPoints, zPoints);
@ -1072,7 +1105,7 @@ void VisualiserComponent::drawCRT() {
activateTargetTexture(blur1Texture);
setShader(texturedShader.get());
texturedShader->setUniform("uResizeForCanvas", lineTexture.width / 1024.0f);
texturedShader->setUniform("uResizeForCanvas", lineTexture.width / (float) recordingSettings.getResolution());
drawTexture({lineTexture});
//horizontal blur 512x512
@ -1131,7 +1164,7 @@ void VisualiserComponent::drawCRT() {
outputShader->setUniform("uFishEye", screenOverlay == ScreenOverlay::VectorDisplay ? VECTOR_DISPLAY_FISH_EYE : 0.0f);
outputShader->setUniform("uRealScreen", settings.parameters.screenOverlay->isRealisticDisplay() ? 1.0f : 0.0f);
#endif
outputShader->setUniform("uResizeForCanvas", lineTexture.width / 1024.0f);
outputShader->setUniform("uResizeForCanvas", lineTexture.width / (float) recordingSettings.getResolution());
juce::Colour colour = juce::Colour::fromHSV(settings.getHue() / 360.0f, 1.0, 1.0, 1.0);
outputShader->setUniform("uColour", colour.getFloatRed(), colour.getFloatGreen(), colour.getFloatBlue());
drawTexture({
@ -1250,7 +1283,7 @@ Texture VisualiserComponent::createScreenTexture() {
glVertexAttribPointer(glGetAttribLocation(simpleShader->getProgramID(), "vertexPosition"), 2, GL_FLOAT, GL_FALSE, 0, nullptr);
glBindBuffer(GL_ARRAY_BUFFER, 0);
simpleShader->setUniform("colour", 0.01f, 0.05f, 0.01f, 1.0f);
glLineWidth(2.0f);
glLineWidth(4.0f);
glDrawArrays(GL_LINES, 0, data.size() / 2);
glBindTexture(GL_TEXTURE_2D, targetTexture.value().id);
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
@ -1306,7 +1339,7 @@ void VisualiserComponent::renderScope(const std::vector<float>& xPoints, const s
if (sampleRate != oldSampleRate || scratchVertices.empty()) {
oldSampleRate = sampleRate;
setupArrays(RESAMPLE_RATIO * sampleRate / FRAME_RATE);
setupArrays(RESAMPLE_RATIO * sampleRate / recordingSettings.getFrameRate());
}
intensity = settings.getIntensity() * (41000.0f / sampleRate);

Wyświetl plik

@ -82,7 +82,6 @@ private:
CommonAudioProcessor& audioProcessor;
float intensity;
const double FRAME_RATE = 60.0;
bool visualiserOnly;
AudioPlayerComponent audioPlayer{audioProcessor};
@ -194,6 +193,8 @@ private:
std::vector<float> fullScreenQuad;
GLuint frameBuffer = 0;
double currentFrameRate = 60.0;
Texture lineTexture;
Texture blur1Texture;
Texture blur2Texture;
@ -209,12 +210,12 @@ private:
juce::Image emptyScreenImage = juce::ImageFileFormat::loadFrom(BinaryData::empty_jpg, BinaryData::empty_jpgSize);
#if SOSCI_FEATURES
juce::Image oscilloscopeImage = juce::ImageFileFormat::loadFrom(BinaryData::real_jpg, BinaryData::real_jpgSize);
juce::Image vectorDisplayImage = juce::ImageFileFormat::loadFrom(BinaryData::vector_display_jpg, BinaryData::vector_display_jpgSize);
juce::Image oscilloscopeImage = juce::ImageFileFormat::loadFrom(BinaryData::real_png, BinaryData::real_pngSize);
juce::Image vectorDisplayImage = juce::ImageFileFormat::loadFrom(BinaryData::vector_display_png, BinaryData::vector_display_pngSize);
juce::Image emptyReflectionImage = juce::ImageFileFormat::loadFrom(BinaryData::no_reflection_jpg, BinaryData::no_reflection_jpgSize);
juce::Image oscilloscopeReflectionImage = juce::ImageFileFormat::loadFrom(BinaryData::real_reflection_jpg, BinaryData::real_reflection_jpgSize);
juce::Image vectorDisplayReflectionImage = juce::ImageFileFormat::loadFrom(BinaryData::vector_display_reflection_jpg, BinaryData::vector_display_reflection_jpgSize);
juce::Image oscilloscopeReflectionImage = juce::ImageFileFormat::loadFrom(BinaryData::real_reflection_png, BinaryData::real_reflection_pngSize);
juce::Image vectorDisplayReflectionImage = juce::ImageFileFormat::loadFrom(BinaryData::vector_display_reflection_png, BinaryData::vector_display_reflection_pngSize);
OsciPoint REAL_SCREEN_OFFSET = { 0.02, -0.15 };
OsciPoint REAL_SCREEN_SCALE = { 0.6 };
@ -252,7 +253,8 @@ private:
void initialiseSharedTexture();
void closeSharedTexture();
#endif
Texture makeTexture(int width, int height);
Texture makeTexture(int width, int height, GLuint textureID = 0);
void setResolution(int width);
void setupArrays(int num_points);
void setupTextures();
void drawLineTexture(const std::vector<float>& xPoints, const std::vector<float>& yPoints, const std::vector<float>& zPoints);

Wyświetl plik

@ -4,7 +4,7 @@
addUsingNamespaceToJuceHeader="0" jucerFormatVersion="1" pluginCharacteristicsValue="pluginWantsMidiIn"
pluginManufacturer="jameshball" aaxIdentifier="sh.ball.oscirender"
cppLanguageStandard="20" projectLineFeed="&#10;" headerPath="./include"
version="2.4.4.0" companyName="James H Ball" companyWebsite="https://osci-render.com"
version="2.4.5.0" companyName="James H Ball" companyWebsite="https://osci-render.com"
companyEmail="james@ball.sh" defines="NOMINMAX=1&#10;INTERNET_FLAG_NO_AUTO_REDIRECT=0&#10;SOSCI_FEATURES=1"
pluginAUMainType="'aumf'">
<MAINGROUP id="j5Ge2T" name="osci-render">
@ -37,13 +37,13 @@
<FILE id="RgmiPU" name="no_reflection.jpg" compile="0" resource="1"
file="Resources/oscilloscope/no_reflection.jpg"/>
<FILE id="dNtZYs" name="noise.jpg" compile="0" resource="1" file="Resources/oscilloscope/noise.jpg"/>
<FILE id="FyEDbA" name="real.jpg" compile="0" resource="1" file="Resources/oscilloscope/real.jpg"/>
<FILE id="v8E6y9" name="real_reflection.jpg" compile="0" resource="1"
file="Resources/oscilloscope/real_reflection.jpg"/>
<FILE id="QrCP4w" name="vector_display.jpg" compile="0" resource="1"
file="Resources/oscilloscope/vector_display.jpg"/>
<FILE id="s3VNsJ" name="vector_display_reflection.jpg" compile="0"
resource="1" file="Resources/oscilloscope/vector_display_reflection.jpg"/>
<FILE id="ZeLdkV" name="real.png" compile="0" resource="1" file="Resources/oscilloscope/real.png"/>
<FILE id="LRgixi" name="real_reflection.png" compile="0" resource="1"
file="Resources/oscilloscope/real_reflection.png"/>
<FILE id="arGLS1" name="vector_display.png" compile="0" resource="1"
file="Resources/oscilloscope/vector_display.png"/>
<FILE id="a6URcP" name="vector_display_reflection.png" compile="0"
resource="1" file="Resources/oscilloscope/vector_display_reflection.png"/>
</GROUP>
<GROUP id="{82BCD6F1-A8BF-F30B-5587-81EE70168883}" name="svg">
<FILE id="rl17ZK" name="cog.svg" compile="0" resource="1" file="Resources/svg/cog.svg"/>

Wyświetl plik

@ -3,7 +3,7 @@
<JUCERPROJECT id="HH2E72" name="sosci" projectType="audioplug" useAppConfig="0"
addUsingNamespaceToJuceHeader="0" jucerFormatVersion="1" pluginManufacturer="jameshball"
aaxIdentifier="sh.ball.sosci" cppLanguageStandard="20" projectLineFeed="&#10;"
headerPath="./include" version="1.0.4.0" companyName="James H Ball"
headerPath="./include" version="1.0.5.0" companyName="James H Ball"
companyWebsite="https://osci-render.com" companyEmail="james@ball.sh"
defines="NOMINMAX=1&#10;INTERNET_FLAG_NO_AUTO_REDIRECT=0&#10;SOSCI_FEATURES=1"
pluginManufacturerCode="Jhba" pluginCode="Sosc" pluginAUMainType="'aufx'">
@ -32,13 +32,13 @@
<FILE id="ZgcesA" name="no_reflection.jpg" compile="0" resource="1"
file="Resources/oscilloscope/no_reflection.jpg"/>
<FILE id="dNtZYs" name="noise.jpg" compile="0" resource="1" file="Resources/oscilloscope/noise.jpg"/>
<FILE id="xxXx4Q" name="real.jpg" compile="0" resource="1" file="Resources/oscilloscope/real.jpg"/>
<FILE id="nuEXXn" name="real_reflection.jpg" compile="0" resource="1"
file="Resources/oscilloscope/real_reflection.jpg"/>
<FILE id="bdQp0Q" name="vector_display.jpg" compile="0" resource="1"
file="Resources/oscilloscope/vector_display.jpg"/>
<FILE id="XojumY" name="vector_display_reflection.jpg" compile="0"
resource="1" file="Resources/oscilloscope/vector_display_reflection.jpg"/>
<FILE id="LAmlcm" name="real.png" compile="0" resource="1" file="Resources/oscilloscope/real.png"/>
<FILE id="FKUOID" name="real_reflection.png" compile="0" resource="1"
file="Resources/oscilloscope/real_reflection.png"/>
<FILE id="P9kYdq" name="vector_display.png" compile="0" resource="1"
file="Resources/oscilloscope/vector_display.png"/>
<FILE id="IiqBke" name="vector_display_reflection.png" compile="0"
resource="1" file="Resources/oscilloscope/vector_display_reflection.png"/>
</GROUP>
<GROUP id="{08DE8F94-4A00-7C71-4AF3-4C34C821A5DF}" name="sosci">
<FILE id="jtOYDo" name="clean.sosci" compile="0" resource="1" file="Resources/sosci/clean.sosci"/>