kopia lustrzana https://github.com/jameshball/osci-render
Remove redundant connection to old web-based software oscilloscope, and make visualiser centered
rodzic
9bfdca7b99
commit
b630a1b7cb
|
@ -16,11 +16,17 @@
|
||||||
height: 100%;
|
height: 100%;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
canvas {
|
canvas {
|
||||||
display: block;
|
width: min(100vw, 100vh);
|
||||||
margin: auto;
|
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 {
|
#overlay {
|
||||||
|
@ -119,15 +125,6 @@
|
||||||
|
|
||||||
let isDebug = true;
|
let isDebug = true;
|
||||||
let paused = false;
|
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 openInAnotherWindow = false;
|
||||||
let externalSampleRate = 96000;
|
let externalSampleRate = 96000;
|
||||||
let externalBufferSize = 1920;
|
let externalBufferSize = 1920;
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
#include "audio/ShapeVoice.h"
|
#include "audio/ShapeVoice.h"
|
||||||
#include "audio/PublicSynthesiser.h"
|
#include "audio/PublicSynthesiser.h"
|
||||||
#include <numbers>
|
#include <numbers>
|
||||||
#include "audio/AudioWebSocketServer.h"
|
|
||||||
#include "audio/DelayEffect.h"
|
#include "audio/DelayEffect.h"
|
||||||
#include "audio/PitchDetector.h"
|
#include "audio/PitchDetector.h"
|
||||||
#include "audio/WobbleEffect.h"
|
#include "audio/WobbleEffect.h"
|
||||||
|
@ -316,7 +315,6 @@ private:
|
||||||
PublicSynthesiser synth;
|
PublicSynthesiser synth;
|
||||||
bool retriggerMidi = true;
|
bool retriggerMidi = true;
|
||||||
|
|
||||||
AudioWebSocketServer softwareOscilloscopeServer{*this};
|
|
||||||
ObjectServer objectServer{*this};
|
ObjectServer objectServer{*this};
|
||||||
|
|
||||||
const double VOLUME_BUFFER_SECONDS = 0.1;
|
const double VOLUME_BUFFER_SECONDS = 0.1;
|
||||||
|
|
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -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;
|
|
||||||
};
|
|
|
@ -275,6 +275,7 @@ void VisualiserComponent::initialiseBrowser() {
|
||||||
.withUserDataFolder(juce::File::getSpecialLocation(juce::File::SpecialLocationType::userApplicationDataDirectory).getChildFile("osci-render"))
|
.withUserDataFolder(juce::File::getSpecialLocation(juce::File::SpecialLocationType::userApplicationDataDirectory).getChildFile("osci-render"))
|
||||||
.withStatusBarDisabled()
|
.withStatusBarDisabled()
|
||||||
.withBuiltInErrorPageDisabled()
|
.withBuiltInErrorPageDisabled()
|
||||||
|
.withBackgroundColour(Colours::dark)
|
||||||
)
|
)
|
||||||
.withNativeFunction("toggleFullscreen", [this](auto& var, auto complete) {
|
.withNativeFunction("toggleFullscreen", [this](auto& var, auto complete) {
|
||||||
enableFullScreen();
|
enableFullScreen();
|
||||||
|
@ -295,9 +296,6 @@ void VisualiserComponent::initialiseBrowser() {
|
||||||
.withNativeFunction("isOverlay", [this](auto& var, auto complete) {
|
.withNativeFunction("isOverlay", [this](auto& var, auto complete) {
|
||||||
complete(parent != nullptr);
|
complete(parent != nullptr);
|
||||||
})
|
})
|
||||||
.withNativeFunction("isPaused", [this](auto& var, auto complete) {
|
|
||||||
complete(!active);
|
|
||||||
})
|
|
||||||
.withNativeFunction("pause", [this](auto& var, auto complete) {
|
.withNativeFunction("pause", [this](auto& var, auto complete) {
|
||||||
setPaused(active);
|
setPaused(active);
|
||||||
})
|
})
|
||||||
|
|
|
@ -63,10 +63,6 @@
|
||||||
</GROUP>
|
</GROUP>
|
||||||
<GROUP id="{75439074-E50C-362F-1EDF-8B4BE9011259}" name="Source">
|
<GROUP id="{75439074-E50C-362F-1EDF-8B4BE9011259}" name="Source">
|
||||||
<GROUP id="{85A33213-D880-BD92-70D8-1901DA6D23F0}" name="audio">
|
<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 id="NWuowi" name="BitCrushEffect.cpp" compile="1" resource="0"
|
||||||
file="Source/audio/BitCrushEffect.cpp"/>
|
file="Source/audio/BitCrushEffect.cpp"/>
|
||||||
<FILE id="Bc8UeW" name="BitCrushEffect.h" compile="0" resource="0"
|
<FILE id="Bc8UeW" name="BitCrushEffect.h" compile="0" resource="0"
|
||||||
|
|
Ładowanie…
Reference in New Issue