GEN code export : big annoying Bug , but easy to fix

bruno's icon

Hello Cycling74/Gen Dev Team, I hope you can help me with this,

I found a very annoying bug in GEN and I hope you can fix it , specially since it seems to be something very easy to do for you.

Here's the fact :
I'm making my Gen patches using delay lines etc...
In genexpr / genblock, the delay/buffer size is set to "samplerate" variable. When the entire patch is converted to c++ code, the "samplerate" variable is converted to the INTEGER value of the sampling rate CURRENTLY used by MAX, for example (in the exported .cpp file) you'll find :

"m_delay_22.reset("m_delay_22", 44100);" //this is what is ERRONEOUSLY exported by max/gen

..it should be...
"m_delay_22.reset("m_delay_22", samplerate);" //this is what it should be exported

...It happen also with fractions, for example :

"m_delay_22.reset("m_delay_22", 22050);" //NOT CORRECT
..it should be...
"m_delay_22.reset("m_delay_22", samplerate/2);" //this is what it should be exported

As far as I know, I noticed it happen in the "Reset()" c++ method but maybe it may happen in other places...
And, as far as I know, I noticed it happen with the "delay" line GEN OBJECTS but maybe it may occur with other GEN OBJECTS too...

I'm currently MANUALLY modifying the exported .cpp file each time I export cpp from GEN :
replacing "44100" with "samplerate",
replacing "4410" with "samplerate/10",
replacing "22050" with "samplerate/2",
etc...(very annoying :))

I hope you can help me with this ! If you need additional infos, just ask me :)

P.S. NOTE : If you start a gen patch and create "delay" blocks setting size to "samplerate", and you see at the (right side, "C" icon) genexpr code that is automatically generated on the right side panel, you'll notice that "samplerate" variable is replaced with 44100. So maybe this error happen AT FIRST in genexpr, a step before exporting to c++ code...

Ben Bracken's icon

Hi Bruno,

We are aware that this is a problem for some developers using exported Gen code, and it is ticketed as something to look at down the road. Apologies for the inconvenience in the meantime.

-Ben

g2312's icon
bruno's icon

Thank you Ben for your quick reply and support,

I wish that issue will be solved in the next update and that GEN will continue to be improved, because it is really awesome.
I noticed that the bug (I mentioned earlier) occurs with "delay" , but also when a GEN OBJECT/BLOCK "expr" is exported to c++, as mentioned by Thomas (g2312) in his post/thread.
The variable "samplerate" is exported as 44100.

Cheers,