1
0
mirror of https://github.com/cookiengineer/audacity synced 2026-01-12 23:55:50 +01:00

Update Nyquist to v3.09.

This commit is contained in:
Leland Lucius
2015-04-07 22:10:17 -05:00
parent f88b27e6d8
commit 9fb0ce5b82
358 changed files with 26327 additions and 7043 deletions

View File

@@ -0,0 +1,70 @@
/***************************************************/
/*! \class ReedTabl
\brief STK reed table class.
This class implements a simple one breakpoint,
non-linear reed function, as described by
Smith (1986). This function is based on a
memoryless non-linear spring model of the reed
(the reed mass is ignored) which saturates when
the reed collides with the mouthpiece facing.
See McIntyre, Schumacher, & Woodhouse (1983),
Smith (1986), Hirschman, Cook, Scavone, and
others for more information.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
*/
/***************************************************/
#if !defined(__REEDTABL_H)
#define __REEDTABL_H
#include "Stk.h"
class ReedTabl : public Stk
{
public:
//! Default constructor.
ReedTabl();
//! Class destructor.
~ReedTabl();
//! Set the table offset value.
/*!
The table offset roughly corresponds to the size
of the initial reed tip opening (a greater offset
represents a smaller opening).
*/
void setOffset(MY_FLOAT aValue);
//! Set the table slope value.
/*!
The table slope roughly corresponds to the reed
stiffness (a greater slope represents a harder
reed).
*/
void setSlope(MY_FLOAT aValue);
//! Return the last output value.
MY_FLOAT lastOut() const;
//! Return the function value for \e input.
/*!
The function input represents the differential
pressure across the reeds.
*/
MY_FLOAT tick(MY_FLOAT input);
//! Take \e vectorSize inputs and return the corresponding function values in \e vector.
MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize);
protected:
MY_FLOAT offSet;
MY_FLOAT slope;
MY_FLOAT lastOutput;
};
#endif

View File

@@ -36,6 +36,15 @@
#include <sys/types.h>
#include <string.h>
#include <cmath>
#include <cstdio>
/* this is defined in xlisp.h, but it seems a bad idea
* to create an stk dependency on xlisp, or to add a new
* security.h file to share between xlisp.h and stk
*/
extern "C" {
int ok_to_open(const char *filename, const char *mode);
}
using namespace Nyq;
@@ -47,7 +56,7 @@ FileRead :: FileRead()
FileRead :: FileRead( std::string fileName, bool typeRaw )
: fd_(0)
{
open( fileName, typeRaw );
open( fileName, typeRaw );
}
FileRead :: ~FileRead()
@@ -75,7 +84,9 @@ void FileRead :: open( std::string fileName, bool typeRaw )
close();
// Try to open the file.
fd_ = fopen( fileName.c_str(), "rb" );
fd_ = NULL;
if (ok_to_open(fileName.c_str(), "rb"))
fd_ = fopen( fileName.c_str(), "rb" );
if ( !fd_ ) {
errorString_ << "FileRead::open: could not open or find file (" << fileName << ")!";
handleError( StkError::FILE_NOT_FOUND );

View File

@@ -0,0 +1,71 @@
/***************************************************/
/*! \class ReedTabl
\brief STK reed table class.
This class implements a simple one breakpoint,
non-linear reed function, as described by
Smith (1986). This function is based on a
memoryless non-linear spring model of the reed
(the reed mass is ignored) which saturates when
the reed collides with the mouthpiece facing.
See McIntyre, Schumacher, & Woodhouse (1983),
Smith (1986), Hirschman, Cook, Scavone, and
others for more information.
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
*/
/***************************************************/
#include "ReedTabl.h"
ReedTabl :: ReedTabl()
{
offSet = (MY_FLOAT) 0.6; // Offset is a bias, related to reed rest position.
slope = (MY_FLOAT) -0.8; // Slope corresponds loosely to reed stiffness.
}
ReedTabl :: ~ReedTabl()
{
}
void ReedTabl :: setOffset(MY_FLOAT aValue)
{
offSet = aValue;
}
void ReedTabl :: setSlope(MY_FLOAT aValue)
{
slope = aValue;
}
MY_FLOAT ReedTabl :: lastOut() const
{
return lastOutput;
}
MY_FLOAT ReedTabl :: tick(MY_FLOAT input)
{
// The input is differential pressure across the reed.
lastOutput = offSet + (slope * input);
// If output is > 1, the reed has slammed shut and the
// reflection function value saturates at 1.0.
if (lastOutput > 1.0) lastOutput = (MY_FLOAT) 1.0;
// This is nearly impossible in a physical system, but
// a reflection function value of -1.0 corresponds to
// an open end (and no discontinuity in bore profile).
if (lastOutput < -1.0) lastOutput = (MY_FLOAT) -1.0;
return lastOutput;
}
MY_FLOAT *ReedTabl :: tick(MY_FLOAT *vector, unsigned int vectorSize)
{
for (unsigned int i=0; i<vectorSize; i++)
vector[i] = tick(vector[i]);
return vector;
}