Cycling74 / min-devkit

Tools, documentation, and reference implementation of a Max Package built using the Min-API.
MIT License
158 stars 31 forks source link

Any way to control a number of mc output channels? #156

Open tomoyanonymous opened 4 years ago

tomoyanonymous commented 4 years ago

Hi, thanks for creating a very nice framework. I'm now trying to create a network audio-transfer object with min framework and ffmpeg API(like netsend~&netreceive~ existed in many years ago).

I read an example of mc.min.info_tilde and understood the way to auto-adapt to incoming audio channels but still struggling on changing a number of output channels.

By specifying type on a declaration of an outlet like below,

outlet<> m_output{this, "(multichannelsignal) received output","multichannelsignal"};

I confirmed the first outlet became multichannel signal successfully but with a single channel. However, I could not find a way to modify the number of channels manually... is it not supported yet?

Best regards.

tomoyanonymous commented 4 years ago

Sorry, I solved this by calling Max-API directly. Of course, this totally ruins a cleanness of min-API :( but it worked

namespace max = c74::max;

class rtpreceive_tilde : public object<rtpreceive_tilde>, public mc_operator<> {

//adding callback on class registration
message<> maxclass_setup{this, "maxclass_setup",
                         MIN_FUNCTION{
    auto c = max::class_findbyname(max::gensym("box"), max::gensym("mc.rtpreceive~"));
    max::class_addmethod(c,(max::method)setOutChans,"multichanneloutputs",max::A_CANT, 0);
     return {};
}};

...

//callback will be called on a recompilation of dsp graph
static long setOutChans(void* obj, long outletindex) {
    auto chs = max::object_attr_getlong(obj, max::gensym("channels"));
  return chs;
}

};

maybe is that work if we add a wrapper for "multichanneloutputs" event to c74_min_object_wrapper.h?

tap commented 4 years ago

Thanks for the note. This is a great idea. It would definitely provide a cleaner experience if there were a method that could be called on the outlet.

schramm commented 3 years ago

Hi @tomoyanonymous and @tap. I am trying to change the channel output number in my max-external (min-devkit). I am wondering if there is already an C++ solution for replacing you code above. Any update?

tomoyanonymous commented 3 years ago

AFAIK still not.

caillonantoine commented 2 years ago

Still no way to achieve that ?