SC - C++ a good resourse for learning it?

Hi,
someone knows a good resourse in YouTube for learning C++?
As SC is made in C++ Im interested in learning the language,
thanks,
Oxxo.

I learned/still learning it using https://www.learncpp.com/ - chapter 12 is the most essential one Id’ say. I personally couldn’t learn things via YouTube, I need the written format and you’ll need to look up things a lot in https://cppreference.com/

I’d say UGens will provide you with a good starting point to go down the rabbit hole of C++. Start by looking at some UGens that you enjoy - e.g. sc3-plugins provide a good resource to get started in order to understand how UGens work [don’t use the internal SuperCollider UGens for that - they are highly optimized which results in really confusing code sometimes] - use this knowledge to think of a UGen that you would like to build and start building it.
Then you can start looking at the sc-ide, which is probably the least complex part of the SuperCollider project.
OFC you can also start by hacking the interpreter if you prefer a steeper learning curve.

I’d also recommend to use CLion over vscode or else, since it provides you hints on memory allocaction bugs which you will definetely run into. Also their debugging tools are really good IMO. They changed their license recently so it is free to use when working on FOSS.

If you’re more of a youtube type, then the Cherno’s channel is a very good starting point. He’s a game developer, so the channel is biased a bit in that direction.

1 Like

I’d strongly recommend looking at cpp cons videos, they have whole lectures on literally everything cpp, from beginner to wizard. They are amazing :heart_eyes:

I’d make sure to you understand object lifetimes as a first point of call, then look at move semantics and the rule of 5, it is complex, but very important to understand how memory management works in modern cpp. No need to dig into prvalues, but you should know what && means (ignore universal references) and what std::move does before working with memory.

Re sc’s codebase, a lot is in an old c with classes style - not all, but enough that if you want to contribute it can be pretty tough! Not to put you off, but just be prepared that it will take a while to feel comfortable with the code.

I was looking for same resources and this is what I’ve found so far :

1- Chapter 25 of The supercollider book - > Writing Unit Generator Plug-ins - Dan Stowell
2-Mads tutorial → Release Update the tutorial · notam02/supercollider-plugin-tutorial · GitHub
3- A good playlist on youtube from the Audio Programmer : https://www.youtube.com/playlist?list=PLLgJJsrdwhPyl4gGqn-bGsCR_kIstLMGk
4- online compiler → https://wandbox.org/
5- A very good book : Audio Programming in C++ - The Beginner Level → Håkan Blomqvist

2 Likes

Thanks to all! a lot.

I also found tis resourse:

This won’t teach you C++ fundamentals, but if you want DSP concepts broken down in a way that doesn’t assume you have a deep understanding of C++, check out my website. If you’re coming from SC, I’m assuming you’re wanting to learn C++ for DSP reasons and the content I post is DSP focused.

There’s information on oscillators, phase accumulation, antialiasing, lookup tables, polynomial approximations, FFT, filter theory, and implementations done in C++/JS (WebAudio). Plus a ton of interactive applets.

I took C++ at Johns Hopkins and I was interested in none of what we were making in that class. Things like

class Employee {
     private:
         std::string firstName;
         std::string lastName;
         int monthlySalary;
     public:
         Employee(std::string first, std::string last, int salary) : firstName(first), lastName(last), monthlySalary(salary >= 0 ? salary : 0) {}
}
1 Like

Hi, mjsyts:

Im learning Python a lot - Im in advanced Pyhton, but I want to figure if the C++ is more and more complex than an advanced Python? Just to know to what Im going to prepare.

I had recently seen a claim that if you’re a programmer who already knows fundamentals and is familiar with common algorithms, you can get “proficient” (whatever that means) in Python within about 6 months. But the same level of proficiency would take 2 years in C++.

AFAIK C++ is a lot more complex than most other modern languages.

hjh

When looking for resources, first keep in mind two kinds of ignorance/unawareness:
The first is the ignorance one knows one has. A problem shows up, you recognize the gap, you look it up, you fix it, you move on. That’s build systems, libs, toolchain nonsense, whatever hype framework is hot this week. Learn it only when it shows up.
Learning it in advance is wasted attention.

The second kind is the tricky one. It quietly shapes every decision you make and leaves you convinced you chose something when you never had a chance. Your code slow, and you don’t know it could be fast. You write what you think is “the thing,” when really it’s just a weak version of it, because you brushed past something you couldn’t know was important in that context. This is the unawareness that eats you, because you can’t see it coming.

Against this kind of ignorance, you can’t google. You can’t even ask it clearly on a forum like this one, because you don’t know what you’re missing.

About cpp itself, a common mistake: people think it’s an OOP language, a sort of painful version of sclang. Don’t think that way. It was never really true, and it makes even less sense as time goes by and C++ evolves.

Modern c++ is genuinely a multi-paradigm language, and a lot of serious work leans toward value semantics, composition, data-oriented design, even functional-style thinking. People like Bartosz Milewski didn’t bring Haskell ideas into C++ for fun or to show off. They did it because it maps better to how you actually want to reason about fundamental stuff.

The one who defaults to building oop hierarchies of audio objects in cpp often brings the wrong instincts. In the hot path, with samples moving around, it usually gets in the way.

The part that’ll be the real deal for you: real-time audio is not normal programming. It’s programming under a very specific constraint. A deadline arrives every few milliseconds. Ruthless, all the time. Either you meet it, or you get a loud glitch everybody in the room hears while you cringe on stage playing your instrument. From this follows a rule you treat like your new law of gravity: no allocations, no locks, no blocking, nothing you ain’t sure about. Outside the audio thread, do whatever you want.

In SC, the server enforced that law for you. You was protected. In cpp, you the one enforcing it. Once you leave that model, you ain’t optimizing within a system anymore. You’s deciding what the system even is. Memory layout, scheduling, vectorization, fusion, execution order, these stop being implementation details and become design decisions.

Modern cpp actually helps a lot when used right. Don’t misunderstand me saying “don’t use them when doing rt audio.” I’m not saying this. RAII for clean resource management, move semantics to avoid unnecessary copies, std::span to pass a buffer without pretending you own the data, constexpr to move work from runtime into compile time. You lean on those for real-time work. It will give you clarity and performance.

In other words: discipline. Same kind of discipline you need when you writing sclang on the language side, when you interfacing with the server, or when you writing a SynthDef (which looks like sclang, but you can also understand it as a DSL). Know you are writing different kinds of code.
SC’s UGens are well-crafted, and the server model gives you real performance when you stay inside it. Solid design that proved itself for 20+ years. But all that optimization lives inside a specific design box: fixed block sizes, graph traversal, node-based execution, a particular scheduling structure. It’s one special case of how things could be done, not what’s possible in cpp starting from scratch. To write a UGen is not to write “free” high-performance cpp dsp. It’s to write dsp that fits that system.

And a lot of what you write as a plugin isn’t even DSP. As Miller Puckette once said, it’s “90% weird glue.” So don’t confuse “this is how optimized audio code looks” with “this is how optimized audio code must look.” Outside that model, there’s a much larger territory. Every system erases 99.9% of what one can achieve with a finite amount of human effort.

In a nutshell: learn features and libraries as you need. Learn ownership and lifetime early, how the machine works, etc, because you won’t know to go looking for it once it’s already cost you. Treat real-time constraints like laws of physics. Everything else, pick up as you go. Don’t waste your time there.

Last thing: the actual bottleneck to learning anything, not just cpp, is having fun. Without fun, you’ll move on before the good part. Be careful with hostile places that chip away at your joy of exploring. Don’t underrate fun.

2 Likes

Thanks to everyone for all the helpful links in this thread. I’m trying to get started with learning C++ for audio and found them helpful. While I have plenty of experience with other OO and functional languages, I’m new to C++ and audio programming.

I’ve been going through a few resources that I’ve found to be a good intro, focused on C++ and audio plugins rather than SC specifically, but I like that they a combine C++ intro with an audio focus and DSP, and have hands-on projects that you can follow along with and code.

A nice, free online course on building an audio effect plugin with C++ and juce :

Also, videos and books on the audioprogrammer site. The “Creating Synthesizer Plug-Ins with C++ and JUCE” book is a very well-written intro to synth plugins and DSP.

Don’t forget the core guidelines!