Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify outlets post-object construction #187

Open
mourendxu opened this issue Dec 19, 2021 · 13 comments
Open

Modify outlets post-object construction #187

mourendxu opened this issue Dec 19, 2021 · 13 comments
Labels

Comments

@mourendxu
Copy link

Hi,

I was wondering if it's possible to change the number of outlets of an object after it has been initialized? If so, how would I go about doing that?

Thank you.

@isabelgk isabelgk transferred this issue from Cycling74/min-devkit Feb 15, 2022
@x37v
Copy link
Contributor

x37v commented Feb 16, 2022

@mourendxu
I have a project that uses min-api and I create my outlets in the constructor..
std::make_unique<c74::min::outlet<>>(this, name) and I store the result in a std::vector to maintain its lifetime.
Maybe this is helpful?

@mourendxu
Copy link
Author

mourendxu commented Feb 21, 2022

@x37v
Hi Alex, thank you for your reply. That's exactly what I am doing now.

What I am asking is can I change the number of outlets AFTER the constructor has been called?

Another way to look at it, can I create an mc like signal operator that will output undetermined(at object initialization time) number of channels?

Thank you!

@x37v
Copy link
Contributor

x37v commented Feb 24, 2022

@mourendxu

min is built on top of the max-sdk which indicates specifically that you shouldn't create inlets or outlets after your initialization routine: https://cycling74.com/sdk/max-sdk-8.0.3/html/chapter_inout.html

Ideally your creation arguments would describe all that you need to specify your i/o. If that isn't possible, could you specify a maximum for inlets and outlets in your creation arguments, create those, and then utilize as needed after?

@mourendxu
Copy link
Author

Hi Alex, thank you for the reply. Yes that's what I thought. No worries. It's understandable due to preemptive buffer allocations.

I will work around it.
Thanks.

@eliottparis
Copy link

eliottparis commented Feb 25, 2022

It was possible to handle dynamic IO with the max-api using the dsp_resize method for inlets and outlet_delete/outlet_append for outlets after the object creation, which can be particularly useful for UI objects. I'm wondering if this is possible with the min-api as well.

@superbigio
Copy link

I can think of only one very specific scenario where changing the number of inlet/outlets after object's instantiation may be useful. For the vast majority of cases, it's just a sign of flawed design.
Having said that, in max-api dynamic inlets/outlets are still possible.
Could you describe a little bit your specific user case?

@mourendxu
Copy link
Author

thank you for the replies. So, I am creating a set of modules to transfer data from another application. In the other application, they do allow for dynamic # of channels.

The way I see it, it should be best handled with mc, since there isn't a need to physically attach connections. A single cable carrying x number of channels.

It's interesting to know that you can do that with dsp_resize. I will take a look there. Thanks.

@mourendxu mourendxu reopened this Feb 25, 2022
@superbigio
Copy link

As I said, more often than not dynamic inlets/oulets are not really necessary.
From your answer I am assuming the data you are talking about is at the audio rate.
So, yes, in your specific case a single mc connection carrying N number of channels should be all that's needed.
If you were to transfer control data, you could easily use a single connection and use lists instead.

@mourendxu
Copy link
Author

Yah, if it was just control data running on the Scheduler thread, the data is so sparse, there is no point in generating multiple outlets. A single outlet w a route/routepass would solve the problem.

Is there an MC project that I can take a look at? I mainly just want to see the standard practice for changing output channels post-constructor.

Thank you.

@superbigio
Copy link

You may want to ask C74/Ableton to share some code snippets that showcase the technique.
For example the [live.gain~] and [plot~] objects implement dynamic inlets/outlets under the hood.

@x37v
Copy link
Contributor

x37v commented Feb 26, 2022

Yah, if it was just control data running on the Scheduler thread, the data is so sparse, there is no point in generating multiple outlets. A single outlet w a route/routepass would solve the problem.

Is there an MC project that I can take a look at? I mainly just want to see the standard practice for changing output channels post-constructor.

Thank you.

If you're just trying to do MC directly.. check the SDK docs: https://cycling74.com/sdk/max-sdk-8.2.0/chapter_mc.html
There is also a min-devkit example that does MC, it is pretty minimal but maybe that is useful for you.

@x37v
Copy link
Contributor

x37v commented Feb 26, 2022

Is there an MC project that I can take a look at? I mainly just want to see the standard practice for changing output channels post-constructor.

https://cycling74.com/sdk/max-sdk-8.2.0/chapter_mc.html#chapter_mc_output_channelcount

I figure you can use a min-api message member to register/implement that method.

@mourendxu
Copy link
Author

Awesome. Thank you folks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants