Hi, I’m relatively new to cabbage and I just finished my first project. Though I am not new to coding, I am also not really that professional at it (everything I know I learned it through the internet lol), and I had a few questions about how I made it work and how I could improve it.
It is an unusual multiband dynamics shaper that is based off a system that has been in my head for a few months (in fact, I just went to cabbage to make that system in the first place). It works by dividing the spectral field of a signal into a certain number of bands that is defined with a knob, and then independently getting the amplitude of each band in real time using different methods that the user can change for different tonality and character, and then each band uses it’s value to change the volume of the signal it comes out of it. Using this method, quiet frequencies get quieter and louder frequencies get louder. This can be used for obtaining really interesting characters and changing the tone of the sounds you put through it. I’ve tested it and it’s really fun to mess around with it as I had predicted, but I have one issue with it. The cpu performance could be better. And that might be because of how I wrote the code.
If you open the code you’ll see there’s a massive amount of lines that are basically duplications of the same snippet of code but with increasing numbers. That is the system that splits the audio’s spectrum into up to 100 different bands and processes the bands. I made it this way for two reasons to make the user able to decide what number of bands they want to split the audio into (this way the user can manage the cpu usage because the code for the bands that are not used is just ignored, saving cpu). I know I could have written it more efficiently using a for loop, but I thought it would be more straight-forward for the cpu to read it this way, and hopefully more efficient.
My question is, is using a for loop more optimal or not? and if it’s not, is there a better and more optimized way to write this apart from using a for loop?
Here’s the code so you can check it out:
Sharpener.csd (169.9 KB)