Buffer and function in genexpr
Hi all,
is it possible to change a Buffer reference in a genexpr function? If yes, how?
In the attached patch I created three gen~ patches: the first one is a simple patch which plays the content of an external buffer, and it works.
In the second patch I used a codebox with the same algorithm, and it still works.
In the third patch I enclosed the algorithm into a function, then called the function, and it doesn't work: that is because the buffer declaration is inside the function and cannot (apparently) be redirect from the 'outside'. I tried to pass the buffer name as a parameter but without success.
Is there a way to make it work? Thanks!
Hi Maurizio
What version of Max?
Hi Ernest,
it is the latest Max 7.3.5
That means I can't help, sorry.
Oh. ran into bandwidth limits again. Hope you can figure it out )
You have it right, you just need to uncomment the Buffer declaration. It has been my experience that buffers need to be declared in the top level, so that there is something to pass the message on to the function. Otherwise the top level [gen~] has no idea what to do with the message when it is received from max. Sort of like Params:
Hi, cptnfantasy, thank you for the reply, but apparently uncommenting the Buffer declaration didn't fix the issue (no sound).
I don't know if I'm missing something: is there something other I should do other than uncommenting the Buffer declaration? Your patch is a completely different example so I don't understand how to use it.
Thanks
.QUASAR Awesome, thanks!
To summarize this very helpful thread:
The buffer to be passed to the function must be declared outside of the codebox with an actual [buffer] operator and NOT anywhere inside the codebox.
Hi I did upgrade eventually and I did not have this problem, and could declare buffers inside codebox. There's a number of ways to do it, including passing the buffer name in as an argument from the main routine. However, you can't use the name of the buffer for another variable because all variables in codebox have global scope in various ways. They are not meant to, but they do. You should use unique names for everything or it may not work.