GEN Code Export Bug with : "divide by samplerate"

bruno's icon

Hello Cycling 74 team ,

I would let you know about a bug/issue with GEN and C++ code export.

Using visual patching objects like "expr" or "/" or "!/" to divide a number by SAMPLERATE (example : "1/samplerate"), everything works fine INSIDE GEN, but if you use the code export function to export c++ code for that patcher, in the generated .cpp file this is what happen :

(1/samplerate) is exported as : (1 * 2.2675736961451e-005)

(2/samplerate) is exported as : (2 * 2.2675736961451e-005)

and so on... (the number : "2.2675736961451e-005" is a fixed RESULT for "1/44100").
This bug is very nasty because it will not allow samplerate changes in the exported cpp code (apps/plugins/etc...)

In the patcher I attached to this post, you'll find all details and examples.

Thank you for your attention.

divided_samplerate_issue.maxpat
Max Patch
Graham Wakefield's icon

Hi Bruno

This should be fixed in the next update.

It was an optimization from another feature request (to convert division by constant into multiplication by its inverse, for efficiency) that had incorrectly treated samplerate as a constant in code export.

Graham

bruno's icon

Thank you Graham for your quick support !