Want to learn good C++ and set up a simple demo project - Feedback welcome!


As I’m a student of electrical engineering, I learned some C programming for microprocessors at university, after that I taught myself how to use C++ in the context of Arduino programming, but I never learned C++ in any lecture from scratch. But I had a Java lecture some years ago. Even if I don’t remember any piece of Java code, it gave me a good impression of the ideas behind object oriented programming.
I’m familiar with theory and practice of digital (audio) signal processing and I’m a musician and sound engineer myself, but I only did MATLAB and MAX MSP based software Projects and FPGA based hardware projects until now. My goal is to be able to use the power of modern CPUs for linux powered embedded audio devices as well as for cool Mac/PC based Audio Plugins in future.

So it’s time for me to learn a lot of different stuff. As a starting point, I want to start improving my C++ skills and then go on and practice some other programming languages. I’m glad to have found JUCE as an easy starting point. I already played around with a simple VST plugin, but I think it’s good to get familiar with efficient algorithm programming before starting to build a gui, so I started with a simple command line tool, placing a biquad filter between the default system in- and output. It is meant to be a learning project rather than to be a really useful application.

You’ll find my project here: https://github.com/JanosGit/simpleAudioFilters

I wanted to try to focus on different things:

  • inheritance: The biquad class inherits from the myAudioProcessor class, myAudioProcessor should be a base class for all classes that process audio and should have virtual member functions, that are implemented by its child classes
  • readability: The code should be well structured to help other people understanding my code. I’m no native english speaker, but I tried to use my best english :wink:
  • performance: I tried to implement the critical audio processing part as efficient as possible

Now I would appreciate some feedback! What can be done better, what is good? Any suggestions for good websites/books?

And there are two special questions:
In line 29 of myAudioProcessor.h the virtual destructor is commented out. This way, the project builds without errors, but Xcode show the warning

'myAudioProcessor'h has virtual functions but non-virtual destructor

But if I remove the comment, I get the linker error

Undefined symbols for architecture x86_64:
"myAudioProcessor::~myAudioProcessor()", referenced from:
  biquad::~biquad() in biquad.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

What is wrong at this point?

The second question is how to setup a JUCE based project, so that it could be shared via github? I cloned the repo to a different machine with JUCE installed, but all search paths in the project were absolute paths to the JUCE folder on the machine, the project was created with, so I was unable to build it with that configuration and had to change all paths to all modules. I’m sure there is a better way :wink:

1 Like

Re: destructor

You want:

virtual ~myAudioProcessor() {}

Instead of:

virtual ~myAudioProcessor() = 0;

1 Like

The best way is to:

  • Add JUCE as a git submodule to your project
  • Include the jucer file, your source but not the contents of the Builds folder into the repo

The user of the code then can checkout the correct version of git, use the projucer to create the appropriate Builds files and build the app.

This is harder than it should be (there should be some tooling in JUCE to make this easier!), but it’s definitely the cleanest approach.


I also come from electrical engineering. I recommend the book ‘The C++ Programming Language’ from the C++ creator Bjarne Stroustrup.


Thank you, that works!

Thank you, I took a look at the JUCE API documentation but didn’t come across this links. That answers a lot of questions and gives me a good starting point on improving my C++ skills.

I didn’t know git submodules until now although I missed a feature like that some time ago… Seems like a good solution!

Just by reading the JUCE coding standards I now found a lot of things to improve in my own code, from naming convention to avoiding to use delete. A lot of things now seemed absolutely obvious to me, after reading that short explanations. My code definitively looks better now, even if I haven’t paid attention to all the points mentioned until now.