Skip to content
Snippets Groups Projects
Commit 72feff01 authored by Christian Schweizer's avatar Christian Schweizer
Browse files

day 2 source code

parent c8c606db
No related branches found
No related tags found
No related merge requests found
......@@ -5,6 +5,8 @@
version="0.1" companyName="ZHdK-Plugin-Kurs" pluginChannelConfigs="{1,4}">
<MAINGROUP id="RDeQpu" name="Demo-Plugin">
<GROUP id="{198DF08A-A841-9364-CFB2-DEBA3E565C4F}" name="Source">
<FILE id="yGk5We" name="MainGui.cpp" compile="1" resource="0" file="Source/MainGui.cpp"/>
<FILE id="rYATkz" name="MainGui.h" compile="0" resource="0" file="Source/MainGui.h"/>
<FILE id="BNDEYk" name="PluginProcessor.cpp" compile="1" resource="0"
file="Source/PluginProcessor.cpp"/>
<FILE id="WKYcaQ" name="PluginProcessor.h" compile="0" resource="0"
......
/*
==============================================================================
This is an automatically generated GUI class created by the Projucer!
Be careful when adding custom code to these files, as only the code within
the "//[xyz]" and "//[/xyz]" sections will be retained when the file is loaded
and re-saved.
Created with Projucer version: 6.0.7
------------------------------------------------------------------------------
The Projucer is part of the JUCE library.
Copyright (c) 2020 - Raw Material Software Limited.
==============================================================================
*/
//[Headers] You can add your own extra header files here...
//[/Headers]
#include "MainGui.h"
//[MiscUserDefs] You can add your own user definitions and misc code here...
//[/MiscUserDefs]
//==============================================================================
MainGui::MainGui ()
{
//[Constructor_pre] You can add your own custom stuff here..
//[/Constructor_pre]
juce__textButton.reset (new juce::TextButton ("new button"));
addAndMakeVisible (juce__textButton.get());
juce__textButton->addListener (this);
juce__textButton->setBounds (96, 32, 150, 24);
//[UserPreSize]
//[/UserPreSize]
setSize (600, 400);
//[Constructor] You can add your own custom stuff here..
//[/Constructor]
}
MainGui::~MainGui()
{
//[Destructor_pre]. You can add your own custom destruction code here..
//[/Destructor_pre]
juce__textButton = nullptr;
//[Destructor]. You can add your own custom destruction code here..
//[/Destructor]
}
//==============================================================================
void MainGui::paint (juce::Graphics& g)
{
//[UserPrePaint] Add your own custom painting code here..
//[/UserPrePaint]
g.fillAll (juce::Colour (0xff323e44));
//[UserPaint] Add your own custom painting code here..
//[/UserPaint]
}
void MainGui::resized()
{
//[UserPreResize] Add your own custom resize code here..
//[/UserPreResize]
//[UserResized] Add your own custom resize handling here..
//[/UserResized]
}
void MainGui::buttonClicked (juce::Button* buttonThatWasClicked)
{
//[UserbuttonClicked_Pre]
//[/UserbuttonClicked_Pre]
if (buttonThatWasClicked == juce__textButton.get())
{
//[UserButtonCode_juce__textButton] -- add your button handler code here..
//[/UserButtonCode_juce__textButton]
}
//[UserbuttonClicked_Post]
//[/UserbuttonClicked_Post]
}
//[MiscUserCode] You can add your own definitions of your custom methods or any other code here...
//[/MiscUserCode]
//==============================================================================
#if 0
/* -- Projucer information section --
This is where the Projucer stores the metadata that describe this GUI layout, so
make changes in here at your peril!
BEGIN_JUCER_METADATA
<JUCER_COMPONENT documentType="Component" className="MainGui" componentName=""
parentClasses="public juce::Component" constructorParams="" variableInitialisers=""
snapPixels="8" snapActive="1" snapShown="1" overlayOpacity="0.330"
fixedSize="0" initialWidth="600" initialHeight="400">
<BACKGROUND backgroundColour="ff323e44"/>
<TEXTBUTTON name="new button" id="48346f05801f4060" memberName="juce__textButton"
virtualName="" explicitFocusOrder="0" pos="96 32 150 24" buttonText="new button"
connectedEdges="0" needsCallback="1" radioGroupId="0"/>
</JUCER_COMPONENT>
END_JUCER_METADATA
*/
#endif
//[EndFile] You can add extra defines here...
//[/EndFile]
/*
==============================================================================
This is an automatically generated GUI class created by the Projucer!
Be careful when adding custom code to these files, as only the code within
the "//[xyz]" and "//[/xyz]" sections will be retained when the file is loaded
and re-saved.
Created with Projucer version: 6.0.7
------------------------------------------------------------------------------
The Projucer is part of the JUCE library.
Copyright (c) 2020 - Raw Material Software Limited.
==============================================================================
*/
#pragma once
//[Headers] -- You can add your own extra header files here --
#include <JuceHeader.h>
//[/Headers]
//==============================================================================
/**
//[Comments]
An auto-generated component, created by the Projucer.
Describe your class and how it works here!
//[/Comments]
*/
class MainGui : public juce::Component,
public juce::Button::Listener
{
public:
//==============================================================================
MainGui ();
~MainGui() override;
//==============================================================================
//[UserMethods] -- You can add your own custom methods in this section.
//[/UserMethods]
void paint (juce::Graphics& g) override;
void resized() override;
void buttonClicked (juce::Button* buttonThatWasClicked) override;
private:
//[UserVariables] -- You can add your own custom variables in this section.
//[/UserVariables]
//==============================================================================
std::unique_ptr<juce::TextButton> juce__textButton;
//==============================================================================
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainGui)
};
//[EndFile] You can add extra defines here...
//[/EndFile]
......@@ -13,6 +13,10 @@
DemoPluginAudioProcessorEditor::DemoPluginAudioProcessorEditor (DemoPluginAudioProcessor& p)
: AudioProcessorEditor (&p), audioProcessor (p)
{
// we create an instance of our class MainGui and save the pointer to the variable mainGui
mainGui = new MainGui();
addAndMakeVisible(mainGui);
// Make sure that before the constructor has finished, you've set the
// editor's size to whatever you need it to be.
setSize (400, 300);
......@@ -20,6 +24,8 @@ DemoPluginAudioProcessorEditor::DemoPluginAudioProcessorEditor (DemoPluginAudioP
DemoPluginAudioProcessorEditor::~DemoPluginAudioProcessorEditor()
{
// because we manually created our main GUI, we have to delete it here!
delete mainGui;
}
//==============================================================================
......@@ -35,6 +41,6 @@ void DemoPluginAudioProcessorEditor::paint (juce::Graphics& g)
void DemoPluginAudioProcessorEditor::resized()
{
// This is generally where you'll want to lay out the positions of any
// subcomponents in your editor..
// we use the whole available gui space for our main GUI
mainGui->setBounds(getBounds());
}
......@@ -10,6 +10,7 @@
#include <JuceHeader.h>
#include "PluginProcessor.h"
#include "MainGui.h"
//==============================================================================
/**
......@@ -28,6 +29,9 @@ private:
// This reference is provided as a quick way for your editor to
// access the processor object that created it.
DemoPluginAudioProcessor& audioProcessor;
// a pointer to our main GUI instance
MainGui* mainGui;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (DemoPluginAudioProcessorEditor)
};
......@@ -22,6 +22,8 @@ DemoPluginAudioProcessor::DemoPluginAudioProcessor()
)
#endif
{
// initialize class variables to avoid undefined values and big surprises!
runningValue = 0;
}
DemoPluginAudioProcessor::~DemoPluginAudioProcessor()
......@@ -150,12 +152,37 @@ void DemoPluginAudioProcessor::processBlock (juce::AudioBuffer<float>& buffer, j
// 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)
// first we copy our audio input
AudioBuffer<float> input(1, buffer.getNumSamples());
input.copyFrom(0, 0, buffer, 0, 0, buffer.getNumSamples());
// we ask for a pointer to our readable data
const float* readPointer = input.getReadPointer(0);
// we loop through all output channels
for (int channel = 0; channel < totalNumOutputChannels; ++channel)
{
// we define an additional angle of 0/90/180/270 for the channels 0-4
float additionalAngle = channel * 3.14 * 0.5;
// we get a write pointer to the main buffer
auto* channelData = buffer.getWritePointer (channel);
// ..do something to the data...
// we loop through all samples in the buffer
for(int iData = 0; iData < buffer.getNumSamples(); iData++)
{
// we define a factor that is dependent on the current time and produces a 1Hz sinus curve
float factor = sin((runningValue + iData) / getSampleRate() * 3.14 + additionalAngle);
// we multiply the input data with that factor and save it to the output buffer (through the write pointer)
channelData[iData] = readPointer[iData] * factor;
}
}
// finally we update our runningValue
runningValue += buffer.getNumSamples();
}
//==============================================================================
......
......@@ -54,6 +54,8 @@ public:
void setStateInformation (const void* data, int sizeInBytes) override;
private:
// a variable that exists throuout the whole lifetime of our DemoPluginAudioProcessor instance
int runningValue;
//==============================================================================
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (DemoPluginAudioProcessor)
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment