Changeset a54502c


Ignore:
Timestamp:
Sep 29, 2009, 8:08:10 PM (15 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
Children:
899dfd3
Parents:
6481c0c
Message:

src/temporal/filter.{c,h}: indent, update copyright and license

Location:
src/temporal
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/temporal/filter.c

    r6481c0c ra54502c  
    11/*
    2    Copyright (C) 2003 Paul Brossier
     2  Copyright (C) 2003-2009 Paul Brossier <piem@aubio.org>
    33
    4    This program is free software; you can redistribute it and/or modify
    5    it under the terms of the GNU General Public License as published by
    6    the Free Software Foundation; either version 2 of the License, or
    7    (at your option) any later version.
     4  This file is part of aubio.
    85
    9    This program is distributed in the hope that it will be useful,
    10    but WITHOUT ANY WARRANTY; without even the implied warranty of
    11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    12    GNU General Public License for more details.
     6  aubio 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 3 of the License, or
     9  (at your option) any later version.
    1310
    14    You should have received a copy of the GNU General Public License
    15    along with this program; if not, write to the Free Software
    16    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
     11  aubio 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
     16  You should have received a copy of the GNU General Public License
     17  along with aubio.  If not, see <http://www.gnu.org/licenses/>.
    1718
    1819*/
     
    2829#include "temporal/filter.h"
    2930
    30 struct _aubio_filter_t {
     31struct _aubio_filter_t
     32{
    3133  uint_t order;
    3234  uint_t samplerate;
    33   lvec_t * a;
    34   lvec_t * b;
    35   lvec_t * y;
    36   lvec_t * x;
     35  lvec_t *a;
     36  lvec_t *b;
     37  lvec_t *y;
     38  lvec_t *x;
    3739};
    3840
    39 void aubio_filter_do_outplace(aubio_filter_t * f, fvec_t * in, fvec_t * out) {
    40   fvec_copy(in, out);
     41void
     42aubio_filter_do_outplace (aubio_filter_t * f, fvec_t * in, fvec_t * out)
     43{
     44  fvec_copy (in, out);
    4145  aubio_filter_do (f, out);
    4246}
    4347
    44 void aubio_filter_do(aubio_filter_t * f, fvec_t * in) {
    45   uint_t i,j,l, order = f->order;
     48void
     49aubio_filter_do (aubio_filter_t * f, fvec_t * in)
     50{
     51  uint_t i, j, l, order = f->order;
    4652  lsmp_t *x;
    4753  lsmp_t *y;
     
    5460    for (j = 0; j < in->length; j++) {
    5561      /* new input */
    56       x[0] = KILL_DENORMAL(in->data[i][j]);
     62      x[0] = KILL_DENORMAL (in->data[i][j]);
    5763      y[0] = b[0] * x[0];
    58       for (l=1;l<order; l++) {
     64      for (l = 1; l < order; l++) {
    5965        y[0] += b[l] * x[l];
    6066        y[0] -= a[l] * y[l];
     
    6369      in->data[i][j] = y[0];
    6470      /* store for next sample */
    65       for (l=order-1; l>0; l--){
    66         x[l] = x[l-1];
    67         y[l] = y[l-1];
     71      for (l = order - 1; l > 0; l--) {
     72        x[l] = x[l - 1];
     73        y[l] = y[l - 1];
    6874      }
    6975    }
     
    108114}
    109115
    110 lvec_t * aubio_filter_get_feedback ( aubio_filter_t *f ) {
     116lvec_t *
     117aubio_filter_get_feedback (aubio_filter_t * f)
     118{
    111119  return f->a;
    112120}
    113121
    114 lvec_t * aubio_filter_get_feedforward ( aubio_filter_t *f ) {
     122lvec_t *
     123aubio_filter_get_feedforward (aubio_filter_t * f)
     124{
    115125  return f->b;
    116126}
    117127
    118 uint_t aubio_filter_get_order ( aubio_filter_t *f ) {
     128uint_t
     129aubio_filter_get_order (aubio_filter_t * f)
     130{
    119131  return f->order;
    120132}
    121133
    122 uint_t aubio_filter_get_samplerate ( aubio_filter_t *f ) {
     134uint_t
     135aubio_filter_get_samplerate (aubio_filter_t * f)
     136{
    123137  return f->samplerate;
    124138}
    125139
    126 aubio_filter_t * new_aubio_filter(uint_t samplerate,
    127     uint_t order, uint_t channels) {
    128   aubio_filter_t * f = AUBIO_NEW(aubio_filter_t);
    129   f->x = new_lvec(order, channels);
    130   f->y = new_lvec(order, channels);
    131   f->a = new_lvec(order, 1);
    132   f->b = new_lvec(order, 1);
    133   f->samplerate = samplerate;
     140aubio_filter_t *
     141new_aubio_filter (uint_t samplerate, uint_t order, uint_t channels)
     142{
     143  aubio_filter_t *f = AUBIO_NEW (aubio_filter_t);
     144  f->x = new_lvec (order, channels);
     145  f->y = new_lvec (order, channels);
     146  f->a = new_lvec (order, 1);
     147  f->b = new_lvec (order, 1);
     148  f->samplerate = samplerate;
    134149  f->order = order;
    135150  /* set default to identity */
     
    138153}
    139154
    140 void del_aubio_filter(aubio_filter_t * f) {
    141   del_lvec(f->a);
    142   del_lvec(f->b);
    143   del_lvec(f->x);
    144   del_lvec(f->y);
    145   AUBIO_FREE(f);
     155void
     156del_aubio_filter (aubio_filter_t * f)
     157{
     158  del_lvec (f->a);
     159  del_lvec (f->b);
     160  del_lvec (f->x);
     161  del_lvec (f->y);
     162  AUBIO_FREE (f);
    146163  return;
    147164}
  • src/temporal/filter.h

    r6481c0c ra54502c  
    11/*
    2          Copyright (C) 2003 Paul Brossier
     2  Copyright (C) 2003-2009 Paul Brossier <piem@aubio.org>
    33
    4          This program is free software; you can redistribute it and/or modify
    5          it under the terms of the GNU General Public License as published by
    6          the Free Software Foundation; either version 2 of the License, or
    7          (at your option) any later version.
     4  This file is part of aubio.
    85
    9          This program is distributed in the hope that it will be useful,
    10          but WITHOUT ANY WARRANTY; without even the implied warranty of
    11          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    12          GNU General Public License for more details.
     6  aubio 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 3 of the License, or
     9  (at your option) any later version.
    1310
    14          You should have received a copy of the GNU General Public License
    15          along with this program; if not, write to the Free Software
    16          Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
     11  aubio 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
     16  You should have received a copy of the GNU General Public License
     17  along with aubio.  If not, see <http://www.gnu.org/licenses/>.
    1718
    1819*/
     
    7374
    7475*/
    75 void aubio_filter_do(aubio_filter_t * f, fvec_t * in);
     76void aubio_filter_do (aubio_filter_t * f, fvec_t * in);
    7677
    7778/** filter input vector (out-of-place)
     
    8283
    8384*/
    84 void aubio_filter_do_outplace(aubio_filter_t * f, fvec_t * in, fvec_t * out);
     85void aubio_filter_do_outplace (aubio_filter_t * f, fvec_t * in, fvec_t * out);
    8586
    8687/** filter input vector forward and backward
     
    9192
    9293*/
    93 void aubio_filter_do_filtfilt(aubio_filter_t * f, fvec_t * in, fvec_t * tmp);
     94void aubio_filter_do_filtfilt (aubio_filter_t * f, fvec_t * in, fvec_t * tmp);
    9495
    9596/** returns a pointer to feedback coefficients \f$ a_i \f$
     
    100101
    101102*/
    102 lvec_t * aubio_filter_get_feedback ( aubio_filter_t *f );
     103lvec_t *aubio_filter_get_feedback (aubio_filter_t * f);
    103104
    104105/** returns a pointer to feedforward coefficients \f$ b_i \f$
     
    109110
    110111*/
    111 lvec_t * aubio_filter_get_feedforward ( aubio_filter_t *f );
     112lvec_t *aubio_filter_get_feedforward (aubio_filter_t * f);
    112113
    113114/** get order of the filter
     
    118119
    119120*/
    120 uint_t aubio_filter_get_order ( aubio_filter_t *f );
     121uint_t aubio_filter_get_order (aubio_filter_t * f);
    121122
    122123/** get sampling rate of the filter
     
    127128
    128129*/
    129 uint_t aubio_filter_get_samplerate ( aubio_filter_t *f );
     130uint_t aubio_filter_get_samplerate (aubio_filter_t * f);
    130131
    131132/** create new filter object
     
    141142
    142143*/
    143 aubio_filter_t * new_aubio_filter(uint_t samplerate, uint_t order, uint_t channels);
     144aubio_filter_t *new_aubio_filter (uint_t samplerate, uint_t order,
     145    uint_t channels);
    144146
    145147/** delete a filter object
     
    148150
    149151*/
    150 void del_aubio_filter(aubio_filter_t * f);
     152void del_aubio_filter (aubio_filter_t * f);
    151153
    152154#ifdef __cplusplus
Note: See TracChangeset for help on using the changeset viewer.