2
* hssc~ : Highest Significant Spectral Component, according to amplitude ratio to
3
* Strongest Significant Spectral Component.
4
* Copyright (C) 2005 Edward Kelly <morph_2016@yahoo.co.uk>
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23
static t_class *hssc_tilde_class;
25
typedef struct _hssc_tilde
29
t_float f_maxbin, f_minbin, f_ratio;
30
t_outlet *f_hssc, *f_sssc;
33
t_int *hssc_tilde_perform(t_int *w)
35
t_hssc_tilde *x = (t_hssc_tilde *)(w[1]);
36
t_sample *real = (t_sample *)(w[2]);
37
t_sample *imag = (t_sample *)(w[3]);
40
double vectorr, vectori;
43
x->f_maxbin = x->f_minbin = 0;
44
x->f_ratio = x->f_ratio > 0 ? x->f_ratio : 100;
50
alpha = sqrt((vectorr * vectorr) + (vectori * vectori));
51
x->f_maxbin = alpha > max ? incr : x->f_maxbin;
52
max = alpha > max ? alpha : max;
53
x->f_minbin = alpha > (max / x->f_ratio) ? incr : x->f_minbin;
56
outlet_float(x->f_sssc, x->f_maxbin);
57
outlet_float(x->f_hssc, x->f_minbin);
62
void hssc_tilde_dsp(t_hssc_tilde *x, t_signal **sp)
64
dsp_add(hssc_tilde_perform, 4, x,
65
sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n);
68
void *hssc_tilde_new(t_floatarg f)
70
t_hssc_tilde *x = (t_hssc_tilde *)pd_new(hssc_tilde_class);
74
inlet_new (&x->x_obj, &x->x_obj.ob_pd, &s_signal, &s_signal);
75
floatinlet_new (&x->x_obj, &x->f_ratio);
76
x->f_hssc = outlet_new(&x->x_obj, gensym("float"));
77
x->f_sssc = outlet_new(&x->x_obj, gensym("float"));
83
void hssc_tilde_setup(void)
85
hssc_tilde_class = class_new(gensym("hssc~"),
86
(t_newmethod)hssc_tilde_new,
87
0, sizeof(t_hssc_tilde),
88
CLASS_DEFAULT, A_DEFFLOAT, 0);
90
post("|=================hssc~==================|");
91
post("|=highest significant spectral component=|");
92
post("|======edward=======kelly=======2005=====|");
94
class_addmethod(hssc_tilde_class, (t_method)hssc_tilde_dsp,
97
CLASS_MAINSIGNALIN(hssc_tilde_class, t_hssc_tilde, f);