What are the most important parts of C++ for coding plug-ins?
-
- KVRian
- 1096 posts since 28 May, 2010 from Finland
-
- KVRer
- 11 posts since 29 Apr, 2022
"My tip is very simple: Learn it by doing."
This is the way
This is the way
- KVRAF
- 10528 posts since 20 Nov, 2003 from Lost and Spaced
I got ChatGPT to code a 2 oscillator 1 filter, 1 LFO, & Chorus VST synth in C++. It didn't put any values in for the internals, but it was a great bare bones structure to learn from.
-
- KVRian
- 761 posts since 5 Oct, 2020
I'd be interested to know what you told chatgpt to get this
also what do you mean it didnt put any values in for the internals? like an lfo with no frequency value?
-
- KVRAF
- 4276 posts since 8 Mar, 2005
Be aware of ‘realtime safe’ code in realtime threads. Look up lock-free programming.
Avoid locks, malloc, logging, anything of that sort in a realtime thread. Use atomics wherever appropriate. The principles are the same across the programming languages, the execution and syntax is different.
Cpp specific: lookup RAII, be aware of rule of zero, rule of seven. Get comfortable with templates and debugging using gdb, run tools like asan, tsan. Stick with modern cpp (avoid c++11). Go for c++17 at the oldest.
Avoid locks, malloc, logging, anything of that sort in a realtime thread. Use atomics wherever appropriate. The principles are the same across the programming languages, the execution and syntax is different.
Cpp specific: lookup RAII, be aware of rule of zero, rule of seven. Get comfortable with templates and debugging using gdb, run tools like asan, tsan. Stick with modern cpp (avoid c++11). Go for c++17 at the oldest.
- KVRAF
- 7890 posts since 12 Feb, 2006 from Helsinki, Finland
Locks are fine as long as you never wait on a lock that might be held by a lower priority thread. Two audio threads using locks to synchronize each other is fine if there's no sensible wait-free alternative. An audio thread waiting for a lock that could be held by a GUI thread on the other hand is a priority inversion and not realtime safe (though sometimes you can get away with this using trywait() primitives in audio thread, if you don't care if it always succeeds and just move along with your audio processing if it doesn't).keyman_sam wrote: ↑Thu Sep 21, 2023 3:37 am Avoid locks, malloc, logging, anything of that sort in a realtime thread. Use atomics wherever appropriate. The principles are the same across the programming languages, the execution and syntax is different.
- KVRAF
- 10528 posts since 20 Nov, 2003 from Lost and Spaced
I think what it thinks it's trying to do is teach me to code. It says it wants Steinberg SDK, which I don't have so I don't know if it would make any difference. I just asked it to code a basic one oscillator multi wave synth. Midi in, pitch and Unison. The envelopes for amp, filter and a LFO. It did the basic frame. The envelopes were all done but no values for Attack Decay, etc.