Pyo equivalent to SuperCollider's Env object

28 views
Skip to first unread message

kjel

unread,
Sep 14, 2022, 1:01:31 PM9/14/22
to pyo-discuss
And another one,

I'm curious if there's anything in Pyo as flexible as SuperCollider's Env object. With that object one can define an envelope in terms of three arrays representing respectively: signal amplitude, duration between the amplitudes, and the curvature of the segments, taking the form:

Env.new(levels: [0, 1, 0.9, 0], times: [0.1, 0.5, 1], curve: [-5, 0, -5]).plot;

In the curve array, zero represents a straight line, positive numbers represent an exponential curve, and negative numbers represent a logarithmic curve. As far as I can tell, in Pyo, Expseg allows us to globally define the steepness of all the curves, with 1 being straight lines, but doesn't allow us the granular detail of varying the level of curve at each breakpoint. Is there a way to implement something like the SuperCollider paradigm described above in Pyo? It would be great to be able to define complex envelopes of this nature especially since it is fairly common to want an exponential attack but then a flatline sustain for instance. 

In SuperCollider it's straightforward to throw this general envelope onto a midi event. We just have to define a release node (the address in the levels array where we want our midi event to sustain) and then we put this Env in an EnvGen.kr to instantiate it on the server, and then we assign that to a SynthDef. We can then play this Synth with a midi instrument and the envelope should work. In Pyo, it seems we are pretty limited with our midi options. We have MidiAdsr of course, MidiDelAdsr, and MidiLinseg. We don't have MidiExpseg let alone something that allows for variable curve breakpoints. Am I understanding this right or is there something I'm missing. I'm very new here and coming from a Supercollider/Max background so I'm open to there being more pythonic ways to accomplish these same ideas.

Thanks again,

Kjel

kjel

unread,
Sep 14, 2022, 1:10:16 PM9/14/22
to pyo-discuss
This is also not a criticism of Pyo whatsoever. I have a huge respect and appreciation for the immense work Olivier has put into this project. It is already amazing how much we can do with Pyo and it would make sense that there are certain things that haven't been implemented or aren't possible. I'm just curious to learn more and add my voice to the conversation.

Kjel

Aaron Krister Johnson

unread,
Sep 14, 2022, 2:49:26 PM9/14/22
to pyo-d...@googlegroups.com
There is ExpTable, but it's not MIDI compatible without a lot of manual manipulation, and wouldn't really understand the concept of MIDI "release".

If you didn't need varying powers/slopes, conceivably, one could pipe the output of a MidiAdsr through a nonlinear transformation like Pow().

But the generalized MIDI-ready envelope you describe needing? I don't think it's yet a thing in Pyo.

If you're feeling up to it, you could take template C-code for MidAdsr, and drum up a new object for the repo that expands on it....?

On another note, in Csound, I was playing with the `faust2csound` that exists in `faust`. It would be great to create a `faust2pyo` script that would essentially make
a `pyo` plugin object from a high-level DSP description in `faust`....I think that's the future!


--
You received this message because you are subscribed to the Google Groups "pyo-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyo-discuss...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyo-discuss/74c7a457-c378-4fac-998b-2d86343833bcn%40googlegroups.com.

kjel

unread,
Sep 14, 2022, 7:37:50 PM9/14/22
to pyo-discuss
Hi Aaron,

Thanks for your message. I like the idea of applying Pow() to the MidiAdsr() in a pinch even if it's not as detailed as it could be. I would love to eventually contribute to the project, but I have a basic level of C++ and no experience with C. That being said, I am always open to learning. I scanned through the repo and it looks like the code for MidiAdsr() is buried in pyo/src/objects/midimodule.c. It's all way over my head for the moment but I'll see if I can come back to it at some point when I have more knowledge of C. 

Haven't tried Faust yet but I hear good things!

Kjel

Aaron Krister Johnson

unread,
Sep 15, 2022, 4:22:43 PM9/15/22
to pyo-d...@googlegroups.com
N.B.: if you apply `Pow()` to `MidiAdsr()`, I think the latter is 0-1 scaled, and depending on your base that you're raising from, you'll want to re-normalize, likely by subtraction and multiplication

Consider that `Pow()` is like python's `math.pow()`, but applied to a vector signal. So, you can see that:

math.pow(2, 0) = 1
math.pow(2, 1) = 2

and

math.pow(10, 0) = 1
math.pow(10, 1) = 10

so in general, after any signal ranging from 0-1 is applied as the exponent, you'll want to subtract 1 and divide by the (base - 1)

so if the general form is

math.pow(b, x)

and x is your control or audio signal, you'll do:

base = Sig(<your_real_base>)
scaled_control = (Pow(base, MidiAdsr(...)) - 1) / (base - 1)

and your scaled control will now be between 0-1 in range, but have analogous curvature that you want per a given power base.

This works similarly with `Log()`

Cheers,

AKJ

Olivier Bélanger

unread,
Sep 27, 2022, 7:25:11 PM9/27/22
to pyo-d...@googlegroups.com
Hi,

I think adding "loop points" to Linseg, Expseg, and MidiLinseg could be a nice addition to the library... Added to my TODO!

Olivier


kjel sidloski

unread,
Sep 28, 2022, 8:27:45 AM9/28/22
to pyo-d...@googlegroups.com
That’s great, thanks Olivier!

Kjel

On Sep 27, 2022, at 7:25 PM, Olivier Bélanger <bela...@gmail.com> wrote:


You received this message because you are subscribed to a topic in the Google Groups "pyo-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pyo-discuss/Y3Eu-O7lYRM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pyo-discuss...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyo-discuss/CAMXBGhRwY6u%2BWBX4spT3YcMbUCz_N5y5au87VLvnQ_cvCXL1ZQ%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages