# Fast explanation of the 4 JUCE's sources?

**URL:** <https://forum.juce.com/t/fast-explanation-of-the-4-juces-sources/43442>\
**Category:** General JUCE discussion\
**Created:** [December 24, 2020, 4:52pm UTC](https://forum.juce.com/t/fast-explanation-of-the-4-juces-sources/43442 "2020-12-24T16:52:42Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![PietroGuglielmini](https://avatars.discourse-cdn.com/v4/letter/p/da6949/32.png) [@PietroGuglielmini](https://forum.juce.com/u/PietroGuglielmini)\
**Post date:** [December 24, 2020, 4:52pm UTC](https://forum.juce.com/t/fast-explanation-of-the-4-juces-sources/43442/1 "2020-12-24T16:52:42Z")

</div>

Can someone please explain me what are the four sources of JUCE and how they interact with each other (I’m talking about PluginProcessor.ccp, PluginProcessor.h, PluginEditor.ccp, PluginEditor.h)?

---

<div class="post-metadata">

**Author:** ![anoesisaudio](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/anoesisaudio/32/1132_2.png) [@anoesisaudio](https://forum.juce.com/u/anoesisaudio)\
**Post date:** [December 24, 2020, 4:57pm UTC](https://forum.juce.com/t/fast-explanation-of-the-4-juces-sources/43442/2 "2020-12-24T16:57:38Z")

</div>

The simplest way (for me) to think about it is as a few ‘rules’.

The processor is the plugin & the editor (which is created/destroyed by processor) is a representation of the processor’s data.

Anything you want to do with sound goes in the processor, and anything you want to do with the GUI goes in the editor.

You should not make changes to sound directly from the editor.

You should not make changes to the GUI directly from the processor (the editor should periodically get data from the processor to represent).

I hope that helps.

---

<div class="post-metadata">

**Author:** ![Mrugalla](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/mrugalla/32/13092_2.png) [@Mrugalla](https://forum.juce.com/u/Mrugalla)\
**Post date:** [December 25, 2020, 1:05am UTC](https://forum.juce.com/t/fast-explanation-of-the-4-juces-sources/43442/3 "2020-12-25T01:05:02Z")

</div>

check out the cherno’s c++ series on youtube to learn more about the difference between .h and .cpp files

---

<div class="post-metadata">

**Author:** ![PietroGuglielmini](https://avatars.discourse-cdn.com/v4/letter/p/da6949/32.png) [@PietroGuglielmini](https://forum.juce.com/u/PietroGuglielmini)\
**Post date:** [December 25, 2020, 10:29am UTC](https://forum.juce.com/t/fast-explanation-of-the-4-juces-sources/43442/4 "2020-12-25T10:29:08Z")

</div>

Ok thanks a lot

---

<div class="post-metadata">

**Author:** ![PietroGuglielmini](https://avatars.discourse-cdn.com/v4/letter/p/da6949/32.png) [@PietroGuglielmini](https://forum.juce.com/u/PietroGuglielmini)\
**Post date:** [December 25, 2020, 10:29am UTC](https://forum.juce.com/t/fast-explanation-of-the-4-juces-sources/43442/5 "2020-12-25T10:29:52Z")

</div>

Thanks. Can you tell me the difference roughly in a few words?

---

<div class="post-metadata">

**Author:** ![ImJimmi](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/imjimmi/32/10843_2.png) [@ImJimmi](https://forum.juce.com/u/ImJimmi)\
**Post date:** [December 25, 2020, 11:44am UTC](https://forum.juce.com/t/fast-explanation-of-the-4-juces-sources/43442/6 "2020-12-25T11:44:56Z")

</div>

“The convention is that .h files are declarations, and .cpp files are definitions.”

> <https://stackoverflow.com/questions/875479/what-is-the-difference-between-a-cpp-file-and-a-h-file/875489#875489>

---

<div class="post-metadata">

**Author:** ![daniel](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/daniel/32/790_2.png) [@daniel](https://forum.juce.com/u/daniel)\
**Post date:** [December 25, 2020, 12:21pm UTC](https://forum.juce.com/t/fast-explanation-of-the-4-juces-sources/43442/7 "2020-12-25T12:21:39Z")

</div>

The PluginProcessor is the class describing the actual sound processing or the sound generation in case of a generator or instrument. The actual class inside that file has a generic name formed of your PluginName you supplied. It inherits [juce::AudioProcessor](https://docs.juce.com/develop/classAudioProcessor.html) to function correctly.

The ProcessorEditor contains the class describing the GUI. It is generated in a [factory function](https://docs.juce.com/develop/classAudioProcessor.html#a103fc8a8666b7d31b472e017262be84d), that was also autogenerated using your PluginName and inheriting [juce::AudioProcessorEditor](https://docs.juce.com/develop/classAudioProcessorEditor.html).

The ProcessorEditor is optional. You can either supply none, in which case a host might show a generic control panel, some hosts just show nothing.  
Or you can return a juce::GenericAudioProcessorEditor, which shows all parameters, so you can already interact with your plugin (highly recommended for prototyping).  
Or you can use a third party GUI engine, like my [PluginGuiMagic](https://foleysfinest.com/developer/pluginguimagic/) or Blueprint (JavaScript).

Always code so that processing works with no PluginEditor present!

> **[ffAudio/foleys\_gui\_magic](https://github.com/ffAudio/foleys_gui_magic)**
>
> A GUI builder module for JUCE. Contribute to ffAudio/foleys\_gui\_magic development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![Mrugalla](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/mrugalla/32/13092_2.png) [@Mrugalla](https://forum.juce.com/u/Mrugalla)\
**Post date:** [December 25, 2020, 1:29pm UTC](https://forum.juce.com/t/fast-explanation-of-the-4-juces-sources/43442/8 "2020-12-25T13:29:56Z")

</div>

My understanding might also still be incomplete but I see it like this:

Every C++ program starts with a main.cpp

You don’t see that when the projucer makes a new project for you because it’s somewhere in the JUCE files or so.

Then whenever you want to outsource some information from this main.cpp you make a header file with your new information, like if you want to make a file that only deals with audio buffers and you call it Buffer.h

Then you might go ahead and include it along with the other things in your pluginProcessor.h at the top of the file.  
#include “Buffer.h”

That copy-pastes all the stuff from Buffer.h at exactly that point.

At this point you are already pretty much settled. You can make everything in a header-file, namespaces, classes, variables, and you can create instances of those objects from your pluginProcessor.

But you can potentially also make a cpp file called Buffer.cpp if you want to.  
Then you’d have definition and declaration seperated. I personally don’t see which advantage we gain from doing that because I don’t like to jump around between files when I write functions, but it’s useful for something I guess. However you can just look at pluginEditor and pluginProcessor’s h and cpp files to get an example for that

---

<div class="post-metadata">

**Author:** ![daniel](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/daniel/32/790_2.png) [@daniel](https://forum.juce.com/u/daniel)\
**Post date:** [December 25, 2020, 9:50pm UTC](https://forum.juce.com/t/fast-explanation-of-the-4-juces-sources/43442/9 "2020-12-25T21:50:26Z")

</div>

> [@hdlAudio](#):
>
> Every C++ program starts with a main.cpp

There is a lot of confusion around.

It depends what you mean with “program”. An executable indeed starts at the so called main entry point, which is defined as `int main (int, char**) { ... }`.  
A plugin is not a program in that sense. It is a library offering additional functionality to the host. The interface how the host will call the functionality is the API. Instead of a main function (which is already running as the host’s main) there is a factory that creates the plugin. You find it at the end of PluginProcessor.cpp:

```auto
// This creates new instances of the plugin..
juce::AudioProcessor* JUCE_CALLTYPE createPluginFilter()
{
    return new MyFooAudioProcessor();
}

```

Hope that helps

---

<div class="post-metadata">

**Author:** ![Mrugalla](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/mrugalla/32/13092_2.png) [@Mrugalla](https://forum.juce.com/u/Mrugalla)\
**Post date:** [December 25, 2020, 9:55pm UTC](https://forum.juce.com/t/fast-explanation-of-the-4-juces-sources/43442/10 "2020-12-25T21:55:43Z")

</div>

that was unexpected! 🙂 thank you. i really always thought the main.cpp was just not exposed to the juce-user
