For SC itâs almost that easy.
// this is your array
b = Buffer.alloc(s, howManySamplesDoIWantToRecord, 1);
(
a = {
var signal = theSignalIWantToRecord;
// RecordBuf = tabwrite~ basically
// assuming signal is ar -- if it's kr, write RecordBuf.kr()
RecordBuf.ar(signal, b, loop: 0, doneAction: 2);
Silent.ar(1);
}.play;
)
b.plot; // or see also b.get, b.getn, b.getToFloatArray
Alternately,
p = { ... audio or kr stuff... }.plot;
p.value[channelIndex] // this is an array of sample values
Most plot examples donât assign it to a variable, but all the data are available through the plotter object.
Since Pd doesnât have any concept of control rate, you donât want to render the samples of an envelope at .kr and check against Pdâs audio rate envelope.
It would be relevant to look at the conversion of the control rate envelope up to audio rate: K2A.ar(krEnvelope).
What you will find, at that extreme curve value, is a series of line segments, each 64 samples long, quickly dropping to near zero (for the decay). This precise signal will be prohibitively difficult to generate in Pd. I think youâre wasting your time to try to replicate this curve exactly.
One weird thing is that youâve specified a 30-second decay, but with a really kind of outrageous curve value. The decay segment reaches pretty close to 0 within one second. So why not just write a one-second decay with a more moderate curve? Then your volume envelope will be able to release the synth after one second instead of after 30 seconds.
An attack time of 0 is something I would never recommend to my students. 2 or 3 ms is fine for percussion.
I think if you clean up the envelope definition, the difference between ar and kr will be greatly reduced. Then you have less of a moving target to try to imitate in Pd.
The difference between ar and kr here is especially in the attack segment, where the curve (way too big a curve value IMO) causes it to rise extremely quickly. kr then effectively acts like a slew limiter. So itâs a bit convoluted: generating a near instantaneous rise, but at control rate so that it will be slowed down, and then trying to mirror this behavior in Pd. If you define the desired envelope shape in simpler terms (times matching the actual perceived rise/fall times, curves within +/- 5, there is usually not much need to have curves outside of this range), it will be simpler to port.
hjh