Skip to content

Commit

Permalink
examples: Start XY component demo
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiashienzsch committed May 22, 2020
1 parent 8db6296 commit 4a4a589
Show file tree
Hide file tree
Showing 7 changed files with 351 additions and 20 deletions.
39 changes: 19 additions & 20 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
---
BasedOnStyle: WebKit
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: 'true'
AlignOperands: 'true'
AlignTrailingComments: 'true'
AlwaysBreakTemplateDeclarations: 'true'
AllowShortBlocksOnASingleLine: 'false'
AllowShortCaseLabelsOnASingleLine: 'true'
AllowShortFunctionsOnASingleLine: 'true'
AllowShortIfStatementsOnASingleLine: 'true'
AllowShortLoopsOnASingleLine: 'true'
AlignConsecutiveAssignments: "true"
AlignOperands: "true"
AlignTrailingComments: "true"
AlwaysBreakTemplateDeclarations: "true"
AllowShortBlocksOnASingleLine: "false"
AllowShortCaseLabelsOnASingleLine: "true"
AllowShortFunctionsOnASingleLine: "true"
AllowShortIfStatementsOnASingleLine: "true"
AllowShortLoopsOnASingleLine: "true"
BreakBeforeBraces: Allman
ColumnLimit: 120
ConstructorInitializerAllOnOneLineOrOnePerLine: 'true'
Cpp11BracedListStyle: 'true'
FixNamespaceComments: 'true'
KeepEmptyLinesAtTheStartOfBlocks: 'false'
ColumnLimit: 100
ConstructorInitializerAllOnOneLineOrOnePerLine: "true"
Cpp11BracedListStyle: "true"
FixNamespaceComments: "true"
KeepEmptyLinesAtTheStartOfBlocks: "false"
Language: Cpp
MaxEmptyLinesToKeep: '1'
MaxEmptyLinesToKeep: "1"
NamespaceIndentation: None
PointerAlignment: Left
ReflowComments: 'true'
SortIncludes: 'true'
SpaceBeforeAssignmentOperators: 'true'
SpacesBeforeTrailingComments: '2'
...
ReflowComments: "true"
SortIncludes: "true"
SpaceBeforeAssignmentOperators: "true"
SpacesBeforeTrailingComments: "2"
2 changes: 2 additions & 0 deletions examples/component/XYPad/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
JuceLibraryCode
Builds
20 changes: 20 additions & 0 deletions examples/component/XYPad/Source/PluginEditor.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include "PluginEditor.h"

namespace tobanteAudio
{
PluginEditor::PluginEditor(PluginProcessor& p) : AudioProcessorEditor(&p), processor(p)
{
setSize(400, 300);
}

PluginEditor::~PluginEditor() { }

void PluginEditor::paint(juce::Graphics& g)
{
auto const color = getLookAndFeel().findColour(juce::ResizableWindow::backgroundColourId);
g.fillAll(color);
}

void PluginEditor::resized() { }

} // namespace tobanteAudio
22 changes: 22 additions & 0 deletions examples/component/XYPad/Source/PluginEditor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#pragma once

#include "PluginProcessor.h"

namespace tobanteAudio
{
class PluginEditor : public juce::AudioProcessorEditor
{
public:
PluginEditor(PluginProcessor&);
~PluginEditor();

void paint(juce::Graphics&) override;
void resized() override;

private:
PluginProcessor& processor;

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(PluginEditor)
};

} // namespace tobanteAudio
139 changes: 139 additions & 0 deletions examples/component/XYPad/Source/PluginProcessor.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
#include "PluginProcessor.h"
#include "PluginEditor.h"

namespace tobanteAudio
{
PluginProcessor::PluginProcessor()
#ifndef JucePlugin_PreferredChannelConfigurations
: AudioProcessor(BusesProperties()
#if !JucePlugin_IsMidiEffect
#if !JucePlugin_IsSynth
.withInput("Input", juce::AudioChannelSet::stereo(), true)
#endif
.withOutput("Output", juce::AudioChannelSet::stereo(), true)
#endif
)
#endif
{
}

PluginProcessor::~PluginProcessor() { }

const juce::String PluginProcessor::getName() const { return JucePlugin_Name; }

bool PluginProcessor::acceptsMidi() const
{
#if JucePlugin_WantsMidiInput
return true;
#else
return false;
#endif
}

bool PluginProcessor::producesMidi() const
{
#if JucePlugin_ProducesMidiOutput
return true;
#else
return false;
#endif
}

bool PluginProcessor::isMidiEffect() const
{
#if JucePlugin_IsMidiEffect
return true;
#else
return false;
#endif
}

double PluginProcessor::getTailLengthSeconds() const { return 0.0; }

int PluginProcessor::getNumPrograms() { return 1; }

int PluginProcessor::getCurrentProgram() { return 0; }

void PluginProcessor::setCurrentProgram(int index) { }

const juce::String PluginProcessor::getProgramName(int index) { return {}; }

void PluginProcessor::changeProgramName(int index, const juce::String& newName) { }

void PluginProcessor::prepareToPlay(double sampleRate, int samplesPerBlock) { }

void PluginProcessor::releaseResources() { }

#ifndef JucePlugin_PreferredChannelConfigurations
bool PluginProcessor::isBusesLayoutSupported(const BusesLayout& layouts) const
{
#if JucePlugin_IsMidiEffect
juce::ignoreUnused(layouts);
return true;
#else
// This is the place where you check if the layout is supported.
// In this template code we only support mono or stereo.
if (layouts.getMainOutputChannelSet() != juce::AudioChannelSet::mono()
&& layouts.getMainOutputChannelSet() != juce::AudioChannelSet::stereo())
return false;

// This checks if the input layout matches the output layout
#if !JucePlugin_IsSynth
if (layouts.getMainOutputChannelSet() != layouts.getMainInputChannelSet()) return false;
#endif

return true;
#endif
}
#endif

void PluginProcessor::processBlock(juce::AudioBuffer<float>& buffer, juce::MidiBuffer& midiMessages)
{
juce::ScopedNoDenormals noDenormals;
auto totalNumInputChannels = getTotalNumInputChannels();
auto totalNumOutputChannels = getTotalNumOutputChannels();

// In case we have more outputs than inputs, this code clears any output
// channels that didn't contain input data, (because these aren't
// guaranteed to be empty - they may contain garbage).
// This is here to avoid people getting screaming feedback
// when they first compile a plugin, but obviously you don't need to keep
// this code if your algorithm always overwrites all the output channels.
for (auto i = totalNumInputChannels; i < totalNumOutputChannels; ++i)
buffer.clear(i, 0, buffer.getNumSamples());

// This is the place where you'd normally do the guts of your plugin's
// audio processing...
// Make sure to reset the state if your inner loop is processing
// the samples and the outer loop is handling the channels.
// Alternatively, you can process the samples with the channels
// interleaved by keeping the same state.
for (int channel = 0; channel < totalNumInputChannels; ++channel)
{
auto* channelData = buffer.getWritePointer(channel);

// ..do something to the data...
}
}

bool PluginProcessor::hasEditor() const
{
return true; // (change this to false if you choose to not supply an editor)
}

juce::AudioProcessorEditor* PluginProcessor::createEditor()
{
return new tobanteAudio::PluginEditor(*this);
}

void PluginProcessor::getStateInformation(juce::MemoryBlock& destData) { }

void PluginProcessor::setStateInformation(const void* data, int sizeInBytes) { }

} // namespace tobanteAudio

// This creates new instances of the plugin..
juce::AudioProcessor* JUCE_CALLTYPE createPluginFilter()
{
return new tobanteAudio::PluginProcessor();
}
44 changes: 44 additions & 0 deletions examples/component/XYPad/Source/PluginProcessor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#pragma once

#include <JuceHeader.h>

namespace tobanteAudio
{
class PluginProcessor : public juce::AudioProcessor
{
public:
PluginProcessor();
~PluginProcessor();

void prepareToPlay(double sampleRate, int samplesPerBlock) override;
void releaseResources() override;

#ifndef JucePlugin_PreferredChannelConfigurations
bool isBusesLayoutSupported(const BusesLayout& layouts) const override;
#endif

void processBlock(juce::AudioBuffer<float>&, juce::MidiBuffer&) override;

juce::AudioProcessorEditor* createEditor() override;
bool hasEditor() const override;

const juce::String getName() const override;

bool acceptsMidi() const override;
bool producesMidi() const override;
bool isMidiEffect() const override;
double getTailLengthSeconds() const override;

int getNumPrograms() override;
int getCurrentProgram() override;
void setCurrentProgram(int index) override;
const juce::String getProgramName(int index) override;
void changeProgramName(int index, const juce::String& newName) override;

void getStateInformation(juce::MemoryBlock& destData) override;
void setStateInformation(const void* data, int sizeInBytes) override;

private:
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(PluginProcessor)
};
} // namespace tobanteAudio
105 changes: 105 additions & 0 deletions examples/component/XYPad/XYPad.jucer
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
<?xml version="1.0" encoding="UTF-8"?>

<JUCERPROJECT id="bkD65c" name="XYPad" projectType="audioplug" useAppConfig="0"
addUsingNamespaceToJuceHeader="0" displaySplashScreen="1">
<MAINGROUP id="f2ElfS" name="XYPad">
<GROUP id="{197C6EF5-ED8A-27D3-6D29-4D7608045586}" name="Source">
<FILE id="hLrXiH" name="PluginProcessor.cpp" compile="1" resource="0"
file="Source/PluginProcessor.cpp"/>
<FILE id="YydzFk" name="PluginProcessor.h" compile="0" resource="0"
file="Source/PluginProcessor.h"/>
<FILE id="E8U0Cp" name="PluginEditor.cpp" compile="1" resource="0"
file="Source/PluginEditor.cpp"/>
<FILE id="Cd1P06" name="PluginEditor.h" compile="0" resource="0" file="Source/PluginEditor.h"/>
</GROUP>
</MAINGROUP>
<EXPORTFORMATS>
<XCODE_MAC targetFolder="Builds/MacOSX">
<CONFIGURATIONS>
<CONFIGURATION isDebug="1" name="Debug"/>
<CONFIGURATION isDebug="0" name="Release"/>
</CONFIGURATIONS>
<MODULEPATHS>
<MODULEPATH id="juce_audio_basics" path="../../../../../../.builds/JUCE/modules"/>
<MODULEPATH id="juce_audio_devices" path="../../../../../../.builds/JUCE/modules"/>
<MODULEPATH id="juce_audio_formats" path="../../../../../../.builds/JUCE/modules"/>
<MODULEPATH id="juce_audio_plugin_client" path="../../../../../../.builds/JUCE/modules"/>
<MODULEPATH id="juce_audio_processors" path="../../../../../../.builds/JUCE/modules"/>
<MODULEPATH id="juce_audio_utils" path="../../../../../../.builds/JUCE/modules"/>
<MODULEPATH id="juce_core" path="../../../../../../.builds/JUCE/modules"/>
<MODULEPATH id="juce_cryptography" path="../../../../../../.builds/JUCE/modules"/>
<MODULEPATH id="juce_data_structures" path="../../../../../../.builds/JUCE/modules"/>
<MODULEPATH id="juce_events" path="../../../../../../.builds/JUCE/modules"/>
<MODULEPATH id="juce_graphics" path="../../../../../../.builds/JUCE/modules"/>
<MODULEPATH id="juce_gui_basics" path="../../../../../../.builds/JUCE/modules"/>
<MODULEPATH id="juce_gui_extra" path="../../../../../../.builds/JUCE/modules"/>
<MODULEPATH id="juce_opengl" path="../../../../../../.builds/JUCE/modules"/>
</MODULEPATHS>
</XCODE_MAC>
<VS2019 targetFolder="Builds/VisualStudio2019">
<CONFIGURATIONS>
<CONFIGURATION isDebug="1" name="Debug"/>
<CONFIGURATION isDebug="0" name="Release"/>
</CONFIGURATIONS>
<MODULEPATHS>
<MODULEPATH id="juce_audio_basics" path="../../../../../../.builds/JUCE/modules"/>
<MODULEPATH id="juce_audio_devices" path="../../../../../../.builds/JUCE/modules"/>
<MODULEPATH id="juce_audio_formats" path="../../../../../../.builds/JUCE/modules"/>
<MODULEPATH id="juce_audio_plugin_client" path="../../../../../../.builds/JUCE/modules"/>
<MODULEPATH id="juce_audio_processors" path="../../../../../../.builds/JUCE/modules"/>
<MODULEPATH id="juce_audio_utils" path="../../../../../../.builds/JUCE/modules"/>
<MODULEPATH id="juce_core" path="../../../../../../.builds/JUCE/modules"/>
<MODULEPATH id="juce_cryptography" path="../../../../../../.builds/JUCE/modules"/>
<MODULEPATH id="juce_data_structures" path="../../../../../../.builds/JUCE/modules"/>
<MODULEPATH id="juce_events" path="../../../../../../.builds/JUCE/modules"/>
<MODULEPATH id="juce_graphics" path="../../../../../../.builds/JUCE/modules"/>
<MODULEPATH id="juce_gui_basics" path="../../../../../../.builds/JUCE/modules"/>
<MODULEPATH id="juce_gui_extra" path="../../../../../../.builds/JUCE/modules"/>
<MODULEPATH id="juce_opengl" path="../../../../../../.builds/JUCE/modules"/>
</MODULEPATHS>
</VS2019>
<LINUX_MAKE targetFolder="Builds/LinuxMakefile">
<CONFIGURATIONS>
<CONFIGURATION isDebug="1" name="Debug"/>
<CONFIGURATION isDebug="0" name="Release"/>
</CONFIGURATIONS>
<MODULEPATHS>
<MODULEPATH id="juce_audio_basics" path="../../../../../../.builds/JUCE/modules"/>
<MODULEPATH id="juce_audio_devices" path="../../../../../../.builds/JUCE/modules"/>
<MODULEPATH id="juce_audio_formats" path="../../../../../../.builds/JUCE/modules"/>
<MODULEPATH id="juce_audio_plugin_client" path="../../../../../../.builds/JUCE/modules"/>
<MODULEPATH id="juce_audio_processors" path="../../../../../../.builds/JUCE/modules"/>
<MODULEPATH id="juce_audio_utils" path="../../../../../../.builds/JUCE/modules"/>
<MODULEPATH id="juce_core" path="../../../../../../.builds/JUCE/modules"/>
<MODULEPATH id="juce_cryptography" path="../../../../../../.builds/JUCE/modules"/>
<MODULEPATH id="juce_data_structures" path="../../../../../../.builds/JUCE/modules"/>
<MODULEPATH id="juce_events" path="../../../../../../.builds/JUCE/modules"/>
<MODULEPATH id="juce_graphics" path="../../../../../../.builds/JUCE/modules"/>
<MODULEPATH id="juce_gui_basics" path="../../../../../../.builds/JUCE/modules"/>
<MODULEPATH id="juce_gui_extra" path="../../../../../../.builds/JUCE/modules"/>
<MODULEPATH id="juce_opengl" path="../../../../../../.builds/JUCE/modules"/>
</MODULEPATHS>
</LINUX_MAKE>
</EXPORTFORMATS>
<JUCEOPTIONS JUCE_VST3_CAN_REPLACE_VST2="0" JUCE_STRICT_REFCOUNTEDPOINTER="1"/>
<MODULES>
<MODULE id="juce_audio_basics" showAllCode="1" useLocalCopy="0" useGlobalPath="1"/>
<MODULE id="juce_audio_devices" showAllCode="1" useLocalCopy="0" useGlobalPath="1"/>
<MODULE id="juce_audio_formats" showAllCode="1" useLocalCopy="0" useGlobalPath="1"/>
<MODULE id="juce_audio_plugin_client" showAllCode="1" useLocalCopy="0"
useGlobalPath="1"/>
<MODULE id="juce_audio_processors" showAllCode="1" useLocalCopy="0" useGlobalPath="1"/>
<MODULE id="juce_audio_utils" showAllCode="1" useLocalCopy="0" useGlobalPath="1"/>
<MODULE id="juce_core" showAllCode="1" useLocalCopy="0" useGlobalPath="1"/>
<MODULE id="juce_cryptography" showAllCode="1" useLocalCopy="0" useGlobalPath="1"/>
<MODULE id="juce_data_structures" showAllCode="1" useLocalCopy="0" useGlobalPath="1"/>
<MODULE id="juce_events" showAllCode="1" useLocalCopy="0" useGlobalPath="1"/>
<MODULE id="juce_graphics" showAllCode="1" useLocalCopy="0" useGlobalPath="1"/>
<MODULE id="juce_gui_basics" showAllCode="1" useLocalCopy="0" useGlobalPath="1"/>
<MODULE id="juce_gui_extra" showAllCode="1" useLocalCopy="0" useGlobalPath="1"/>
<MODULE id="juce_opengl" showAllCode="1" useLocalCopy="0" useGlobalPath="1"/>
</MODULES>
<LIVE_SETTINGS>
<LINUX/>
</LIVE_SETTINGS>
</JUCERPROJECT>

0 comments on commit 4a4a589

Please sign in to comment.