Queries from MAX SDK - Anatomy of MAX MSP object?


    May 03 2021 | 3:27 pm
    Hello,
    I have two questions from the code provided in the chapter Anatomy of MAX MSP object of Max sdk. (https://cycling74.com/sdk/max-sdk-8.0.3/html/chapter_msp_anatomy.html). The code is under the DSP Method and Perform Routine section of the chapter.
    1) What is the int n = sampleframes? The commented part says vector size. But It is not very clear to me. It is definitely not the number of samples in the signal. Is the same as Signal Vector Size or I/O Vector Size in the Audio Status window?
    2) How do I print (using post) the values that I receive at the outlet?
    void mydspobject_perform64(t_mydspobject *x, t_object *dsp64, double **ins, long numins, double **outs, long numouts, long sampleframes, long flags, void *userparam){ double *in = ins[0]; // first inlet double *out = outs[0]; // first outlet int n = sampleframes; // vector size t_double value; while (n--) { // perform calculation on all samples value = *in++; *out++ = value + 1.0; } }

    • May 03 2021 | 9:14 pm
      Hi! 1) The difference between I/O and signal vector size [MSP: Audio Input and Output documentation] is:
      The I/O Vector Size (I/O stands for input/output) controls the number of samples that are transferred to and from the audio interface at one time.
      The Signal Vector Size sets the number of samples that are calculated by MSP objects at one time. This can be less than or equal to the I/O Vector Size, but not more. If the Signal Vector Size is less than the I/O Vector Size, MSP calculates two or more signal vectors in succession for each I/O vector that needs to be calculated. With an I/O vector size of 256, and a sampling rate of 44.1 kHz, MSP calculates about 5.8 milliseconds of audio data at a time.
      The vector size that comment refers to is the signal vector size. 2) You can post to the console with one of these functions: https://cycling74.com/sdk/max-sdk-8.0.3/html/group__console.html . Posting on every sample of a DSP calculation will likely flood your console, if you want to post on every output sample, though.