Hi, I’m going through Tutorial: Introduction to DSP and getting some errors when trying to build in Xcode. I’ve added in the code per the tutorial but Xcode won’t build and shows a few errors. Pretty sure everything is in the right place and matches syntactically. What did I miss?
These are the errors I get (Unknown type name ‘Type’, Use of undeclared identifier ‘oscIndex’, Use of undeclared identifier ‘gainIndex’, Cannot use dot operator on a type).
Lines 67 and 68 are problematic and incorrect C++. It looks like you may have copy-pasted the wrong thing or perhaps deleted something but only partially.
To be more specific, I think the closing brace }; in line 68 is the problem. This will end the class body at this line and everything after that is interpreted wrong. You probably put it there by mistake.
Thanks for responding! That’s taken directly from the tutorial. Maybe the tutorial needs an update? Their version of Xcode is definitely older than mine.
you are piecing together code, but you have copied it wrong. That whole extra } and ; have to go. and, you should learn more about c++ so you understand why that is wrong. Curly braces work in pairs, in this case that error with the curly brace is because it pairs with the class declaration opening curly brace, closing out the class definition. and then everything after it will just start failing.
It’s a tutorial. I’m placing the code that they’re telling me to use in the places where they’re telling me where it goes. Yes, I need to learn more and that’s precisely what I’m trying to do. Can you help explain why this tutorial has used incorrect C++ then?
The code snippet you refer to, is pulled from the middle of some code. It is showing you something, not telling you to copy and paste it. I see one more place, possibly three more total, on that page where you could run into trouble from just copy/pasting. I can only assume they expect you to understand the language enough to understand that. For example, if I were to tell you this is the sentence you need, “This is the first sentence you need. This is”, your understanding of the language would inform you that the last few words do not go with the previous sentence. To summarize, the tutorial is not wrong, but the code snippets are not meant to be blindly copy/pasted. Again, this mistake is telling the compiler that your class CustomOscillator definition is complete, and thus all the other stuff that follows, and belongs in that class, is not included.
To further point out that there is not a problem with the turtorial, you can download the complete source code and compare it to yours, to see where you went wrong.
Just going to put in my two cents in here and say substitute “float” for “Type” in declaring the processorChain (67) and in the function declarations on lines 71 and 78, assuming you’re not processing audio as doubles.
This is generally done to show you’d be adding this stuff at the end of the class definition, since }; is what ends the class. But if you’re new to C++, it can be confusing indeed.
Thanks for your insight. However, that file is the template file provided in the tutorial (on line 425 it literally says it’s template code). I should be able to build that in Xcode and get the MIDI keyboard, but that doesn’t pop up when it’s done building. It should make this, but it doesn’t:
The rest of the tutorial shows you how to add a couple oscillators, filter, LFO, and reverb. Their example code is not in the template file.
If there’s a finished file with those components implemented, I’d love to take a look. I haven’t been able to find a complete project though.
I completed a C++ course recently, but this is my first foray into DSP, so I’m trying to understand how it’s implemented in JUCE specifically. Seeing it in action would be great but as a tutorial this doesn’t seem very helpful to learn.
I am not sure I understand your comment about ‘template’. The line you reference is in the function isBusesLayoutSupported, and it is referred to as “template code”, because it does not cover all possible channel layouts. It will work for doing mono and stereo, if your code is going to support more layouts, you will need to add to this function.
I was just pointing you to the files as a way to show you where your mistake was. I cannot comment on the tutorial as a whole. There may be a tutorial that suits your needs more, but I have never been through the tutorials. I have purused some of them to find snippets of code to understand usage in context, but not enough to advice you on where to look.
While you may have completed a C++ course recently, you are still learning, as is shown with your confusion in pasting code. I am not being crititcal, just pointing out that a good understanding of C++ would have allowed you to understand the mistake. I understand your frustration though, and still encourage you to focus on the language more. All the tools in the world won’t help you build a house if you don’t know how to use them. I was using C++ long before I started using JUCE, so my path was very different.
I am sure you can find source code on github that is a complete JUCE plugin with a UI. if you just want to look at a working piece of code, so you can understand how DSP works in JUCE specficially.
Are you definitely building the Standalone target, as explained under the “The demo project” heading in the tutorial?
There’s a link to download the project materials in PIP format near the top of the tutorial. This link will download a .zip containing two files: DSPIntroductionTutorial_01.h is the starting point; DSPIntroductionTutorial_02.h is the finished version including all of the code added throughout the tutorial. The 02.h file also includes all of the numbered comments (// [1]) that appear in the tutorial, so you can match these up to find out where each snippet is supposed to go.