コード例 #1
0
void *hoa_decoder_new(t_symbol *s, long argc, t_atom *argv)
{
	t_hoa_decoder *x = NULL;
    t_dictionary *d = NULL;
    t_dictionary *attr = NULL;
    t_atom_long channels;
    t_symbol*   mode;
	int	order = 1;
    x = (t_hoa_decoder *)object_alloc(hoa_decoder_class);
	if (x)
	{
		if(atom_gettype(argv) == A_LONG)
			order = atom_getlong(argv);
		if(order < 1)
            order = 1;
    
        x->f_decoder    = new Hoa2D::DecoderMulti(order);
        x->f_decoder->setSampleRate(sys_getsr());
        x->f_decoder->setVectorSize(sys_getblksize());
        
        d = (t_dictionary *)gensym("#D")->s_thing;
        if(d && dictionary_getdictionary(d, gensym("saved_object_attributes"), (t_object **)&attr) == MAX_ERR_NONE)
        {
            if(dictionary_getsym(attr, gensym("mode"), &mode) == MAX_ERR_NONE)
            {
                if(mode == gensym("irregular"))
                    x->f_decoder->setDecodingMode(Hoa2D::DecoderMulti::Irregular);
                else if(mode == gensym("binaural"))
                    x->f_decoder->setDecodingMode(Hoa2D::DecoderMulti::Binaural);
                else
                    x->f_decoder->setDecodingMode(Hoa2D::DecoderMulti::Regular);
            }
            if(dictionary_getlong(attr, gensym("channels"), &channels) == MAX_ERR_NONE)
                x->f_decoder->setNumberOfChannels(channels);
            dictionary_getlong(attr, gensym("autoconnect"), &x->f_send_config);
        }
       
		dsp_setup((t_pxobject *)x, x->f_decoder->getNumberOfHarmonics());
        for(int i = 0; i < x->f_decoder->getNumberOfChannels(); i++)
            outlet_new(x, "signal");
        
        x->f_ob.z_misc = Z_NO_INPLACE;
        x->f_ins = new double[x->f_decoder->getNumberOfHarmonics() * SYS_MAXBLKSIZE];
        x->f_outs= new double[MAX_CHANNELS * SYS_MAXBLKSIZE];
        
        if(d)
            attr_dictionary_process(x, d);
	}

	return (x);
}
コード例 #2
0
void *hoa_vector_new(t_symbol *s, long argc, t_atom *argv)
{
	// @arg 0 @name number-of-channels @optional 0 @type int @digest The number of channels
	// @description First argument sets the number of channels.
	
	t_hoa_vector *x = NULL;
    t_dictionary *d = NULL;
    t_dictionary *attr = NULL;
    t_atom_long nchannels = 0;
    x = (t_hoa_vector *)object_alloc(hoa_vector_class);
    
	if(x)
	{
        d = (t_dictionary *)gensym("#D")->s_thing;
        if(d && dictionary_getdictionary(d, gensym("saved_object_attributes"), (t_object **)&attr) == MAX_ERR_NONE)
        {
            if(dictionary_getlong(attr, gensym("channels"), &nchannels) != MAX_ERR_NONE)
                nchannels = 4;
        }
        else
            nchannels = 4;
       
        if(nchannels < 1)
            nchannels = 1;
        
		x->f_vector = new Hoa2D::Vector(nchannels);
		
		dsp_setup((t_pxobject *)x, x->f_vector->getNumberOfChannels());
		for (int i = 0; i < 4; i++)
			outlet_new(x, "signal");
        
		x->f_ins = new double[x->f_vector->getNumberOfChannels() * SYS_MAXBLKSIZE];
        x->f_outs = new double[4 * SYS_MAXBLKSIZE];
        
        if(d)
            attr_dictionary_process(x, d);
	}

	return (x);
}