Remove redundant connection to old web-based software oscilloscope, and make visualiser centered

pull/249/head
James H Ball 2024-08-21 10:27:45 +01:00 zatwierdzone przez James H Ball
rodzic 9bfdca7b99
commit b630a1b7cb
6 zmienionych plików z 12 dodań i 111 usunięć

Wyświetl plik

@ -16,11 +16,17 @@
height: 100%;
width: 100%;
overflow: hidden;
}
canvas {
display: block;
margin: auto;
}
canvas {
width: min(100vw, 100vh);
height: min(100vw, 100vh);
position: absolute;
top: calc(calc(100vh - min(100vw, 100vh)) / 2);
left: calc(calc(100vw - min(100vw, 100vh)) / 2);
display: block;
margin: auto;
z-index: -1;
}
#overlay {
@ -119,15 +125,6 @@
let isDebug = true;
let paused = false;
Juce.getNativeFunction("isPaused")().then(isPaused => {
paused = isPaused;
if (isPaused) {
overlay.style.display = "flex";
} else {
overlay.style.display = "none";
}
});
let openInAnotherWindow = false;
let externalSampleRate = 96000;
let externalBufferSize = 1920;

Wyświetl plik

@ -16,7 +16,6 @@
#include "audio/ShapeVoice.h"
#include "audio/PublicSynthesiser.h"
#include <numbers>
#include "audio/AudioWebSocketServer.h"
#include "audio/DelayEffect.h"
#include "audio/PitchDetector.h"
#include "audio/WobbleEffect.h"
@ -316,7 +315,6 @@ private:
PublicSynthesiser synth;
bool retriggerMidi = true;
AudioWebSocketServer softwareOscilloscopeServer{*this};
ObjectServer objectServer{*this};
const double VOLUME_BUFFER_SECONDS = 0.1;

Wyświetl plik

@ -1,67 +0,0 @@
#include "AudioWebSocketServer.h"
#include "../PluginProcessor.h"
AudioWebSocketServer::AudioWebSocketServer(OscirenderAudioProcessor& audioProcessor) : juce::Thread("AudioWebSocketServer"), audioProcessor(audioProcessor) {
server.setOnClientMessageCallback([](std::shared_ptr<ix::ConnectionState> connectionState, ix::WebSocket & webSocket, const ix::WebSocketMessagePtr & msg) {
// The ConnectionState object contains information about the connection,
// at this point only the client ip address and the port.
DBG("Remote ip: " << connectionState->getRemoteIp());
if (msg->type == ix::WebSocketMessageType::Open) {
DBG("New connection");
// A connection state object is available, and has a default id
// You can subclass ConnectionState and pass an alternate factory
// to override it. It is useful if you want to store custom
// attributes per connection (authenticated bool flag, attributes, etc...)
DBG("id: " << connectionState->getId());
// The uri the client did connect to.
DBG("Uri: " << msg->openInfo.uri);
DBG("Headers:");
for (auto it : msg->openInfo.headers) {
DBG("\t" << it.first << ": " << it.second);
}
}
});
ix::initNetSystem();
auto res = server.listen();
if (res.first) {
server.disablePerMessageDeflate();
server.start();
startThread();
}
// TODO: don't silently fail
}
AudioWebSocketServer::~AudioWebSocketServer() {
server.stop();
ix::uninitNetSystem();
audioProcessor.consumerStop(consumer);
stopThread(1000);
}
void AudioWebSocketServer::run() {
while (!threadShouldExit()) {
consumer = audioProcessor.consumerRegister(floatBuffer);
audioProcessor.consumerRead(consumer);
for (int i = 0; i < floatBuffer.size(); i++) {
short sample = floatBuffer[i] * 32767;
char b0 = sample & 0xff;
char b1 = (sample >> 8) & 0xff;
buffer[2 * i] = b0;
buffer[2 * i + 1] = b1;
}
for (auto&& client : server.getClients()) {
ix::IXWebSocketSendData data{buffer, sizeof(buffer)};
client->sendBinary(data);
}
}
}

Wyświetl plik

@ -1,21 +0,0 @@
#pragma once
#include <JuceHeader.h>
#include "../ixwebsocket/IXWebSocketServer.h"
#include "../concurrency/BufferConsumer.h"
class OscirenderAudioProcessor;
class AudioWebSocketServer : juce::Thread {
public:
AudioWebSocketServer(OscirenderAudioProcessor& audioProcessor);
~AudioWebSocketServer();
void run() override;
private:
ix::WebSocketServer server{ 42988 };
OscirenderAudioProcessor& audioProcessor;
std::vector<float> floatBuffer = std::vector<float>(2 * 4096);
char buffer[4096 * 2 * 2];
std::shared_ptr<BufferConsumer> consumer;
};

Wyświetl plik

@ -275,6 +275,7 @@ void VisualiserComponent::initialiseBrowser() {
.withUserDataFolder(juce::File::getSpecialLocation(juce::File::SpecialLocationType::userApplicationDataDirectory).getChildFile("osci-render"))
.withStatusBarDisabled()
.withBuiltInErrorPageDisabled()
.withBackgroundColour(Colours::dark)
)
.withNativeFunction("toggleFullscreen", [this](auto& var, auto complete) {
enableFullScreen();
@ -295,9 +296,6 @@ void VisualiserComponent::initialiseBrowser() {
.withNativeFunction("isOverlay", [this](auto& var, auto complete) {
complete(parent != nullptr);
})
.withNativeFunction("isPaused", [this](auto& var, auto complete) {
complete(!active);
})
.withNativeFunction("pause", [this](auto& var, auto complete) {
setPaused(active);
})

Wyświetl plik

@ -63,10 +63,6 @@
</GROUP>
<GROUP id="{75439074-E50C-362F-1EDF-8B4BE9011259}" name="Source">
<GROUP id="{85A33213-D880-BD92-70D8-1901DA6D23F0}" name="audio">
<FILE id="WDV6eI" name="AudioWebSocketServer.cpp" compile="1" resource="0"
file="Source/audio/AudioWebSocketServer.cpp"/>
<FILE id="RD41Jd" name="AudioWebSocketServer.h" compile="0" resource="0"
file="Source/audio/AudioWebSocketServer.h"/>
<FILE id="NWuowi" name="BitCrushEffect.cpp" compile="1" resource="0"
file="Source/audio/BitCrushEffect.cpp"/>
<FILE id="Bc8UeW" name="BitCrushEffect.h" compile="0" resource="0"