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); }
long tralala_mouseHitNote(t_tll *x, long m) { long i, n = 0; t_symbol *s = NULL; t_symbol *mark = NULL; t_symbol **keys = NULL; long position = TLL_X_TO_POSITION(x->cursor.x - 1.); long pitch = TLL_Y_TO_PITCH(x->cursor.y - 1.); long k = TLL_HIT_NONE; TLL_DATA_LOCK dictionary_deleteentry(x->status, TLL_SYM_ZONE); if (!(dictionary_getkeys(x->current, &n, &keys))) { // long argc; t_atom *argv = NULL; for (i = 0; i < n; i++) { t_symbol *key = (*(keys + i)); if (!(dictionary_getatoms(x->current, key, &argc, &argv))) { if ((atom_getsym(argv) == TLL_SYM_NOTE)) { long p = atom_getlong(argv + 2); long a = atom_getlong(argv + 1); long b = a + atom_getlong(argv + 4); if ((pitch == p) && (position >= a) && (position <= b)) { s = key; break; } } } } dictionary_freekeys(x->current, n, keys); // } if (s) { if (dictionary_hasentry(x->status, s)) { if (m & eShiftKey) { k = TLL_HIT_SWAP; } else { k = TLL_HIT_GRAB; } } else { k = TLL_HIT_PULL; } } if (!(m & eShiftKey) && ((k == TLL_HIT_NONE) || (k == TLL_HIT_PULL))) { dictionary_clear(x->status); } if (k == TLL_HIT_SWAP) { if(!(dictionary_getsym(x->status, TLL_SYM_MARK, &mark)) && (s == mark)) { dictionary_deleteentry(x->status, TLL_SYM_MARK); } dictionary_deleteentry(x->status, s); } else if (k == TLL_HIT_GRAB) { dictionary_appendsym(x->status, TLL_SYM_MARK, s); } else if (k == TLL_HIT_PULL) { dictionary_appendsym(x->status, TLL_SYM_MARK, s); dictionary_appendlong(x->status, s, TLL_SELECTED); } TLL_DATA_UNLOCK return k; }
void tralala_paintCurrent(t_tll *x, t_object *pv) { long zoneStatus = 0; long i, argc, n = 0; t_atom *argv = NULL; t_symbol *mark = NULL; t_symbol **keys = NULL; PIZError err = PIZ_GOOD; char string[TLL_STRING_SIZE] = ""; t_symbol *s[ ] = { TLL_SYM_BPM, TLL_SYM_CHANCE, TLL_SYM_VELOCITY, TLL_SYM_CHANNEL, TLL_SYM_CHORD, TLL_SYM_CELL, TLL_SYM_VALUE, TLL_SYM_SCALE }; pizArrayClear(x->temp[0]); pizArrayClear(x->temp[1]); pizArrayClear(x->temp[2]); TLL_DATA_LOCK dictionary_getlong(x->status, TLL_SYM_ZONE, &zoneStatus); for (i = 0; i < 9; i++) { if (!(dictionary_getatoms(x->current, s[i], &argc, &argv)) && (argc > 1)) { tralala_paintStrncatPanel(string, argc, argv); } } if (!(dictionary_getatoms(x->current, TLL_SYM_MUTE, &argc, &argv)) && (argc > 1) && (atom_gettype(argv + 1) == A_LONG) && (atom_getlong(argv + 1) == 1)) { strncat_zero(string, "•\n", TLL_STRING_SIZE); } else { strncat_zero(string, "\n", TLL_STRING_SIZE); } if (dictionary_hasentry(x->status, TLL_SYM_ZONE)) { if (!(dictionary_getatoms(x->current, TLL_SYM_ZONE, &argc, &argv))) { tralala_paintStrncatZone(string, argc, argv, zoneStatus); } } else if (!(dictionary_getsym(x->status, TLL_SYM_MARK, &mark)) && (!(dictionary_getatoms(x->current, mark, &argc, &argv)))) { tralala_paintStrncatNote(string, argc, argv); } if (!(dictionary_getkeys(x->current, &n, &keys))) { // for (i = 0; i < n; i++) { // long k, j, p, status = 0; t_symbol *key = (*(keys + i)); if (!(dictionary_getatoms(x->current, key, &argc, &argv)) && (atom_getsym(argv) == TLL_SYM_NOTE) && (argc == 6)) { if (k = dictionary_hasentry(x->status, key)) { dictionary_getlong(x->status, key, &status); } if (!k || (status == TLL_LASSO_UNSELECTED)) { p = 0; } else if (key != mark) { p = 1; } else { p = 2; } for (j = 1; j < 5; j++) { pizArrayAppend(x->temp[p], atom_getlong(argv + j)); } } // } dictionary_freekeys(x->current, n, keys); // } err |= (dictionary_getatoms(x->current, TLL_SYM_ZONE, &argc, &argv)) != MAX_ERR_NONE; TLL_DATA_UNLOCK if (!err) { if (!zoneStatus) { tralala_paintCurrentZone(x, pv, argc, argv, zoneStatus); tralala_paintCurrentNote(x, pv); } else { tralala_paintCurrentNote(x, pv); tralala_paintCurrentZone(x, pv, argc, argv, zoneStatus); } if (x->viewText) { tralala_paintCurrentText(x, pv, string); } } }