Skip to content

Commit

Permalink
update for encoder changes + checker for order
Browse files Browse the repository at this point in the history
  • Loading branch information
pierreguillot committed Sep 24, 2016
1 parent 6e73467 commit bb9ce3c
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 13 deletions.
2 changes: 1 addition & 1 deletion hoa.library
File renamed without changes.
6 changes: 3 additions & 3 deletions sources/2d/hoa.2d.encoder_tilde.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ typedef struct _hoa_2d_encoder
{
t_hoa_processor f_obj;
float f_f;
hoa::Encoder<hoa::Hoa2d, t_sample>::Basic* f_processor;
hoa::EncoderBasic<hoa::Hoa2d, t_sample>* f_processor;
t_sample* f_signals;
} t_hoa_2d_encoder;

Expand All @@ -25,8 +25,8 @@ static void *hoa_2d_encoder_new(t_float f)
t_hoa_2d_encoder *x = (t_hoa_2d_encoder *)pd_new(hoa_2d_encoder_class);
if(x)
{
const size_t order = (size_t)(f) < 1 ? 1 : (size_t)(f);
x->f_processor = new hoa::Encoder<hoa::Hoa2d, t_sample>::Basic(order);
const size_t order = hoa_processor_clip_order(x, (size_t)f);
x->f_processor = new hoa::EncoderBasic<hoa::Hoa2d, t_sample>(order);
x->f_signals = new t_sample[x->f_processor->getNumberOfHarmonics() * 81092];
hoa_processor_init(x, 2, x->f_processor->getNumberOfHarmonics());
}
Expand Down
5 changes: 3 additions & 2 deletions sources/2d/hoa.2d.optim_tilde.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ static void *hoa_2d_optim_new(t_float f, t_symbol* s)
t_hoa_2d_optim *x = (t_hoa_2d_optim *)pd_new(hoa_2d_optim_class);
if(x)
{
const size_t order = (size_t)(f) < 1 ? 1 : (size_t)(f);
post("%f", f);
const size_t order = hoa_processor_clip_order(x, (size_t)f);
if(s == hoa_sym_basic)
{
x->f_processor = new hoa::OptimBasic<hoa::Hoa2d, t_sample>(order);
Expand All @@ -43,7 +44,7 @@ static void *hoa_2d_optim_new(t_float f, t_symbol* s)
else
{
x->f_processor = new hoa::OptimInPhase<hoa::Hoa2d, t_sample>(order);
if(s != hoa_sym_inPhase || s == hoa_sym_inphase)
if(s != hoa_sym_inPhase && s != hoa_sym_inphase)
{
pd_error(x, "hoa.2d.optim: bad argument.");
}
Expand Down
2 changes: 1 addition & 1 deletion sources/2d/hoa.2d.rotate_tilde.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ static void *hoa_2d_rotate_new(t_float f, t_symbol* s)
t_hoa_2d_rotate *x = (t_hoa_2d_rotate *)pd_new(hoa_2d_rotate_class);
if(x)
{
const size_t order = (size_t)(f) < 1 ? 1 : (size_t)(f);
const size_t order = hoa_processor_clip_order(x, (size_t)f);
x->f_processor = new hoa::Rotate<hoa::Hoa2d, t_sample>(order);
x->f_ins = new t_sample[x->f_processor->getNumberOfHarmonics() * 81092];
x->f_outs = new t_sample[x->f_processor->getNumberOfHarmonics() * 81092];
Expand Down
2 changes: 1 addition & 1 deletion sources/2d/hoa.2d.wider_tilde.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ static void *hoa_2d_wider_new(t_float f, t_symbol* s)
t_hoa_2d_wider *x = (t_hoa_2d_wider *)pd_new(hoa_2d_wider_class);
if(x)
{
const size_t order = (size_t)(f) < 1 ? 1 : (size_t)(f);
const size_t order = hoa_processor_clip_order(x, (size_t)f);
x->f_processor = new hoa::Wider<hoa::Hoa2d, t_sample>(order);
x->f_ins = new t_sample[x->f_processor->getNumberOfHarmonics() * 81092];
x->f_outs = new t_sample[x->f_processor->getNumberOfHarmonics() * 81092];
Expand Down
6 changes: 3 additions & 3 deletions sources/3d/hoa.3d.encoder_tilde.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ typedef struct _hoa_3d_encoder
{
t_hoa_processor f_obj;
float f_f;
hoa::Encoder<hoa::Hoa3d, t_sample>::Basic* f_processor;
hoa::EncoderBasic<hoa::Hoa3d, t_sample>* f_processor;
t_sample* f_signals;
} t_hoa_3d_encoder;

Expand All @@ -25,8 +25,8 @@ static void *hoa_3d_encoder_new(t_float f)
t_hoa_3d_encoder *x = (t_hoa_3d_encoder *)pd_new(hoa_3d_encoder_class);
if(x)
{
const size_t order = (size_t)(f) < 1 ? 1 : (size_t)(f);
x->f_processor = new hoa::Encoder<hoa::Hoa3d, t_sample>::Basic(order);
const size_t order = hoa_processor_clip_order(x, (size_t)f);
x->f_processor = new hoa::EncoderBasic<hoa::Hoa3d, t_sample>(order);
x->f_signals = new t_sample[x->f_processor->getNumberOfHarmonics() * 81092];
hoa_processor_init(x, 3, x->f_processor->getNumberOfHarmonics());
}
Expand Down
2 changes: 1 addition & 1 deletion sources/3d/hoa.3d.optim_tilde.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ static void *hoa_3d_optim_new(t_float f, t_symbol* s)
t_hoa_3d_optim *x = (t_hoa_3d_optim *)pd_new(hoa_3d_optim_class);
if(x)
{
const size_t order = (size_t)(f) < 1 ? 1 : (size_t)(f);
const size_t order = hoa_processor_clip_order(x, (size_t)f);
if(s == hoa_sym_basic)
{
x->f_processor = new hoa::OptimBasic<hoa::Hoa3d, t_sample>(order);
Expand Down
2 changes: 1 addition & 1 deletion sources/3d/hoa.3d.wider_tilde.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ static void *hoa_3d_wider_new(t_float f, t_symbol* s)
t_hoa_3d_wider *x = (t_hoa_3d_wider *)pd_new(hoa_3d_wider_class);
if(x)
{
const size_t order = (size_t)(f) < 1 ? 1 : (size_t)(f);
const size_t order = hoa_processor_clip_order(x, (size_t)f);
x->f_processor = new hoa::Wider<hoa::Hoa3d, t_sample>(order);
x->f_ins = new t_sample[x->f_processor->getNumberOfHarmonics() * 81092];
x->f_outs = new t_sample[x->f_processor->getNumberOfHarmonics() * 81092];
Expand Down
10 changes: 10 additions & 0 deletions sources/hoa.pd.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@

#include "hoa.pd.h"

size_t hoa_processor_clip_order(void* obj, size_t order)
{
if(order < 1)
{
pd_error(obj, "hoa.object: bas order of decomposition %i, expect at least 1.", (int)order);
return 1;
}
return order;
}

void hoa_processor_init(void* obj, size_t nins, size_t nouts)
{
size_t i;
Expand Down
1 change: 1 addition & 0 deletions sources/hoa.pd.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ typedef struct _hoa_processor
t_hoa_processor_perfm f_method;
} t_hoa_processor;

size_t hoa_processor_clip_order(void* obj, size_t order);
void hoa_processor_init(void* obj, size_t nins, size_t nouts);
void hoa_processor_clear(void* obj);
void hoa_processor_prepare(void* obj, t_hoa_processor_perfm m, t_signal **sp);
Expand Down

0 comments on commit bb9ce3c

Please sign in to comment.