Ejemplo n.º 1
0
/*--------------------------------------------------------------------
 * new
 */
static void *any2bytes_new(MOO_UNUSED t_symbol *sel, int argc, t_atom *argv)
{
    t_any2bytes *x = (t_any2bytes *)pd_new(any2bytes_class);
    int bufsize = ANY2BYTES_DEFAULT_BUFLEN;

    //-- defaults
    x->x_eos      = 0;

    //-- args: 0: bufsize
    if (argc > 0) {
      int initial_bufsize = atom_getintarg(0, argc, argv);
      if (initial_bufsize > 0) { bufsize = initial_bufsize; }
    }
    //-- args: 1: eos
    if (argc > 1) {
      x->x_eos = atom_getfloatarg(1, argc, argv);
    }

    //-- allocate
    pdstring_bytes_init(&x->x_bytes, 0); //-- x_bytes gets clobbered by binbuf_gettext()
    pdstring_atoms_init(&x->x_atoms, bufsize);
    x->x_binbuf = binbuf_new();

    //-- inlets
    x->x_eos_in = floatinlet_new(&x->x_obj, &x->x_eos);

    //-- outlets
    x->x_outlet = outlet_new(&x->x_obj, &s_list);

    //-- report
    A2SDEBUG(post("any2bytes_new(): x=%p, eos=%d, binbuf=%p", x, x->x_eos, x->x_binbuf));

    return (void *)x;
}
Ejemplo n.º 2
0
/*--------------------------------------------------------------------
 * new
 */
static void *bytes2any_new(MOO_UNUSED t_symbol *sel, int argc, t_atom *argv)
{
    t_bytes2any *x = (t_bytes2any *)pd_new(bytes2any_class);
    int bufsize    = BYTES2ANY_DEFAULT_BUFLEN;

    //-- defaults
    x->x_binbuf = binbuf_new();
    x->x_eos    = -1;

    //-- args: 0: bufsize
    if (argc > 0) {
      int initial_bufsize = atom_getintarg(0,argc,argv);
      if (initial_bufsize > 0) bufsize = initial_bufsize;
      x->x_eos = -1;   //-- backwards-compatibility hack: no default eos character if only bufsize is specified
    } 
    //-- args: 1: separator
    if (argc > 1) {
      x->x_eos = atom_getfloatarg(1,argc,argv);
    }

    //-- allocate x_bytes
    pdstring_bytes_init(&x->x_bytes, bufsize);

    //-- inlets
    x->x_eos_in = floatinlet_new(&x->x_obj, &x->x_eos);

    //-- outlets
    x->x_outlet      = outlet_new(&x->x_obj, &s_list);
    x->x_outlet_done = outlet_new(&x->x_obj, &s_bang);

    //-- debug
    S2ADEBUG(post("bytes2any_new: x=%p, binbuf=%p, bytes.alloc=%d", x, x->x_eos, x->x_binbuf, x->x_bytes.b_alloc));

    return (void *)x;
}
Ejemplo n.º 3
0
/*--------------------------------------------------------------------
 * new
 */
static void *array2rawbytes_new(t_symbol *arrayname)
{
    t_array2rawbytes *x = (t_array2rawbytes *)pd_new(array2rawbytes_class);

    //-- init
    x->x_name = arrayname;
    pdstring_bytes_init(&x->x_bytes, 0); //-- gets clobbered by array data
    pdstring_atoms_init(&x->x_atoms, PDSTRING_DEFAULT_BUFLEN);

    //-- outlets
    x->x_outlet = outlet_new(&x->x_obj, &s_list);

    return (void *)x;
}