14#ifndef JucePlugin_PreferredChannelConfigurations
17#
if !JucePlugin_IsMidiEffect
18#
if !JucePlugin_IsSynth
19 .withInput(
"Input", juce::AudioChannelSet::stereo(),
true)
21 .withOutput(
"Output", juce::AudioChannelSet::stereo(),
true)
26 *
this,
nullptr, juce::Identifier(
"PARAMETERS"),
29 std::make_unique<juce::AudioParameterBool>(
"drawGrid",
31 std::make_unique<juce::AudioParameterFloat>(
32 "bufferLength",
"Scope Length", 0.05, 1, 0.2),
33 std::make_unique<juce::AudioParameterBool>(
34 "isProfessional",
"Professional View",
false),
35 std::make_unique<juce::AudioParameterBool>(
"isTriggered",
37 std::make_unique<juce::AudioParameterBool>(
"slopeButtonTriggered",
39 std::make_unique<juce::AudioParameterBool>(
"autoTriggered",
41 std::make_unique<juce::AudioParameterFloat>(
42 "triggerLevel",
"Trigger Level", 0.05, 1, 0.2),
43 std::make_unique<juce::AudioParameterFloat>(
44 "decayTime",
"Decay Time", 0.05, 1,
static_cast<float>(0.2)),
45 std::make_unique<juce::AudioParameterBool>(
"muteOutput",
"Mute",
50 if (juce::SystemStats::getOperatingSystemType() ==
51 juce::SystemStats::OperatingSystemType::Android) {
52 processorTreeState.getParameter(
"muteOutput")->setValueNotifyingHost(
true);
56 audioBufferQueue.reset(
63void OscilloscopeAudioProcessor::resetAllValuesToDefault(juce::ValueTree tree) {
64 for (
int i = 0; i < tree.getNumChildren(); ++i) {
65 juce::ValueTree child = tree.getChild(i);
68 if (child.hasProperty(
"defaultValue")) {
70 child.setProperty(
"value", child.getProperty(
"defaultValue"),
nullptr);
74 resetAllValuesToDefault(child);
80 return JucePlugin_Name;
84#if JucePlugin_WantsMidiInput
92#if JucePlugin_ProducesMidiOutput
100#if JucePlugin_IsMidiEffect
124 int index,
const juce::String &newName) {}
128 int samplesPerBlock) {
130 this->sampleRate = sampleRate;
140#ifndef JucePlugin_PreferredChannelConfigurations
142 const BusesLayout &layouts)
const {
143#if JucePlugin_IsMidiEffect
144 juce::ignoreUnused(layouts);
151 if (layouts.getMainOutputChannelSet() != juce::AudioChannelSet::mono() &&
152 layouts.getMainOutputChannelSet() != juce::AudioChannelSet::stereo())
156#if !JucePlugin_IsSynth
157 if (layouts.getMainOutputChannelSet() != layouts.getMainInputChannelSet())
167 juce::MidiBuffer &midiMessages) {
168 juce::ScopedNoDenormals noDenormals;
169 auto totalNumInputChannels = getTotalNumInputChannels();
170 auto totalNumOutputChannels = getTotalNumOutputChannels();
172 for (
int i = totalNumInputChannels; i < totalNumOutputChannels; ++i)
173 buffer.clear(i, 0, buffer.getNumSamples());
176 scopeDataCollector->process(buffer.getReadPointer(0),
177 (
size_t)buffer.getNumSamples());
180 if (processorTreeState.getParameterAsValue(
"muteOutput").getValue()) {
196 juce::MemoryBlock &destData) {
202 copyXmlToBinary(*processorTreeState.state.createXml().get(), destData);
212 std::unique_ptr<juce::XmlElement> xmlState(
213 getXmlFromBinary(data, sizeInBytes));
214 if (xmlState.get() !=
nullptr) {
216 juce::ValueTree stateTree = juce::ValueTree::fromXml(*xmlState);
220 processorTreeState.replaceState(stateTree);
228 return this->audioBufferQueue.get();
232 return &this->processorTreeState;
244 processorTreeState.state.getOrCreateChildWithName(
"lastSize",
nullptr);
245 return size.getProperty(
"width", EDITOR_INITIAL_WIDTH());
250 processorTreeState.state.getOrCreateChildWithName(
"lastSize",
nullptr);
251 return size.getProperty(
"height", EDITOR_INITIAL_HEIGHT());
257 processorTreeState.state.getOrCreateChildWithName(
"lastSize",
nullptr);
260 size.setProperty(
"width", width,
nullptr);
261 size.setProperty(
"height", height,
nullptr);
266 auto rate = processorTreeState.state.getOrCreateChildWithName(
267 "editorRefreshRate",
nullptr);
270 return rate.getProperty(
"height", EDITOR_INITIAL_RATE());
juce::AudioProcessor *JUCE_CALLTYPE createPluginFilter()
Oscilloscope audio processor.
const juce::String getProgramName(int index) override
juce::AudioProcessorEditor * createEditor() override
int getEditorRefreshRate()
void processBlock(juce::AudioBuffer< float > &, juce::MidiBuffer &) override
bool hasEditor() const override
double getTailLengthSeconds() const override
void setCurrentProgram(int index) override
void storeEditorSize(int width, int height)
bool producesMidi() const override
const juce::String getName() const override
bool isMidiEffect() const override
void setStateInformation(const void *data, int sizeInBytes) override
OscilloscopeAudioProcessor()
juce::AudioProcessorValueTreeState * getTreeState()
int getNumPrograms() override
void getStateInformation(juce::MemoryBlock &destData) override
void prepareToPlay(double sampleRate, int samplesPerBlock) override
bool acceptsMidi() const override
void releaseResources() override
~OscilloscopeAudioProcessor() override
AudioBufferQueue< float > * getAudioBufferQueue()
int getCurrentProgram() override
void changeProgramName(int index, const juce::String &newName) override
bool isBusesLayoutSupported(const BusesLayout &layouts) const override