Cabbage Logo
Back to Cabbage Site

Updating ftables while being used by distort

Hello, I am trying to make an effect plugin that uses the distortion opcode to perform waveshaping. My goal is to allow the user to update the transfer function with sliders and I have a gentable displaying the current transfer function. I’ve gotten the gentable to successfully update and display the ftable when making changes, however whenever I change the transfer function ftable, I get noticeable clicking in the outputted distortion.

I know this is because I am destructively editing the ftable while it is in use by ‘distort’, however I don’t know what the best practice is to solve this issue.
So my question is, what is the best practice for dynamically updating an ftable when it is continuously being read by a processing opcode?

ChebyDistorter.csd (2.9 KB)

One approach would be to start a second instrument that uses the new ftable, and gently fade it in while the previous instrument fades out and ends. You could constantly swap between the two each time a user updates the table?

Ok thanks Rory, I’m trying to implement a version of that but to little success. The problem is I’m using a slider to trigger the updates in the ftable so whenever adjust the slider, it sends multiple update messages that overlap and creates even worse distortion.

Hi Ben, it should be possible to do this without clicks and I suspect the solution is easier than you think. Here if my own version of the editable GEN13 table and it produces quite smooth results. The table simply rebuilds in a reinit branch and then steps out of the reinit using a rireturn so as to not disturb other performance-time code.
The waveshaping is implemented using a tablei but you could swap this with distort quite easily.
GEN13_14.csd (10.9 KB)

3 Likes

Thank you Iain! This is exactly what I was looking for. I knew there would be an easier solution but I hadn’t known about ‘reinit’. I’m trying to build a plugin very similar to what you’ve created here so this will be a great help with other things as well. Thanks again!