Use audio processor properties instead of manually loading and saving

pull/282/head
James H Ball 2025-02-03 14:33:53 +00:00
rodzic f0c185e538
commit 0eb21a0a70
6 zmienionych plików z 9 dodań i 25 usunięć

Wyświetl plik

@ -184,11 +184,6 @@ OscirenderAudioProcessor::OscirenderAudioProcessor() : CommonAudioProcessor(Buse
synth.addSound(defaultSound); synth.addSound(defaultSound);
addAllParameters(); addAllParameters();
if (objectServerPort == 0) {
objectServerPort = 51677;
objectServer.reload();
}
} }
OscirenderAudioProcessor::~OscirenderAudioProcessor() { OscirenderAudioProcessor::~OscirenderAudioProcessor() {
@ -412,7 +407,7 @@ void OscirenderAudioProcessor::setObjectServerRendering(bool enabled) {
} }
void OscirenderAudioProcessor::setObjectServerPort(int port) { void OscirenderAudioProcessor::setObjectServerPort(int port) {
objectServerPort = port; setProperty("objectServerPort", port);
objectServer.reload(); objectServer.reload();
} }
@ -674,8 +669,6 @@ void OscirenderAudioProcessor::getStateInformation(juce::MemoryBlock& destData)
} }
xml->setAttribute("currentFile", currentFile); xml->setAttribute("currentFile", currentFile);
xml->setAttribute("objectServerPort", objectServerPort);
recordingParameters.save(xml.get()); recordingParameters.save(xml.get());
saveProperties(*xml); saveProperties(*xml);
@ -793,12 +786,10 @@ void OscirenderAudioProcessor::setStateInformation(const void* data, int sizeInB
} }
changeCurrentFile(xml->getIntAttribute("currentFile", -1)); changeCurrentFile(xml->getIntAttribute("currentFile", -1));
objectServerPort = xml->getIntAttribute("objectServerPort", juce::Random::getSystemRandom().nextInt(juce::Range<int>(51600, 51700)));
objectServer.reload();
recordingParameters.load(xml.get()); recordingParameters.load(xml.get());
loadProperties(*xml); loadProperties(*xml);
objectServer.reload();
broadcaster.sendChangeMessage(); broadcaster.sendChangeMessage();
prevMidiEnabled = !midiEnabled->getBoolValue(); prevMidiEnabled = !midiEnabled->getBoolValue();

Wyświetl plik

@ -184,8 +184,6 @@ public:
std::function<void()> haltRecording; std::function<void()> haltRecording;
int objectServerPort = 0;
void addLuaSlider(); void addLuaSlider();
void updateEffectPrecedence(); void updateEffectPrecedence();
void updateFileBlock(int index, std::shared_ptr<juce::MemoryBlock> block); void updateFileBlock(int index, std::shared_ptr<juce::MemoryBlock> block);

Wyświetl plik

@ -1,6 +1,6 @@
#include "AboutComponent.h" #include "AboutComponent.h"
AboutComponent::AboutComponent(const void *image, size_t imageSize, juce::String sectionText, int* port) { AboutComponent::AboutComponent(const void *image, size_t imageSize, juce::String sectionText, int port) {
addAndMakeVisible(logoComponent); addAndMakeVisible(logoComponent);
addAndMakeVisible(text); addAndMakeVisible(text);
addAndMakeVisible(portText); addAndMakeVisible(portText);
@ -26,11 +26,7 @@ AboutComponent::AboutComponent(const void *image, size_t imageSize, juce::String
portText.setColour(juce::TextEditor::backgroundColourId, juce::Colours::transparentBlack); portText.setColour(juce::TextEditor::backgroundColourId, juce::Colours::transparentBlack);
portText.setColour(juce::TextEditor::outlineColourId, juce::Colours::transparentBlack); portText.setColour(juce::TextEditor::outlineColourId, juce::Colours::transparentBlack);
portText.setJustification(juce::Justification(juce::Justification::centred)); portText.setJustification(juce::Justification(juce::Justification::centred));
portText.setText(juce::String("Blender Port: ") + ((port != nullptr) ? juce::String(*port) : juce::String("<error>"))); portText.setText(juce::String("Blender Port: ") + juce::String(port));
}
void AboutComponent::updatePortText(int* port) {
portText.setText(juce::String("Blender Port: ") + ((port != nullptr) ? juce::String(*port) : juce::String("<error>")));
} }
void AboutComponent::resized() { void AboutComponent::resized() {

Wyświetl plik

@ -4,10 +4,9 @@
class AboutComponent : public juce::Component { class AboutComponent : public juce::Component {
public: public:
AboutComponent(const void *image, size_t imageSize, juce::String sectionText, int* port); AboutComponent(const void *image, size_t imageSize, juce::String sectionText, int port);
void resized() override; void resized() override;
void updatePortText(int* port);
private: private:
juce::Image logo; juce::Image logo;

Wyświetl plik

@ -32,7 +32,7 @@ OsciMainMenuBarModel::OsciMainMenuBarModel(OscirenderAudioProcessor& p, Oscirend
"BUS ERROR Collective, for providing the source code for the Hilligoss encoder\n" "BUS ERROR Collective, for providing the source code for the Hilligoss encoder\n"
"Jean Perbet (@jeanprbt) for the osci-render macOS icon\n" "Jean Perbet (@jeanprbt) for the osci-render macOS icon\n"
"All the community, for suggesting features and reporting issues!", "All the community, for suggesting features and reporting issues!",
&audioProcessor.objectServerPort); std::any_cast<int>(audioProcessor.getProperty("objectServerPort")));
options.content.setOwned(about); options.content.setOwned(about);
options.content->setSize(500, 270); options.content->setSize(500, 270);
options.dialogTitle = "About"; options.dialogTitle = "About";
@ -48,9 +48,9 @@ OsciMainMenuBarModel::OsciMainMenuBarModel(OscirenderAudioProcessor& p, Oscirend
juce::DialogWindow* dw = options.launchAsync(); juce::DialogWindow* dw = options.launchAsync();
}); });
addMenuItem(1, "Randomize Port", [this] { addMenuItem(1, "Randomize Blender Port", [this] {
audioProcessor.setObjectServerPort(juce::Random::getSystemRandom().nextInt(juce::Range<int>(51600, 51700))); audioProcessor.setObjectServerPort(juce::Random::getSystemRandom().nextInt(juce::Range<int>(51600, 51700)));
}); });
#if !SOSCI_FEATURES #if !SOSCI_FEATURES
addMenuItem(1, "Purchase osci-render premium!", [this] { addMenuItem(1, "Purchase osci-render premium!", [this] {

Wyświetl plik

@ -16,7 +16,7 @@ void ObjectServer::reload() {
} }
void ObjectServer::run() { void ObjectServer::run() {
port = audioProcessor.objectServerPort; port = std::any_cast<int>(audioProcessor.getProperty("objectServerPort", 51677));
if (socket.createListener(port, "127.0.0.1")) { if (socket.createListener(port, "127.0.0.1")) {
// preallocating a large buffer to avoid allocations in the loop // preallocating a large buffer to avoid allocations in the loop
std::unique_ptr<char[]> message{ new char[10 * 1024 * 1024] }; std::unique_ptr<char[]> message{ new char[10 * 1024 * 1024] };