Showing the changes to TestPlugin/Source/PluginProcessor.cpp (1 of 15 files). Show all
Unified · Split
| @@ -0,0 +1,237 @@ | |||
| 1 | /* | ||
| 2 | ============================================================================== | ||
| 3 | |||
| 4 | This file was auto-generated! | ||
| 5 | |||
| 6 | It contains the basic framework code for a JUCE plugin processor. | ||
| 7 | |||
| 8 | ============================================================================== | ||
| 9 | */ | ||
| 10 | |||
| 11 | #include "PluginProcessor.h" | ||
| 12 | #include "PluginEditor.h" | ||
| 13 | |||
| 14 | #include "UIComponent.h" | ||
| 15 | |||
| 16 | #include "LEAFTest.h" | ||
| 17 | |||
| 18 | //============================================================================== | ||
| 19 | OopsAudioProcessorEditor::OopsAudioProcessorEditor (OopsAudioProcessor& p) | ||
| 20 | : AudioProcessorEditor (&p), processor (p) | ||
| 21 | { | ||
| 22 | // Make sure that before the constructor has finished, you've set the | ||
| 23 | // editor's size to whatever you need it to be. | ||
| 24 | setSize (600, 400); | ||
| 25 | |||
| 26 | addAndMakeVisible(uicomponent); | ||
| 27 | } | ||
| 28 | |||
| 29 | OopsAudioProcessorEditor::~OopsAudioProcessorEditor() | ||
| 30 | { | ||
| 31 | } | ||
| 32 | |||
| 33 | //============================================================================== | ||
| 34 | void OopsAudioProcessorEditor::paint (Graphics& g) | ||
| 35 | { | ||
| 36 | g.fillAll (Colours::white); | ||
| 37 | } | ||
| 38 | |||
| 39 | void OopsAudioProcessorEditor::resized() | ||
| 40 | { | ||
| 41 | uicomponent.setBounds(getBounds()); | ||
| 42 | } | ||
| 43 | //============================================================================== | ||
| 44 | void OopsAudioProcessor::prepareToPlay (double sampleRate, int samplesPerBlock) | ||
| 45 | { | ||
| 46 | gain = 0.0f; | ||
| 47 | timer = 0; | ||
| 48 | start = false; | ||
| 49 | ramp = false; | ||
| 50 | |||
| 51 | LEAFTest_init(sampleRate, samplesPerBlock); | ||
| 52 | } | ||
| 53 | |||
| 54 | |||
| 55 | |||
| 56 | //====================================BLOCK======================================= | ||
| 57 | |||
| 58 | void OopsAudioProcessor::processBlock (AudioSampleBuffer& buffer, MidiBuffer& midiMessages) | ||
| 59 | { | ||
| 60 | const int totalNumInputChannels = getTotalNumInputChannels(); | ||
| 61 | const int totalNumOutputChannels = getTotalNumOutputChannels(); | ||
| 62 | |||
| 63 | for (int i = totalNumInputChannels; i < totalNumOutputChannels; ++i) | ||
| 64 | buffer.clear (i, 0, buffer.getNumSamples()); | ||
| 65 | |||
| 66 | LEAFTest_block(); | ||
| 67 | |||
| 68 | MidiMessage m; | ||
| 69 | int time; | ||
| 70 | |||
| 71 | for (MidiBuffer::Iterator i (midiMessages); i.getNextEvent (m, time);) | ||
| 72 | { | ||
| 73 | int noteNumber = m.getNoteNumber(); | ||
| 74 | float velocity = m.getFloatVelocity(); | ||
| 75 | |||
| 76 | if (m.isNoteOn()) | ||
| 77 | { | ||
| 78 | LEAFTest_noteOn(noteNumber, velocity); | ||
| 79 | } | ||
| 80 | else if (m.isNoteOff()) | ||
| 81 | { | ||
| 82 | LEAFTest_noteOff(noteNumber); | ||
| 83 | } | ||
| 84 | else | ||
| 85 | { | ||
| 86 | |||
| 87 | } | ||
| 88 | } | ||
| 89 | |||
| 90 | |||
| 91 | const float* inPointerL = buffer.getReadPointer (0); | ||
| 92 | const float* inPointerR = buffer.getReadPointer (1); | ||
| 93 | |||
| 94 | float* outPointerL = buffer.getWritePointer( 0); | ||
| 95 | float* outPointerR = buffer.getWritePointer( 1); | ||
| 96 | |||
| 97 | for (int samp = 0; samp < buffer.getNumSamples(); ++samp) | ||
| 98 | { | ||
| 99 | outPointerL[samp] = LEAFTest_tick( (inPointerL[samp] +inPointerR[samp]) * 0.5f); | ||
| 100 | outPointerR[samp] = outPointerL[samp]; | ||
| 101 | } | ||
| 102 | } | ||
| 103 | |||
| 104 | //============================================================================== | ||
| 105 | |||
| 106 | OopsAudioProcessor::OopsAudioProcessor() | ||
| 107 | #ifndef JucePlugin_PreferredChannelConfigurations | ||
| 108 | : AudioProcessor (BusesProperties() | ||
| 109 | #if ! JucePlugin_IsMidiEffect | ||
| 110 | #if ! JucePlugin_IsSynth | ||
| 111 | .withInput ("Input", AudioChannelSet::stereo(), true) | ||
| 112 | #endif | ||
| 113 | .withOutput ("Output", AudioChannelSet::stereo(), true) | ||
| 114 | #endif | ||
| 115 | ) | ||
| 116 | #endif | ||
| 117 | { | ||
| 118 | |||
| 119 | } | ||
| 120 | |||
| 121 | OopsAudioProcessor::~OopsAudioProcessor() | ||
| 122 | { | ||
| 123 | |||
| 124 | } | ||
| 125 | |||
| 126 | //============================================================================== | ||
| 127 | const String OopsAudioProcessor::getName() const | ||
| 128 | { | ||
| 129 | return JucePlugin_Name; | ||
| 130 | } | ||
| 131 | |||
| 132 | bool OopsAudioProcessor::acceptsMidi() const | ||
| 133 | { | ||
| 134 | return true; | ||
| 135 | } | ||
| 136 | |||
| 137 | bool OopsAudioProcessor::producesMidi() const | ||
| 138 | { | ||
| 139 | #if JucePlugin_ProducesMidiOutput | ||
| 140 | return true; | ||
| 141 | #else | ||
| 142 | return false; | ||
| 143 | #endif | ||
| 144 | } | ||
| 145 | |||
| 146 | double OopsAudioProcessor::getTailLengthSeconds() const | ||
| 147 | { | ||
| 148 | return 0.0; | ||
| 149 | } | ||
| 150 | |||
| 151 | int OopsAudioProcessor::getNumPrograms() | ||
| 152 | { | ||
| 153 | return 1; // NB: some hosts don't cope very well if you tell them there are 0 programs, | ||
| 154 | // so this should be at least 1, even if you're not really implementing programs. | ||
| 155 | } | ||
| 156 | |||
| 157 | int OopsAudioProcessor::getCurrentProgram() | ||
| 158 | { | ||
| 159 | return 0; | ||
| 160 | } | ||
| 161 | |||
| 162 | void OopsAudioProcessor::setCurrentProgram (int index) | ||
| 163 | { | ||
| 164 | } | ||
| 165 | |||
| 166 | const String OopsAudioProcessor::getProgramName (int index) | ||
| 167 | { | ||
| 168 | return String(); | ||
| 169 | } | ||
| 170 | |||
| 171 | void OopsAudioProcessor::changeProgramName (int index, const String& newName) | ||
| 172 | { | ||
| 173 | } | ||
| 174 | |||
| 175 | void OopsAudioProcessor::releaseResources() | ||
| 176 | { | ||
| 177 | // When playback stops, you can use this as an opportunity to free up any | ||
| 178 | // spare memory, etc. | ||
| 179 | LEAFTest_end(); | ||
| 180 | } | ||
| 181 | |||
| 182 | #ifndef JucePlugin_PreferredChannelConfigurations | ||
| 183 | bool OopsAudioProcessor::isBusesLayoutSupported (const BusesLayout& layouts) const | ||
| 184 | { | ||
| 185 | #if JucePlugin_IsMidiEffect | ||
| 186 | ignoreUnused (layouts); | ||
| 187 | return true; | ||
| 188 | #else | ||
| 189 | // This is the place where you check if the layout is supported. | ||
| 190 | // In this template code we only support mono or stereo. | ||
| 191 | if (layouts.getMainOutputChannelSet() != AudioChannelSet::mono() | ||
| 192 | && layouts.getMainOutputChannelSet() != AudioChannelSet::stereo()) | ||
| 193 | return false; | ||
| 194 | |||
| 195 | // This checks if the input layout matches the output layout | ||
| 196 | #if ! JucePlugin_IsSynth | ||
| 197 | if (layouts.getMainOutputChannelSet() != layouts.getMainInputChannelSet()) | ||
| 198 | return false; | ||
| 199 | #endif | ||
| 200 | |||
| 201 | return true; | ||
| 202 | #endif | ||
| 203 | } | ||
| 204 | #endif | ||
| 205 | |||
| 206 | |||
| 207 | //============================================================================== | ||
| 208 | bool OopsAudioProcessor::hasEditor() const | ||
| 209 | { | ||
| 210 | return true; // (change this to false if you choose to not supply an editor) | ||
| 211 | } | ||
| 212 | |||
| 213 | AudioProcessorEditor* OopsAudioProcessor::createEditor() | ||
| 214 | { | ||
| 215 | return new OopsAudioProcessorEditor (*this); | ||
| 216 | } | ||
| 217 | |||
| 218 | //============================================================================== | ||
| 219 | void OopsAudioProcessor::getStateInformation (MemoryBlock& destData) | ||
| 220 | { | ||
| 221 | // You should use this method to store your parameters in the memory block. | ||
| 222 | // You could do that either as raw data, or use the XML or ValueTree classes | ||
| 223 | // as intermediaries to make it easy to save and load complex data. | ||
| 224 | } | ||
| 225 | |||
| 226 | void OopsAudioProcessor::setStateInformation (const void* data, int sizeInBytes) | ||
| 227 | { | ||
| 228 | // You should use this method to restore your parameters from this memory block, | ||
| 229 | // whose contents will have been created by the getStateInformation() call. | ||
| 230 | } | ||
| 231 | |||
| 232 | //============================================================================== | ||
| 233 | // This creates new instances of the plugin.. | ||
| 234 | AudioProcessor* JUCE_CALLTYPE createPluginFilter() | ||
| 235 | { | ||
| 236 | return new OopsAudioProcessor(); | ||
| 237 | } | ||