t_max_err mode_set(t_hoa_decoder *x, t_object *attr, long argc, t_atom *argv) { if(argc && argv && atom_gettype(argv) == A_SYM) { if(atom_getsym(argv) == gensym("ambisonic") && x->f_decoder->getDecodingMode() != Hoa2D::DecoderMulti::Regular) { object_method(gensym("dsp")->s_thing, gensym("stop")); x->f_decoder->setDecodingMode(Hoa2D::DecoderMulti::Regular); object_attr_setdisabled((t_object *)x, gensym("angles"), 1); object_attr_setdisabled((t_object *)x, gensym("channels"), 0); object_attr_setdisabled((t_object *)x, gensym("offset"), 0); object_attr_setfloat(x, gensym("offset"), (float)x->f_decoder->getChannelsOffset() / HOA_2PI * 360.f); } else if(atom_getsym(argv) == gensym("irregular") && x->f_decoder->getDecodingMode() != Hoa2D::DecoderMulti::Irregular) { object_method(gensym("dsp")->s_thing, gensym("stop")); x->f_decoder->setDecodingMode(Hoa2D::DecoderMulti::Irregular); object_attr_setdisabled((t_object *)x, gensym("angles"), 0); object_attr_setdisabled((t_object *)x, gensym("channels"), 0); object_attr_setdisabled((t_object *)x, gensym("offset"), 1); } else if(atom_getsym(argv) == gensym("binaural") && x->f_decoder->getDecodingMode() != Hoa2D::DecoderMulti::Binaural) { object_method(gensym("dsp")->s_thing, gensym("stop")); x->f_decoder->setDecodingMode(Hoa2D::DecoderMulti::Binaural); object_attr_setdisabled((t_object *)x, gensym("angles"), 1); object_attr_setdisabled((t_object *)x, gensym("channels"), 1); object_attr_setdisabled((t_object *)x, gensym("offset"), 1); } object_attr_setlong(x, gensym("channels"), x->f_decoder->getNumberOfChannels()); } send_configuration(x); return MAX_ERR_NONE; }
void fade_perform64_2(t_fade *x, t_object *dsp64, double **ins, long numins, double **outs, long numouts, long sampleframes, long flags, void *userparam) { short i; TTUInt16 numChannels = x->audioIn1->getNumChannelsAsInt(); TTUInt16 vs = x->audioIn1->getVectorSizeAsInt(); for(i=0; i<numChannels; i++){ x->audioIn1->setVector(i, vs, ins[i]); x->audioIn2->setVector(i, vs, ins[i+numChannels]); } //TOOO: we cast the signal to a float, if Max can handle 64bit attributes, we should change that object_attr_setfloat(x, _sym_position, (t_float)*ins[numChannels*2]); x->xfade->process(*x->audioIn1, *x->audioIn2, *x->audioOut); for(i=0; i<numChannels; i++) x->audioOut->getVectorCopy(i, vs, outs[i]); }
// signal rate fading t_int *fade_perform2(t_int *w) { t_fade *x = (t_fade *)(w[1]); short i, j; TTUInt16 numChannels = x->audioIn1->getNumChannelsAsInt(); TTUInt16 vs = x->audioIn1->getVectorSizeAsInt(); for(i=0; i<numChannels; i++){ j = (i*3) + 1; x->audioIn1->setVector(i, vs, (t_float *)(w[j+1])); x->audioIn2->setVector(i, vs, (t_float *)(w[j+2])); } object_attr_setfloat(x, _sym_position, *((t_float *)(w[(numChannels*3)+2]))); x->xfade->process(*x->audioIn1, *x->audioIn2, *x->audioOut); for(i=0; i<numChannels; i++){ j = (i*3) + 1; x->audioOut->getVector(i, vs, (t_float *)(w[j+3])); } return w + ((numChannels*3)+3); }