1 /***************************************************/
2 /*! \class ReedTabl
3 \brief STK reed table class.
4
5 This class implements a simple one breakpoint,
6 non-linear reed function, as described by
7 Smith (1986). This function is based on a
8 memoryless non-linear spring model of the reed
9 (the reed mass is ignored) which saturates when
10 the reed collides with the mouthpiece facing.
11
12 See McIntyre, Schumacher, & Woodhouse (1983),
13 Smith (1986), Hirschman, Cook, Scavone, and
14 others for more information.
15
16 by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
17 */
18 /***************************************************/
19
20 #include "ReedTabl.h"
21
ReedTabl()22 ReedTabl :: ReedTabl()
23 {
24 offSet = (MY_FLOAT) 0.6; // Offset is a bias, related to reed rest position.
25 slope = (MY_FLOAT) -0.8; // Slope corresponds loosely to reed stiffness.
26 }
27
~ReedTabl()28 ReedTabl :: ~ReedTabl()
29 {
30
31 }
32
setOffset(MY_FLOAT aValue)33 void ReedTabl :: setOffset(MY_FLOAT aValue)
34 {
35 offSet = aValue;
36 }
37
setSlope(MY_FLOAT aValue)38 void ReedTabl :: setSlope(MY_FLOAT aValue)
39 {
40 slope = aValue;
41 }
42
lastOut() const43 MY_FLOAT ReedTabl :: lastOut() const
44 {
45 return lastOutput;
46 }
47
tick(MY_FLOAT input)48 MY_FLOAT ReedTabl :: tick(MY_FLOAT input)
49 {
50 // The input is differential pressure across the reed.
51 lastOutput = offSet + (slope * input);
52
53 // If output is > 1, the reed has slammed shut and the
54 // reflection function value saturates at 1.0.
55 if (lastOutput > 1.0) lastOutput = (MY_FLOAT) 1.0;
56
57 // This is nearly impossible in a physical system, but
58 // a reflection function value of -1.0 corresponds to
59 // an open end (and no discontinuity in bore profile).
60 if (lastOutput < -1.0) lastOutput = (MY_FLOAT) -1.0;
61 return lastOutput;
62 }
63
tick(MY_FLOAT * vector,unsigned int vectorSize)64 MY_FLOAT *ReedTabl :: tick(MY_FLOAT *vector, unsigned int vectorSize)
65 {
66 for (unsigned int i=0; i<vectorSize; i++)
67 vector[i] = tick(vector[i]);
68
69 return vector;
70 }
71
72