micah-frank-studio / Prototypes

Audio Plugin Sketches
GNU General Public License v2.0
185 stars 18 forks source link

Grainstation-C performance optimizations #1

Open micah-frank-studio opened 4 years ago

micah-frank-studio commented 4 years ago

2 parameters can be adjusted for better performance optimization.

The file you need to edit is:

OSX Audio Units: /Library/Audio/Plug-Ins/Components/Grainstation-C.component/CabbagePlugin.csd OSX VST : /Library/Audio/Plug-Ins/VST/Grainstation-C.vst/Grainstation.csd

Windows: C:/ProgramData/Puremagnetik/Grainstation-C/Grainstation-C.csd

Be sure to quit the plugin before changing.

1) ksmps The number of samples per control period. I set this pretty high at 64 for higher resolution. Try changing it to 32 or 16.

2) giwindow in the spectral analysis section is very cpu intensive and is set at 1028. increase by factors of 2 (e.g. 2056, 4112) for better performance.

nay-seven commented 4 years ago

Hello, thanks for the tip found ksmps, but not giwindow ? ( OSX VST and AU)

find this line ? giwin ftgen 1, 0, 8192, 20, 2, 1 ;Hanning window

And don't found 1028 value

micah-frank-studio commented 4 years ago

ahh - be sure to download the plugin again. I added the giwindow param to make it easy to edit. Or just pull the updated .csd from here then add it to the plugin folder: https://github.com/micah-frank-studio/Prototypes/blob/master/GrainstationC/Grainstation-C.csd

micah-frank-studio commented 4 years ago

FWIW I'm running MBP 2.3 GHz Intel Core i5 and the default settings are OK. If you run into buffer problems, it could be something else. Curious to know.

nay-seven commented 4 years ago

Yes, strange, here MBP 2.7 Ghz Core i5, 8 of ram, 2015 tested in VCV Rack and Reaper, modifications don't seem to change something

rorywalsh commented 4 years ago

I'm not sure changing ksmps will make that much of a difference. The lower it is the more blocks that will get processed every second, but increase it too much and it will cause problems too. I think 64 is pretty reasonable. It also helps when it matches the hosts buffer size. I only see crazy CPU when I play a lot of notes in quick succession. I'm not sure that's the intended use for this instrument?

It's definitely the phase vocoder stuff that is draining the CPU. If you comment out the bulk of the pitchdelay instrument and just return ainL, ainR the CPU usage drops by half. Of course you then miss the nuances of that effect. Perhaps an optional disable button for the spectral delay might work for users who plan to go crazy with this? Alternatively, you could replace it with a time domain pitch shifter, but you would give up any hope of preserving formants.

micah-frank-studio commented 4 years ago

Could also try a mono pitchshift so it only analyzes one stream.

```

/ delay R alfoR lfo 0.05, 0.1 ; slightly mod the right delay time abuf2 delayr imaxdelay atapR deltap3 kdelay+alfoR delayw ainR + (atapR kfeedback) fftinR pvsanal atapR, giwindow, giwindow/4, giwindow, 1 ftpsR pvscale fftinR, kfbpshift, 1, 2
atpsR pvsynth ftpsR
/ atapL = atapL + atapR0.02 ;introduce a little xmodulation ; atapR = atapR + atapL*0.07

kpitchMix = 0.5 ; pitch mix disabled, can add on later in opcode argument
;mix between pitched and unpitched delays
kinvctrl = abs (kpitchMix -1)
amixL = atapL*kinvctrl + atpsL*kpitchMix
; = atapR*kinvctrl + atpsR*kpitchMix

xout amixL, amixL

nay-seven commented 4 years ago

it's definitively linked to tempo, in VCV Rack tempo =30 (for a simple sequencer + grainstation) = 50% of cpu, tempo of 100 give more than 80%

micah-frank-studio commented 4 years ago

Grainstation-C "Lite" https://github.com/micah-frank-studio/Prototypes/blob/master/GrainstationC/Grainstation-C-lite.csd

Slight performance improvement. Pitch delay is mono and has larger FFT size. Try it out. If it needs to be reduced further, we can remove the fft altogether or put it on a shared bus rather than an opcode.

To activate this "lite" version just replace the .csd file in the plugin folder with this one.

*and rename it to match the .csd in the plugin folder"

nay-seven commented 4 years ago

Thanks, but there's no more UI visible with this version ?