MSP object with no audio inlets or outlets

    Oct 20 2009 | 2:11 am
    Hi there,
    here I am stumbling upon something that I thought I knew, but seemingly I don't... I need to write an UI MSP object with no audio inlets or outlets. The only reason why it needs to be an MSP object is because I need to retrieve the sampling rate... exactly like filtergraph~ does it.
    So in my new_method I write:
    obj->inletnum = 0;
    obj->proxy = proxy_new((t_object *)x, 1, &x->inletnum);
    dsp_setupjbox((t_pxjbox *)x, 0);
    x->out = listout((t_object *)x);
    This should give me 2 non-audio proxy inlets and 1 list outlet, and it does...
    Problem is that in my dsp method I need to write something like:
    void myobj_dsp(t_myobj *x, t_signal **sp, short *count)
    x->samplerate = sp[0]->s_sr;
    and at this point Max crashes.
    So my question is do I need to instantiate a dummy signal inlet or outlet in order to retrieve the sampling rate from the t_signal structure ?
    If I write:
    dsp_setupjbox((t_pxjbox *)x, 1);
    then everything works fine.
    - Luigi

    • Oct 21 2009 | 9:59 am
      Is there a reason you don't want a dummy signal inlet? As far as I'm aware, a signal inlet is a proxy anyway, so you can retrieve max messages through it
      Will this not work? :
      1 - create only one proxy inlet and a signal in
      2 - don't tell anyone that it's an audio inlet
      Someone can connect a signal to the input without it complaining, but that's probably true anyway. Check this example:
      Turn audio on - check max window - no complaints.
      Looks like this is the way to do this!
    • Oct 22 2009 | 9:08 pm
      No, I have no problem with creating a signal inlet.
      However, I want to make sure that's the proper way you handle the situation in this case. Even if the dummy inlet makes it work maybe I am overlooking something else and there is a way to make it work without signal inlets or outlets at all. This would be the preferred way since it doesn't make sense that any signals are allowed to connect.
      However it might turn out being a feature since - as I read your reply to the previous thread - we can then force DSP chain order this way... Just thinking out loud...
      You're probably right that the one dummy inlet is the way to go...
      - Luigi