~ubuntu-branches/ubuntu/breezy/muse/breezy

« back to all changes in this revision

Viewing changes to synti/stklib/OnePole.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Kobras
  • Date: 2004-02-07 15:18:22 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040207151822-es27xxkzbcxkebjm
Tags: 0.6.3-1
* New upstream version.
* Added patches:
  + [10_alsa_init_fix] New, from upstream CVS.
    Initialize direction variable when setting Alsa parameters.
  + [10_canvas_translation_fix] New, from upstream CVS.
    Do not translate tooltips twice in canvas popup.
  + [10_checkbox_fix] New, from upstream CVS.
    Use proper set/test methods on metronome checkboxes.
  + [10_html_doc_cleanup] New.
    Fix links and HTML errors in documentation.
  + [20_allow_system_timer] New.
    The new upstream version fails by default if the real-time clock
    could not be accessed (usually the case when not running suid-root).
    This patch reverts the old behaviour of falling back to the more
    inaccurate system timer.
* Updated patches:
  + [11_PIC_fixes_fixup] Rediffed.
* Removed patches:
  + [20_no_atomic_asm] Merged upstream.
* debian/compat: Splice out debhelper compatibility level from rules file.
* debian/control: Build-depend on latest jack release by default.
  Closes: #228788
* debian/control: Bump standards version.
* debian/control: Use auto-generated debconf dependency via misc:Depends.
* debian/control: Minor tweaks to the long description.
* debian/control: Tighten fluidsynth build dependency to sane version.
* debian/muse.doc-base: New. Register HTML documentation with doc-base.
* debian/templates: Tiny rewording, and typo fix.
* debian/templates, debian/po/*: Switch to po-debconf for translations.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*******************************************/
2
 
/*
3
 
   One Pole Filter Class,
4
 
   by Perry R. Cook, 1995-96.
5
 
   Added methods by Julius Smith, 2000.
6
 
 
7
 
   The parameter gain is an additional
8
 
   gain parameter applied to the filter
9
 
   on top of the normalization that takes
10
 
   place automatically.  So the net max
11
 
   gain through the system equals the
12
 
   value of gain.  sgain is the combina-
13
 
   tion of gain and the normalization
14
 
   parameter, so if you set the poleCoeff
15
 
   to alpha, sgain is always set to
16
 
   gain * (1.0 - fabs(alpha)).
17
 
*/
18
 
/*******************************************/
19
 
 
20
 
#include "OnePole.h"
21
 
 
22
 
OnePole :: OnePole() : Filter()
23
 
{
24
 
  poleCoeff = (MY_FLOAT) 0.9;
25
 
  gain = (MY_FLOAT) 1.0;
26
 
  sgain = (MY_FLOAT) 0.1;
27
 
  outputs = (MY_FLOAT *) malloc(sizeof(MY_FLOAT));
28
 
  outputs[0] = (MY_FLOAT) 0.0;
29
 
  lastOutput = (MY_FLOAT) 0.0;
30
 
}
31
 
 
32
 
OnePole :: OnePole(MY_FLOAT thePole) : Filter()
33
 
{
34
 
  poleCoeff = thePole;
35
 
  gain = (MY_FLOAT) 1.0;
36
 
  sgain = (MY_FLOAT) 1.0 - fabs(thePole);
37
 
  outputs = (MY_FLOAT *) malloc(sizeof(MY_FLOAT));
38
 
  outputs[0] = (MY_FLOAT) 0.0;
39
 
  lastOutput = (MY_FLOAT) 0.0;
40
 
}
41
 
 
42
 
OnePole :: ~OnePole()    
43
 
{
44
 
  free(outputs);
45
 
}
46
 
 
47
 
void OnePole :: clear()
48
 
{
49
 
  outputs[0] = (MY_FLOAT) 0.0;
50
 
  lastOutput = (MY_FLOAT) 0.0;
51
 
}
52
 
 
53
 
void OnePole :: setB0(MY_FLOAT aValue)
54
 
{
55
 
  sgain = aValue;
56
 
}
57
 
 
58
 
void OnePole :: setNum(MY_FLOAT *values)
59
 
{
60
 
  sgain = values[0];
61
 
}
62
 
 
63
 
void OnePole :: setA1(MY_FLOAT aValue)
64
 
{
65
 
  poleCoeff = -aValue;
66
 
}
67
 
 
68
 
void OnePole :: setDen(MY_FLOAT *values)
69
 
{
70
 
  poleCoeff = -values[0];
71
 
}
72
 
 
73
 
void OnePole :: setPole(MY_FLOAT aValue)
74
 
{
75
 
  poleCoeff = aValue;
76
 
  // Normalize gain to 1.0 max
77
 
  if (poleCoeff > (MY_FLOAT) 0.0)
78
 
    sgain = gain * ((MY_FLOAT) 1.0 - poleCoeff);
79
 
  else
80
 
    sgain = gain * ((MY_FLOAT) 1.0 + poleCoeff);
81
 
}
82
 
 
83
 
void OnePole :: setGain(MY_FLOAT aValue)
84
 
{
85
 
  gain = aValue;
86
 
 
87
 
  // Normalize gain to 1.0 max
88
 
  if (poleCoeff > (MY_FLOAT) 0.0)
89
 
    sgain = gain * ((MY_FLOAT) 1.0 - poleCoeff);
90
 
  else
91
 
    sgain = gain * ((MY_FLOAT) 1.0 + poleCoeff);
92
 
}
93
 
 
94
 
// Perform Filter Operation
95
 
MY_FLOAT OnePole :: tick(MY_FLOAT sample)
96
 
{
97
 
  outputs[0] = (sgain * sample) + (poleCoeff * outputs[0]);              
98
 
  lastOutput = outputs[0];
99
 
  return lastOutput;
100
 
}
101