kopia lustrzana https://github.com/jameshball/osci-render
Make DAW parameters update when GUI changes and vice versa and fix several bugs
rodzic
d8bb084cac
commit
23bfcaee7d
|
@ -4,7 +4,6 @@
|
||||||
LineArtComponent::LineArtComponent(OscirenderAudioProcessor& p, OscirenderAudioProcessorEditor& editor) : audioProcessor(p), pluginEditor(editor) {
|
LineArtComponent::LineArtComponent(OscirenderAudioProcessor& p, OscirenderAudioProcessorEditor& editor) : audioProcessor(p), pluginEditor(editor) {
|
||||||
setText("Line Art Settings");
|
setText("Line Art Settings");
|
||||||
|
|
||||||
|
|
||||||
addAndMakeVisible(animate);
|
addAndMakeVisible(animate);
|
||||||
addAndMakeVisible(sync);
|
addAndMakeVisible(sync);
|
||||||
addAndMakeVisible(rateLabel);
|
addAndMakeVisible(rateLabel);
|
||||||
|
@ -12,11 +11,11 @@ LineArtComponent::LineArtComponent(OscirenderAudioProcessor& p, OscirenderAudioP
|
||||||
addAndMakeVisible(offsetLabel);
|
addAndMakeVisible(offsetLabel);
|
||||||
addAndMakeVisible(offsetBox);
|
addAndMakeVisible(offsetBox);
|
||||||
|
|
||||||
rateLabel.setText("Framerate: ", juce::dontSendNotification);
|
rateLabel.setText("Framerate", juce::dontSendNotification);
|
||||||
rateBox.setValue(audioProcessor.animationRate->getValueUnnormalised(), false, 2);
|
rateBox.setValue(audioProcessor.animationRate->getValueUnnormalised(), false, 2);
|
||||||
rateBox.setJustification(juce::Justification::left);
|
rateBox.setJustification(juce::Justification::left);
|
||||||
|
|
||||||
offsetLabel.setText(" Offset: ", juce::dontSendNotification);
|
offsetLabel.setText("Offset", juce::dontSendNotification);
|
||||||
offsetBox.setValue(audioProcessor.animationOffset->getValueUnnormalised(), false, 2);
|
offsetBox.setValue(audioProcessor.animationOffset->getValueUnnormalised(), false, 2);
|
||||||
offsetBox.setJustification(juce::Justification::left);
|
offsetBox.setJustification(juce::Justification::left);
|
||||||
|
|
||||||
|
@ -24,16 +23,28 @@ LineArtComponent::LineArtComponent(OscirenderAudioProcessor& p, OscirenderAudioP
|
||||||
update();
|
update();
|
||||||
|
|
||||||
auto updateAnimation = [this]() {
|
auto updateAnimation = [this]() {
|
||||||
audioProcessor.animateLineArt->setValue(animate.getToggleState());
|
audioProcessor.animateLineArt->setValueNotifyingHost(animate.getToggleState());
|
||||||
audioProcessor.syncMIDIAnimation->setValue(sync.getToggleState());
|
audioProcessor.syncMIDIAnimation->setValueNotifyingHost(sync.getToggleState());
|
||||||
audioProcessor.animationRate->setValueUnnormalised(rateBox.getValue());
|
audioProcessor.animationRate->setUnnormalisedValueNotifyingHost(rateBox.getValue());
|
||||||
audioProcessor.animationOffset->setValueUnnormalised(offsetBox.getValue());
|
audioProcessor.animationOffset->setUnnormalisedValueNotifyingHost(offsetBox.getValue());
|
||||||
};
|
};
|
||||||
|
|
||||||
animate.onClick = updateAnimation;
|
animate.onClick = updateAnimation;
|
||||||
sync.onClick = updateAnimation;
|
sync.onClick = updateAnimation;
|
||||||
rateBox.onFocusLost = updateAnimation;
|
rateBox.onTextChange = updateAnimation;
|
||||||
offsetBox.onFocusLost = updateAnimation;
|
offsetBox.onTextChange = updateAnimation;
|
||||||
|
|
||||||
|
audioProcessor.animateLineArt->addListener(this);
|
||||||
|
audioProcessor.syncMIDIAnimation->addListener(this);
|
||||||
|
audioProcessor.animationRate->addListener(this);
|
||||||
|
audioProcessor.animationOffset->addListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
LineArtComponent::~LineArtComponent() {
|
||||||
|
audioProcessor.animationOffset->removeListener(this);
|
||||||
|
audioProcessor.animationRate->removeListener(this);
|
||||||
|
audioProcessor.syncMIDIAnimation->removeListener(this);
|
||||||
|
audioProcessor.animateLineArt->removeListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LineArtComponent::resized() {
|
void LineArtComponent::resized() {
|
||||||
|
@ -65,3 +76,13 @@ void LineArtComponent::update() {
|
||||||
animate.setToggleState(audioProcessor.animateLineArt->getValue(), true);
|
animate.setToggleState(audioProcessor.animateLineArt->getValue(), true);
|
||||||
sync.setToggleState(audioProcessor.syncMIDIAnimation->getValue(), true);
|
sync.setToggleState(audioProcessor.syncMIDIAnimation->getValue(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LineArtComponent::parameterValueChanged(int parameterIndex, float newValue) {
|
||||||
|
triggerAsyncUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
void LineArtComponent::parameterGestureChanged(int parameterIndex, bool gestureIsStarting) {}
|
||||||
|
|
||||||
|
void LineArtComponent::handleAsyncUpdate() {
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
|
@ -5,11 +5,15 @@
|
||||||
#include "components/DoubleTextBox.h"
|
#include "components/DoubleTextBox.h"
|
||||||
|
|
||||||
class OscirenderAudioProcessorEditor;
|
class OscirenderAudioProcessorEditor;
|
||||||
class LineArtComponent : public juce::GroupComponent, public juce::MouseListener {
|
class LineArtComponent : public juce::GroupComponent, public juce::AudioProcessorParameter::Listener, juce::AsyncUpdater {
|
||||||
public:
|
public:
|
||||||
LineArtComponent(OscirenderAudioProcessor&, OscirenderAudioProcessorEditor&);
|
LineArtComponent(OscirenderAudioProcessor&, OscirenderAudioProcessorEditor&);
|
||||||
|
~LineArtComponent();
|
||||||
|
|
||||||
void resized() override;
|
void resized() override;
|
||||||
|
void parameterValueChanged(int parameterIndex, float newValue) override;
|
||||||
|
void parameterGestureChanged(int parameterIndex, bool gestureIsStarting) override;
|
||||||
|
void handleAsyncUpdate() override;
|
||||||
void update();
|
void update();
|
||||||
private:
|
private:
|
||||||
OscirenderAudioProcessor& audioProcessor;
|
OscirenderAudioProcessor& audioProcessor;
|
||||||
|
@ -20,7 +24,7 @@ private:
|
||||||
juce::Label rateLabel{ "Framerate","Framerate"};
|
juce::Label rateLabel{ "Framerate","Framerate"};
|
||||||
juce::Label offsetLabel{ "Offset","Offset" };
|
juce::Label offsetLabel{ "Offset","Offset" };
|
||||||
DoubleTextBox rateBox{ -256, 256 };
|
DoubleTextBox rateBox{ -256, 256 };
|
||||||
DoubleTextBox offsetBox{ -8192,8192 };
|
DoubleTextBox offsetBox{ -8192, 8192 };
|
||||||
|
|
||||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(LineArtComponent)
|
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(LineArtComponent)
|
||||||
};
|
};
|
|
@ -662,7 +662,10 @@ void OscirenderAudioProcessor::processBlock(juce::AudioBuffer<float>& buffer, ju
|
||||||
}
|
}
|
||||||
if ((currentFile >= 0) ? (sounds[currentFile]->parser->isAnimatable) : false) {
|
if ((currentFile >= 0) ? (sounds[currentFile]->parser->isAnimatable) : false) {
|
||||||
int animFrame = (int)(animationTime * animationRate->getValueUnnormalised() + animationOffset->getValueUnnormalised());
|
int animFrame = (int)(animationTime * animationRate->getValueUnnormalised() + animationOffset->getValueUnnormalised());
|
||||||
sounds[currentFile]->parser->getLineArt()->setFrame(animFrame);
|
auto lineArt = sounds[currentFile]->parser->getLineArt();
|
||||||
|
if (lineArt != nullptr) {
|
||||||
|
lineArt->setFrame(animFrame);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ public:
|
||||||
// only keep negative sign at beginning
|
// only keep negative sign at beginning
|
||||||
if (text.contains("-")) {
|
if (text.contains("-")) {
|
||||||
juce::String remainder = text.substring(1);
|
juce::String remainder = text.substring(1);
|
||||||
remainder = remainder.retainCharacters("0123456789");
|
remainder = remainder.retainCharacters("0123456789.");
|
||||||
text = text.substring(0, 1) + remainder;
|
text = text.substring(0, 1) + remainder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -83,7 +83,9 @@ void LineArtParser::parseJsonFrames(juce::String jsonStr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void LineArtParser::setFrame(int fNum) {
|
void LineArtParser::setFrame(int fNum) {
|
||||||
frameNumber = fNum % numFrames;
|
// Ensure that the frame number is within the bounds of the number of frames
|
||||||
|
// This weird modulo trick is to handle negative numbers
|
||||||
|
frameNumber = (numFrames + (fNum % numFrames)) % numFrames;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::unique_ptr<Shape>> LineArtParser::draw() {
|
std::vector<std::unique_ptr<Shape>> LineArtParser::draw() {
|
||||||
|
|
|
@ -16,6 +16,7 @@ import bmesh
|
||||||
import socket
|
import socket
|
||||||
import json
|
import json
|
||||||
import atexit
|
import atexit
|
||||||
|
from bpy.props import StringProperty
|
||||||
from bpy.app.handlers import persistent
|
from bpy.app.handlers import persistent
|
||||||
from bpy_extras.io_utils import ImportHelper
|
from bpy_extras.io_utils import ImportHelper
|
||||||
|
|
||||||
|
@ -67,21 +68,26 @@ class osci_render_save(bpy.types.Operator, ImportHelper):
|
||||||
bl_label = "Save Line Art"
|
bl_label = "Save Line Art"
|
||||||
bl_idname = "render.osci_render_save"
|
bl_idname = "render.osci_render_save"
|
||||||
bl_description = "Save line art to the chosen file"
|
bl_description = "Save line art to the chosen file"
|
||||||
filter_glob: bpy.props.StringProperty(
|
filename_ext = ".gpla"
|
||||||
|
|
||||||
|
filter_glob: StringProperty(
|
||||||
default="*.gpla",
|
default="*.gpla",
|
||||||
options={"HIDDEN"}
|
options={"HIDDEN"}
|
||||||
)
|
)
|
||||||
|
|
||||||
def execute(self,context):
|
def execute(self, context):
|
||||||
FilePath = self.filepath
|
FilePath = self.filepath
|
||||||
filename, extension = os.path.splitext(self.filepath)
|
filename, extension = os.path.splitext(self.filepath)
|
||||||
if (extension != ".gpla"):
|
|
||||||
|
if extension != ".gpla":
|
||||||
extension = ".gpla"
|
extension = ".gpla"
|
||||||
FilePath = FilePath + ".gpla"
|
FilePath = FilePath + ".gpla"
|
||||||
|
|
||||||
self.report({"INFO"}, FilePath)
|
self.report({"INFO"}, FilePath)
|
||||||
|
|
||||||
if filename is not None and extension is not None:
|
if filename is not None and extension is not None:
|
||||||
fin = save_scene_to_file(bpy.context.scene, FilePath)
|
fin = save_scene_to_file(bpy.context.scene, FilePath)
|
||||||
if (fin == 0):
|
if fin == 0:
|
||||||
self.report({"INFO"}, "File write successful!")
|
self.report({"INFO"}, "File write successful!")
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
else:
|
else:
|
||||||
|
|
Ładowanie…
Reference in New Issue