/****************************************************** * * Adaptive Systems for PD * * copyleft (c) Gerda Strobl, Georg Holzmann * 2005 * * for complaints, suggestions: grh@mur.at * ****************************************************** * * license: GNU General Public License v.2 * ******************************************************/ #include "adaptive.h" #ifdef ADAPTIVE_SINGLE_OBJ // for single externals disable the adaptive object #else // build as library typedef struct _adaptive { t_object x_obj; } t_adaptive; t_class *adaptive_class = NULL; static void adaptive_help(void) { post("\n-----------------------------------------------"); post("adaptive systems for PD"); post("copyleft (c) Gerda Strobl, Georg Holzmann, 2005"); post(""); post("for more info look at the help patches!"); post("-----------------------------------------------\n"); } void *adaptive_new(void) { t_adaptive *x = (t_adaptive *)pd_new(adaptive_class); return (void *)x; } //----------------------------------------------------- // declaration of the setup functions: void lms_tilde_setup(); void lms2_tilde_setup(); void nlms_tilde_setup(); void nlms2_tilde_setup(); void nlms3_tilde_setup(); //-end-of-declaration---------------------------------- void adaptive_setup(void) { //--------------------------------------------------- // call all the setup functions: lms_tilde_setup(); lms2_tilde_setup(); nlms_tilde_setup(); nlms2_tilde_setup(); nlms3_tilde_setup(); //-end----------------------------------------------- post("\nadaptive: 2005 by Gerda Strobl and Georg Holzmann"); adaptive_class = class_new(gensym("adaptive"), adaptive_new, 0, sizeof(t_adaptive), 0, 0); class_addmethod(adaptive_class, (t_method)adaptive_help, gensym("help"), 0); } #endif // library /* ---------------------- helpers ----------------------- */ void adaptation_write(const char *filename, t_int N, t_float mu, t_float *c) { FILE *f=0; int i; // open file f = sys_fopen(filename, "w"); if(!f) { post("adaptive, save: error open file"); return; } // write little header, number of coefficients and mu fprintf(f, "adaptivePD\n"); fprintf(f, "size: %d\n", N); fprintf(f, "mu: %.30f\n", mu); // write coefficients for(i=0; i