1 /***************************************************/
2 /*! \class ReedTable
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 - 2005.
17 */
18 /***************************************************/
19 
20 #include "ReedTable.h"
21 
22 using namespace Nyq;
23 
ReedTable()24 ReedTable :: ReedTable()
25 {
26   offset_ = (StkFloat) 0.6;  // Offset is a bias, related to reed rest position.
27   slope_ = (StkFloat) -0.8;  // Slope corresponds loosely to reed stiffness.
28 }
29 
~ReedTable()30 ReedTable :: ~ReedTable()
31 {
32 }
33 
setOffset(StkFloat offset)34 void ReedTable :: setOffset(StkFloat offset)
35 {
36   offset_ = offset;
37 }
38 
setSlope(StkFloat slope)39 void ReedTable :: setSlope(StkFloat slope)
40 {
41   slope_ = slope;
42 }
43 
computeSample(StkFloat input)44 StkFloat ReedTable :: computeSample(StkFloat input)
45 {
46   // The input is differential pressure across the reed.
47   lastOutput_ = offset_ + (slope_ * input);
48 
49   // If output is > 1, the reed has slammed shut and the
50   // reflection function value saturates at 1.0.
51   if (lastOutput_ > 1.0) lastOutput_ = (StkFloat) 1.0;
52 
53   // This is nearly impossible in a physical system, but
54   // a reflection function value of -1.0 corresponds to
55   // an open end (and no discontinuity in bore profile).
56   if (lastOutput_ < -1.0) lastOutput_ = (StkFloat) -1.0;
57   return lastOutput_;
58 }
59 
60