Skip to content

Commit

Permalink
add hoa.in~ & hoa.out~
Browse files Browse the repository at this point in the history
  • Loading branch information
pierreguillot committed Sep 24, 2016
1 parent bdd57a7 commit e40d2d6
Show file tree
Hide file tree
Showing 5 changed files with 145 additions and 359 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ add_pd_external(hoa.connect hoa.connect ${hoa_pd_path}/common/hoa.connect.c)
add_pd_external(hoa.in hoa.in ${hoa_pd_path}/common/hoa.in.c)
add_pd_external(hoa.out hoa.out ${hoa_pd_path}/common/hoa.out.c)

add_pd_external(hoa.in_tilde hoa.in~ ${hoa_pd_path}/common/hoa.in_tilde.c)
add_pd_external(hoa.out_tilde hoa.out~ ${hoa_pd_path}/common/hoa.out_tilde.c)

# 2D Part
file(GLOB hoa_pd_2d_encoder_tilde_sources ${hoa_pd_sources} ${hoa_pd_path}/2d/hoa.2d.encoder_tilde.cpp)
add_pd_external(hoa.2d.encoder_tilde hoa.2d.encoder~ "${hoa_pd_2d_encoder_tilde_sources}")
Expand Down
67 changes: 67 additions & 0 deletions sources/common/hoa.in_tilde.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
// Copyright (c) 2012-2015 Eliott Paris & Pierre Guillot, CICM, Universite Paris 8.
// For information on usage and redistribution, and for a DISCLAIMER OF ALL
// WARRANTIES, see the file, "LICENSE.txt," in this distribution.
*/

#include "../hoa.pd.h"

static t_class* hoa_in_tilde_class;
static t_symbol* hoa_sym_extra;

static void *hoa_in_tilde_new(t_symbol *s, int argc, t_atom *argv)
{
t_hoa_in_tilde *x = (t_hoa_in_tilde *)pd_new(hoa_in_tilde_class);
if(x)
{
x->f_extra = 0;
x->f_signal = NULL;
outlet_new((t_object *)x, &s_signal);
if(atom_getsymbolarg(0, argc, argv) == hoa_sym_extra)
{
x->f_extra = atom_getfloatarg(1, argc, argv);
if(x->f_extra < 1)
{
pd_error(x, "hoa.in: bad argument, extra index must be at least 1.");
pd_free((t_pd *)x);
return NULL;
}
}
else if(argc && argv)
{
pd_error(x, "hoa.in: bad argument.");
pd_free((t_pd *)x);
return NULL;
}
}

return x;
}

static void hoa_in_tilde_dsp(t_hoa_in_tilde *x, t_signal **sp)
{
if(x->f_signal)
{
dsp_add_copy(x->f_signal, sp[0]->s_vec, sp[0]->s_n);
}
else
{
dsp_add_zero(sp[0]->s_vec, sp[0]->s_n);
}
}

extern void setup_hoa0x2ein_tilde(void)
{
t_class* c = class_new(gensym("hoa.in~"), (t_newmethod)hoa_in_tilde_new, (t_method)NULL,
(size_t)sizeof(t_hoa_in_tilde), CLASS_NOINLET, A_GIMME, 0);

if(c)
{
class_addmethod(c, (t_method)hoa_in_tilde_dsp, gensym("dsp"), A_CANT, 0);
}

hoa_in_tilde_class = c;
hoa_sym_extra = gensym("extra");
}


60 changes: 60 additions & 0 deletions sources/common/hoa.out_tilde.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
// Copyright (c) 2012-2015 Eliott Paris & Pierre Guillot, CICM, Universite Paris 8.
// For information on usage and redistribution, and for a DISCLAIMER OF ALL
// WARRANTIES, see the file, "LICENSE.txt," in this distribution.
*/

#include "../hoa.pd.h"

static t_class* hoa_out_tilde_class;
static t_symbol* hoa_sym_extra;

static void *hoa_out_tilde_new(t_symbol *s, int argc, t_atom *argv)
{
t_hoa_out_tilde *x = (t_hoa_out_tilde *)pd_new(hoa_out_tilde_class);
if(x)
{
x->f_extra = 0;
x->f_signal = NULL;
if(atom_getsymbolarg(0, argc, argv) == hoa_sym_extra)
{
x->f_extra = atom_getfloatarg(1, argc, argv);
if(x->f_extra < 1)
{
pd_error(x, "hoa.in: bad argument, extra index must be at least 1.");
pd_free((t_pd *)x);
return NULL;
}
}
else if(argc && argv)
{
pd_error(x, "hoa.in: bad argument.");
pd_free((t_pd *)x);
return NULL;
}
}

return x;
}

static void hoa_out_tilde_dsp(t_hoa_out_tilde *x, t_signal **sp)
{
if(x->f_signal)
{
dsp_add_plus(sp[0]->s_vec, x->f_signal, x->f_signal, sp[0]->s_n);
}
}

extern void setup_hoa0x2eout_tilde(void)
{
t_class* c = class_new(gensym("hoa.out~"), (t_newmethod)hoa_out_tilde_new, (t_method)NULL,
(size_t)sizeof(t_hoa_out_tilde), CLASS_DEFAULT, A_GIMME, 0);

if(c)
{
class_addmethod(c, (t_method)hoa_out_tilde_dsp, gensym("dsp"), A_CANT, 0);
}

hoa_out_tilde_class = c;
hoa_sym_extra = gensym("extra");
}
Loading

0 comments on commit e40d2d6

Please sign in to comment.