Copying [function] graph (with curve!) to a [buffer~] ? [solved!]

MuShoo's icon

Alternately: How to trigger [function] at audio rate...

Basically, I have a patch I'm working on that triggers a number of things with audio-rate clicks (sometimes just one click, sometimes a series of very fast clicks, so snapshot~ is out of the running). I'd like to be able to draw a curve in a [function] and use that for both amplitude and frequncy modulation of a synced oscillator as a sub-thump generator that goes along with the stuff my clicks are triggering.

My current thought is to somehow get the output of [curve~] driven by my [function] into a [buffer~] that I can then reference in [gen~] as a wavetable. So far, the only way I've figured out how to do this is by triggering a [record~] to copy the output of [curve~] in realtime over to the buffer. But that's slow! And requires user input! (Though I suppose I could sync the 'mouse changed' bang from function to the record~ object in a janky way...) But even then, if someone draws a 10 second curve, it's gonna take 10 seconds to record down, which is... slow.

*ten minutes later!*

Right so... Typing all that out made me realize something. I can just keep the buffer and the function locked to 100ms (which is about 4800 samples or 9600 samples at the sample rates I expect this to be used -- more than enough for what I'm doing!) I'm still triggering a [record~] object to actually do the transfer, but 100ms is fast enough for what I need, as nobody will need to be drawing the function 'live.'

Then inside my gen, I can pick it up with a wave object, and just drive the phase with some math to stretch it or shrink it to the length the end user chooses! Easy peasy lemon squeezy. Well, except for all that math. I've been living inside [gen~] a lot the past few days, feels like my brain is mush...

Anyway, figured I'd stick this post up (maybe a patch once I've got it all nice and dandy) just in case anyone else ends up with a similar issue - I had a rough time searching the forums for help with this one!

Luca Schwarz's icon

Hey mate. Could you maybe post the patch here ? Would be cool to try this out!

MakePatchesNotWar's icon

You can also make shape~ behave like curve~ itself and trigger it sample accurately

<pre><code>
----------begin_max5_patcher----------
1758.3oc0Zs0iahCE94To9e.wiqlFgMlaUpq182QUUDA7j3VhAAlYl1pc9su
9BDtj.wjA5jLOPz3iAe99NW3X742e7CqL2l9Btvz3yFe0X0peyGYkbLwHqpG
Xk4gvWhRBKjSzjVdXKN+UyGpElFiEBf0Cvm.glfYEcF8wTJ6wvH4TspGjDKe
joa+9mbO9.KH6jSZ8wokExh1Sn61jiiXJsEAAb4F1dhoY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