#include "mess.h" typedef struct { fts_object_t o; int noutlets; } bangbang_t; static void bangbang_bang( fts_object_t *object, int winlet, fts_symbol_t *selector, int ac, const fts_atom_t *at) { bangbang_t *this; int i; this = (bangbang_t *)object; for (i = this->noutlets-1; i >= 0; i--) fts_outlet_send(object, i, fts_s_bang, 0, 0); } static void bangbang_init( fts_object_t *object, int winlet, fts_symbol_t *selector, int ac, const fts_atom_t *at) { bangbang_t *this; this->noutlets = fts_get_long_arg( at, ac, 0, 2); } static fts_status_t bangbang_instantiate(fts_class_t *class, int ac, const fts_atom_t *at) { int i; int noutlets; fts_atom_type_t a; if ((ac >= 1) && fts_is_long( at)) noutlets = fts_get_long(at); else noutlets = 2; fts_class_init(class, sizeof(bangbang_t), 1, noutlets, 0); fts_method_define(class, 0, fts_s_bang, bangbang_bang, 0, 0); a = fts_Long; fts_method_define( class, fts_SystemInlet, fts_s_init, bangbang_init, 1, &a); for (i = 0; i < noutlets; i++) fts_outlet_type_define( class, i, fts_s_bang, 0, 0); return fts_Success; } static int bangbang_equiv( int ac0, const fts_atom_t *at0, int ac1, const fts_atom_t *at1) { if (ac0 == 1 && ac1 == 1 && fts_is_long(at0) && fts_is_long(at1) && fts_get_long(at0) == fts_get_long(at1)) return 1; else return 0; } void bangbang_config(void) { fts_metaclass_create(fts_new_symbol("bangbang"), bangbang_instantiate, bangbang_equiv); }