Version 4.3.0

This commit is contained in:
Gary Scavone
2009-03-24 23:02:15 -04:00
committed by Stephen Sinclair
parent 2cbce2d8bd
commit 27d9b79dc7
271 changed files with 22219 additions and 8834 deletions

View File

@@ -11,7 +11,7 @@
envelope value reaches 0.0 in the
ADSR::RELEASE state.
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
@@ -75,6 +75,7 @@ class ADSR : public Envelope
protected:
StkFloat computeSample( void );
void sampleRateChanged( StkFloat newRate, StkFloat oldRate );
StkFloat attackRate_;
StkFloat decayRate_;

View File

@@ -19,7 +19,7 @@
to \e keyOn and \e keyOff messages by ramping to
1.0 on keyOn and to 0.0 on keyOff.
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
@@ -64,6 +64,7 @@ class Asymp : public Envelope
protected:
StkFloat computeSample( void );
void sampleRateChanged( StkFloat newRate, StkFloat oldRate );
StkFloat factor_;
StkFloat constant_;

View File

@@ -28,7 +28,7 @@
type who should worry about this (making
money) worry away.
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/

View File

@@ -8,7 +8,7 @@
frequency response while maintaining a constant
filter gain.
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
@@ -27,6 +27,9 @@ public:
//! Class destructor.
virtual ~BiQuad();
//! A function to enable/disable the automatic updating of class data when the STK sample rate changes.
void ignoreSampleRateChange( bool ignore = true ) { ignoreSampleRateChange_ = ignore; };
//! Clears all internal states of the filter.
void clear(void);
@@ -107,6 +110,30 @@ public:
// This function must be implemented in all subclasses. It is used
// to get around a C++ problem with overloaded virtual functions.
virtual StkFloat computeSample( StkFloat input );
virtual void sampleRateChanged( StkFloat newRate, StkFloat oldRate );
};
inline StkFloat BiQuad :: computeSample( StkFloat input )
{
inputs_[0] = gain_ * input;
outputs_[0] = b_[0] * inputs_[0] + b_[1] * inputs_[1] + b_[2] * inputs_[2];
outputs_[0] -= a_[2] * outputs_[2] + a_[1] * outputs_[1];
inputs_[2] = inputs_[1];
inputs_[1] = inputs_[0];
outputs_[2] = outputs_[1];
outputs_[1] = outputs_[0];
return outputs_[0];
}
inline StkFloat BiQuad :: tick( StkFloat input )
{
return this->computeSample( input );
}
inline StkFrames& BiQuad :: tick( StkFrames& frames, unsigned int channel )
{
return Filter::tick( frames, channel );
}
#endif

View File

@@ -8,8 +8,8 @@
The algorithm implemented in this class uses a SincM function with
an even M value to achieve a bipolar bandlimited impulse train.
This signal is then integrated to achieve a square waveform. The
integration process has an associated DC offset but that is
subtracted off the output signal.
integration process has an associated DC offset so a DC blocking
filter is applied at the output.
The user can specify both the fundamental frequency of the
waveform and the number of harmonics contained in the resulting
@@ -19,10 +19,14 @@
to half the sample rate. Note, however, that this setting may
produce aliasing in the signal when the frequency is changing (no
automatic modification of the number of harmonics is performed by
the setFrequency() function).
the setFrequency() function). Also note that the harmonics of a
square wave fall at odd integer multiples of the fundamental, so
aliasing will happen with a lower fundamental than with the other
Blit waveforms. This class is not guaranteed to be well behaved
in the presence of significant aliasing.
Based on initial code of Robin Davies, 2005.
Modified algorithm code by Gary Scavone, 2005.
Modified algorithm code by Gary Scavone, 2005 - 2006.
*/
/***************************************************/
@@ -83,7 +87,9 @@ class BlitSquare: public Generator
StkFloat rate_;
StkFloat phase_;
StkFloat p_;
StkFloat offset_;
StkFloat a_;
StkFloat lastBlitOutput_;
StkFloat dcbState_;
};
#endif

View File

@@ -12,7 +12,7 @@
- Vibrato Gain = 1
- Volume = 128
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/

View File

@@ -29,7 +29,7 @@
- Register State = 1
- Breath Pressure = 128
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/

View File

@@ -5,7 +5,7 @@
This class implements a simple bowed string
non-linear function, as described by Smith (1986).
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/

View File

@@ -17,7 +17,7 @@
- Vibrato Gain = 1
- Volume = 128
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/

View File

@@ -16,7 +16,7 @@
- Vibrato Gain = 1
- Volume = 128
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/

View File

@@ -4,7 +4,7 @@
This class implements a chorus effect.
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/

View File

@@ -18,7 +18,7 @@
- Vibrato Gain = 1
- Breath Pressure = 128
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/

View File

@@ -14,7 +14,7 @@
used in fixed delay-length applications, such
as for reverberation.
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/

View File

@@ -15,7 +15,7 @@
minimum delay possible in this implementation is limited to a
value of 0.5.
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/

View File

@@ -18,7 +18,7 @@
order Lagrange interpolators can typically
improve (minimize) this attenuation characteristic.
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/

View File

@@ -11,7 +11,7 @@
of simultaneous voices) via a #define in the
Drummer.h.
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/

View File

@@ -4,7 +4,7 @@
This class implements an echo effect.
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/

View File

@@ -5,7 +5,7 @@
This class provides common functionality for
STK effects subclasses.
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/

View File

@@ -9,7 +9,7 @@
\e keyOff messages, ramping to 1.0 on
keyOn and to 0.0 on keyOff.
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
@@ -58,6 +58,7 @@ class Envelope : public Generator
protected:
virtual StkFloat computeSample( void );
virtual void sampleRateChanged( StkFloat newRate, StkFloat oldRate );
StkFloat value_;
StkFloat target_;

View File

@@ -19,7 +19,7 @@
type who should worry about this (making
money) worry away.
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/

View File

@@ -26,7 +26,7 @@
type who should worry about this (making
money) worry away.
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/

View File

@@ -25,7 +25,7 @@
filling a matrix row. The sample rate for
MAT-files is assumed to be 44100 Hz.
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/

View File

@@ -17,7 +17,7 @@
type, the data type will automatically be modified. Compressed
data types are not supported.
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/

View File

@@ -27,7 +27,7 @@
See the FileRead class for a description of the supported audio
file formats.
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
@@ -126,6 +126,7 @@ public:
protected:
virtual void computeFrame( void );
virtual void sampleRateChanged( StkFloat newRate, StkFloat oldRate );
FileRead file_;
bool finished_;

View File

@@ -17,7 +17,7 @@
Currently, FileWvOut is non-interpolating and the output rate is
always Stk::sampleRate().
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/

View File

@@ -23,7 +23,7 @@
results in one extra multiply per computed sample,
but allows easy control of the overall filter gain.
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/

View File

@@ -18,7 +18,7 @@
- Vibrato Gain = 1
- Breath Pressure = 128
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/

View File

@@ -8,7 +8,7 @@
It provides methods for controlling the sweep
rate and target frequency.
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/

View File

@@ -6,7 +6,7 @@
implement tables or other types of input to output function
mappings.
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/

View File

@@ -5,7 +5,7 @@
This class provides common functionality for
STK unit generator sample-source subclasses.
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/

View File

@@ -76,9 +76,11 @@ class Granulate: public Generator
trapezoidal window. In addition, each grain can have a time delay
of length \e delay and a grain pointer increment of length \e
offset, which can be negative, before the next ramp onset (in
milliseconds). The actual values calculated for each grain will
be randomized by a factor set using the setRandomFactor()
function.
milliseconds). The \e offset parameter controls grain pointer
jumps between enveloped grain segments, while the \e delay
parameter causes grain calculations to pause between grains. The
actual values calculated for each grain will be randomized by a
factor set using the setRandomFactor() function.
*/
void setGrainParameters( unsigned int duration = 30, unsigned int rampPercent = 50,
int offset = 0, unsigned int delay = 0 );

View File

@@ -24,7 +24,7 @@
type who should worry about this (making
money) worry away.
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/

View File

@@ -20,7 +20,7 @@
data type for the incoming stream is signed 16-bit integers,
though any of the defined StkFormats are permissible.
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/

View File

@@ -16,7 +16,7 @@
data type is signed 16-bit integers but any of the defined
StkFormats are permissible.
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/

View File

@@ -5,7 +5,7 @@
This class provides a common interface for
all STK instruments.
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/

View File

@@ -10,7 +10,7 @@
filters, and two decorrelation delay lines in
parallel at the output.
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/

View File

@@ -9,7 +9,7 @@
Consult Fletcher and Rossing, Karjalainen,
Cook, and others for more information.
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/

View File

@@ -23,7 +23,7 @@
- String Detuning = 1
- Microphone Position = 128
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/

View File

@@ -28,7 +28,7 @@
This class is primarily for use in STK example programs but it is
generic enough to work in many other contexts.
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/

View File

@@ -7,7 +7,7 @@
(non-sweeping BiQuad filters), where N is set
during instantiation.
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/

View File

@@ -24,7 +24,7 @@
- Two Fixed = 7
- Clump = 8
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/

View File

@@ -6,7 +6,7 @@
modulations to give a nice, natural human
modulation function.
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/

View File

@@ -14,7 +14,7 @@
- Vibrato Gain = 1
- Gain = 128
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/

View File

@@ -7,7 +7,7 @@
systems, the pthread library is used. Under
Windows, critical sections are used.
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/

View File

@@ -12,7 +12,7 @@
filters in parallel with corresponding right
and left outputs.
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/

View File

@@ -6,7 +6,7 @@
C rand() function. The quality of the rand()
function varies from one OS to another.
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/

View File

@@ -8,7 +8,7 @@
the real axis of the z-plane while maintaining
a constant peak filter gain.
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/

View File

@@ -8,7 +8,7 @@
along the real axis of the z-plane while
maintaining a constant filter gain.
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/

View File

@@ -10,7 +10,7 @@
two series allpass units and two parallel comb
filters.
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/

View File

@@ -22,7 +22,7 @@
type who should worry about this (making
money) worry away.
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/

View File

@@ -6,7 +6,7 @@
set of 32 static phoneme formant parameters
and provide access to those values.
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/

View File

@@ -5,7 +5,7 @@
This class implements a simple pitch shifter
using delay lines.
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/

View File

@@ -14,7 +14,7 @@
use possibly subject to patents held by
Stanford University, Yamaha, and others.
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/

View File

@@ -13,7 +13,7 @@
Stanford, bearing the names of Karplus and/or
Strong.
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/

View File

@@ -8,7 +8,7 @@
filter with a given coefficient. Another
method is provided to create a DC blocking filter.
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/

View File

@@ -13,7 +13,7 @@
Smith (1986), Hirschman, Cook, Scavone, and
others for more information.
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/

View File

@@ -13,7 +13,7 @@
- Zero Radii = 1
- Envelope Gain = 128
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/

View File

@@ -26,7 +26,7 @@
type who should worry about this (making
money) worry away.
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/

File diff suppressed because it is too large Load Diff

View File

@@ -1,124 +0,0 @@
/***************************************************/
/*! \class RtDuplex
\brief STK realtime audio (blocking) input/output class.
This class provides a simplified interface to
RtAudio for realtime audio input/output. It
may also be possible to achieve duplex
operation using separate RtWvIn and RtWvOut
classes, but this class ensures better
input/output synchronization.
Because this class makes use of RtAudio's
blocking input/output routines, its
performance is less robust on systems where
the audio API is callback-based (Macintosh
CoreAudio and Windows ASIO).
RtDuplex supports multi-channel data in
interleaved format. It is important to
distinguish the tick() methods, which output
single samples to all channels in a sample
frame and return samples produced by averaging
across sample frames, from the tickFrame()
methods, which take/return pointers to
multi-channel sample frames.
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
*/
/***************************************************/
#ifndef STK_RTDUPLEX_H
#define STK_RTDUPLEX_H
#include "Stk.h"
#include "RtAudio.h"
class RtDuplex : public Stk
{
public:
//! Default constructor.
/*!
The \e device argument is passed to RtAudio during
instantiation. The default value (zero) will select the default
device on your system or the first device found meeting the
specified parameters. On systems with multiple
soundcards/devices, values greater than zero can be specified in
accordance with the order that the devices are enumerated by the
underlying audio API. The default buffer size of RT_BUFFER_SIZE
is defined in Stk.h. An StkError will be thrown if an error
occurs duing instantiation.
*/
RtDuplex(int nChannels = 1, StkFloat sampleRate = Stk::sampleRate(), int device = 0, int bufferFrames = RT_BUFFER_SIZE, int nBuffers = 2);
//! Class destructor.
~RtDuplex();
//! Start the audio input/output stream.
/*!
The stream is started automatically, if necessary, when a tick() or tickFrame method is called.
*/
void start(void);
//! Stop the audio input/output stream.
/*!
It may be necessary to use this method to avoid audio overflow/underflow problems if you wish to temporarily stop the audio stream.
*/
void stop(void);
//! Return the average across the last output sample frame.
StkFloat lastOut(void) const;
//! Output a single sample to all channels in a sample frame and return the average across one new input sample frame of data.
/*!
An StkError will be thrown if an error occurs during input/output.
*/
StkFloat tick(const StkFloat sample);
//! Output each sample in \e vector to all channels per frame and return averaged input sample frames of new data in \e vector.
/*!
An StkError will be thrown if an error occurs during input/output.
*/
StkFloat *tick(StkFloat *vector, unsigned int vectorSize);
//! Output a channel of the StkFrames object to all channels and replace with averaged sample frames of input.
/*!
The \c channel argument should be one or greater (the first
channel is specified by 1). An StkError will be thrown if an
error occurs during input/outpu or the \c channel argument is zero
or it is greater than the number of channels in the StkFrames
object.
*/
StkFrames& tick( StkFrames& frames, unsigned int channel = 1 );
//! Return a pointer to the last output sample frame.
const StkFloat *lastFrame(void) const;
//! Output sample \e frames from \e frameVector and return new input frames in \e frameVector.
/*!
An StkError will be thrown if an error occurs during input/output.
*/
StkFloat *tickFrame(StkFloat *frameVector, unsigned int frames = 1);
//! Output the StkFrames data and replace with new input frames.
/*!
An StkError will be thrown if an error occurs during
input/output or if there is an incompatability between the number
of channels in the RtDuplex object and that in the StkFrames
object.
*/
StkFrames& tickFrame( StkFrames& frames );
protected:
RtAudio *audio_;
StkFloat *data_;
StkFloat *lastOutput_;
int bufferSize_;
bool stopped_;
long counter_;
unsigned int channels_;
};
#endif

View File

@@ -12,12 +12,13 @@
#ifndef RTERROR_H
#define RTERROR_H
#include <exception>
#include <iostream>
#include <string>
class RtError
class RtError : public std::exception
{
public:
public:
//! Defined RtError types.
enum Type {
WARNING, /*!< A non-critical error. */
@@ -25,36 +26,35 @@ public:
UNSPECIFIED, /*!< The default, unspecified error type. */
NO_DEVICES_FOUND, /*!< No devices found on system. */
INVALID_DEVICE, /*!< An invalid device ID was specified. */
INVALID_STREAM, /*!< An invalid stream ID was specified. */
MEMORY_ERROR, /*!< An error occured during memory allocation. */
INVALID_PARAMETER, /*!< An invalid parameter was specified to a function. */
INVALID_USE, /*!< The function was called incorrectly. */
DRIVER_ERROR, /*!< A system driver error occured. */
SYSTEM_ERROR, /*!< A system error occured. */
THREAD_ERROR /*!< A thread error occured. */
};
protected:
std::string message_;
Type type_;
public:
//! The constructor.
RtError(const std::string& message, Type type = RtError::UNSPECIFIED) : message_(message), type_(type) {}
RtError( const std::string& message, Type type = RtError::UNSPECIFIED ) throw() : message_(message), type_(type) {}
//! The destructor.
virtual ~RtError(void) {};
virtual ~RtError( void ) throw() {}
//! Prints thrown error message to stderr.
virtual void printMessage(void) { std::cerr << '\n' << message_ << "\n\n"; }
virtual void printMessage( void ) throw() { std::cerr << '\n' << message_ << "\n\n"; }
//! Returns the thrown error message type.
virtual const Type& getType(void) { return type_; }
virtual const Type& getType(void) throw() { return type_; }
//! Returns the thrown error message string.
virtual const std::string& getMessage(void) { return message_; }
virtual const std::string& getMessage(void) throw() { return message_; }
//! Returns the thrown error message as a C string.
virtual const char *getMessageString(void) { return message_.c_str(); }
//! Returns the thrown error message as a c-style string.
virtual const char* what( void ) const throw() { return message_.c_str(); }
protected:
std::string message_;
Type type_;
};
#endif

View File

@@ -35,7 +35,7 @@
*/
/**********************************************************************/
// RtMidi: Version 1.0.4, 14 October 2005
// RtMidi: Version 1.0.5, in development
#ifndef RTMIDI_H
#define RTMIDI_H
@@ -51,7 +51,7 @@ class RtMidi
virtual void openPort( unsigned int portNumber = 0 ) = 0;
//! Pure virtual openVirtualPort() function.
virtual void openVirtualPort() = 0;
virtual void openVirtualPort( const std::string portName = std::string( "RtMidi" ) ) = 0;
//! Pure virtual getPortCount() function.
virtual unsigned int getPortCount() = 0;
@@ -128,7 +128,7 @@ class RtMidiIn : public RtMidi
is currently only supported by the Macintosh OS-X and Linux ALSA
APIs (the function does nothing for the other APIs).
*/
void openVirtualPort();
void openVirtualPort( const std::string portName = std::string( "RtMidi Input" ) );
//! Set a callback function to be invoked for incoming MIDI messages.
/*!
@@ -270,7 +270,7 @@ class RtMidiOut : public RtMidi
exception is thrown if an error occurs while attempting to create
the virtual port.
*/
void openVirtualPort();
void openVirtualPort( const std::string portName = std::string( "RtMidi Output" ) );
//! Return the number of available MIDI output ports.
unsigned int getPortCount();
@@ -279,7 +279,7 @@ class RtMidiOut : public RtMidi
/*!
An exception is thrown if an invalid port specifier is provided.
*/
std::string getPortName( unsigned int portNumber );
std::string getPortName( unsigned int portNumber = 0 );
//! Immediately send a single message out an open MIDI output port.
/*!

View File

@@ -3,18 +3,18 @@
\brief STK realtime audio (blocking) input class.
This class provides a simplified interface to RtAudio for realtime
audio input. It is a subclass of WvIn. Because this class makes
use of RtAudio's blocking output routines, its performance is less
robust on systems where the audio API is callback-based (Macintosh
CoreAudio and Windows ASIO).
audio input. It is a subclass of WvIn. This class makes use of
RtAudio's callback functionality by creating a large ring-buffer
from which data is read. This class should not be used when
low-latency is desired.
RtWvIn supports multi-channel data in interleaved format. It is
important to distinguish the tick() methods, which return samples
produced by averaging across sample frames, from the tickFrame()
methods, which return references or pointers to multi-channel
sample frames.
RtWvIn supports multi-channel data in both interleaved and
non-interleaved formats. It is important to distinguish the
tick() methods, which return samples produced by averaging across
sample frames, from the tickFrame() methods, which return
references or pointers to multi-channel sample frames.
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
@@ -39,8 +39,7 @@ public:
is defined in Stk.h. An StkError will be thrown if an error
occurs duing instantiation.
*/
RtWvIn( unsigned int nChannels = 1, StkFloat sampleRate = Stk::sampleRate(),
int device = 0, int bufferFrames = RT_BUFFER_SIZE, int nBuffers = 4 );
RtWvIn( unsigned int nChannels = 1, StkFloat sampleRate = Stk::sampleRate(), int device = 0, int bufferFrames = RT_BUFFER_SIZE, int nBuffers = 20 );
//! Class destructor.
~RtWvIn();
@@ -59,15 +58,19 @@ public:
*/
void stop( void );
// This function is not intended for general use but had to be made
// public for access from the audio callback function.
void fillBuffer( void *buffer, unsigned int nFrames );
protected:
void computeFrame( void );
RtAudio *adc_;
StkFloat *buffer_;
RtAudio adc_;
bool stopped_;
unsigned int bufferFrames_;
unsigned int bufferIndex_;
unsigned int readIndex_;
unsigned int writeIndex_;
unsigned int framesFilled_;
};

View File

@@ -3,10 +3,10 @@
\brief STK realtime audio (blocking) output class.
This class provides a simplified interface to RtAudio for realtime
audio output. It is a subclass of WvOut. Because this class
makes use of RtAudio's blocking output routines, its performance
is less robust on systems where the audio API is callback-based
(Macintosh CoreAudio and Windows ASIO).
audio output. It is a subclass of WvOut. This class makes use of
RtAudio's callback functionality by creating a large ring-buffer
into which data is written. This class should not be used when
low-latency is desired.
RtWvOut supports multi-channel data in interleaved format. It is
important to distinguish the tick() methods, which output single
@@ -14,7 +14,7 @@
method, which take a pointer or reference to multi-channel sample
frame data.
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
@@ -32,8 +32,7 @@ class RtWvOut : public WvOut
/*!
The \e device argument is passed to RtAudio during
instantiation. The default value (zero) will select the default
device on your system or the first device found meeting the
specified parameters. On systems with multiple
device on your system. On systems with multiple
soundcards/devices, values greater than zero can be specified in
accordance with the order that the devices are enumerated by the
underlying audio API. The default buffer size of RT_BUFFER_SIZE
@@ -41,7 +40,7 @@ class RtWvOut : public WvOut
occurs duing instantiation.
*/
RtWvOut( unsigned int nChannels = 1, StkFloat sampleRate = Stk::sampleRate(),
int device = 0, int bufferFrames = RT_BUFFER_SIZE, int nBuffers = 4 );
int device = 0, int bufferFrames = RT_BUFFER_SIZE, int nBuffers = 20 );
//! Class destructor.
~RtWvOut();
@@ -51,30 +50,30 @@ class RtWvOut : public WvOut
The stream is started automatically, if necessary, when a
tick() or tickFrame method is called.
*/
void start(void);
void start( void );
//! Stop the audio output stream.
/*!
It may be necessary to use this method to avoid undesireable
audio buffer cycling if you wish to temporarily stop audio output.
*/
void stop(void);
void stop( void );
// This function is not intended for general use but had to be made
// public for access from the audio callback function.
int readBuffer( void *buffer, unsigned int frameCount );
protected:
void computeSample( const StkFloat sample );
void computeFrames( const StkFrames& frames );
void incrementFrame( void );
RtAudio *dac_;
StkFloat *buffer_;
RtAudio dac_;
bool stopped_;
unsigned int nChannels_;
unsigned int bufferIndex_;
unsigned int iBuffer_;
unsigned int bufferFrames_;
unsigned int readIndex_;
unsigned int writeIndex_;
long framesFilled_;
unsigned int status_; // running = 0, emptying buffer = 1, finished = 2
};

View File

@@ -5,7 +5,7 @@
This instrument provides an ADSR envelope, a one-pole filter, and
structures for an arbitrary number of attack and loop waves.
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/

View File

@@ -31,7 +31,7 @@
- Vibrato Gain = 1
- Breath Pressure = 128
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/

View File

@@ -13,7 +13,7 @@
- Envelope Rate = 11
- Gain = 128
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/

View File

@@ -9,7 +9,7 @@
The "table" length, set in SineWave.h, is 2048 samples by default.
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
@@ -69,6 +69,7 @@ public:
protected:
StkFloat computeSample( void );
void sampleRateChanged( StkFloat newRate, StkFloat oldRate );
static StkFrames table_;
StkFloat time_;

View File

@@ -9,7 +9,7 @@
from pitch shifting. It will be used as an
excitation source for other instruments.
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/

View File

@@ -13,7 +13,7 @@
Stanford, bearing the names of Karplus and/or
Strong.
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/

View File

@@ -21,7 +21,7 @@
\sa \ref skini
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/

View File

@@ -7,7 +7,7 @@
number of static functions for use with external socket
descriptors.
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/

View File

@@ -17,7 +17,7 @@
- String Sustain = 11
- String Stretch = 1
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/

View File

@@ -8,7 +8,31 @@
this class provides error handling and
byte-swapping functions.
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation files
(the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
Any person wishing to distribute modifications to the Software is
asked to send the modifications to the original developer so that
they can be incorporated into the canonical version. This is,
however, not a binding provision of this license.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/***************************************************/
@@ -18,6 +42,7 @@
#include <string>
#include <iostream>
#include <sstream>
#include <vector>
// Most data in STK is passed and calculated with the
// following user-definable floating-point type. You
@@ -25,19 +50,6 @@
// a "long double" in the future.
typedef double StkFloat;
// The "MY_FLOAT" type was deprecated in STK
// versions higher than 4.1.3 and replaced with the variable
// "StkFloat".
#if defined(__WINDOWS_DS__) || defined(__WINDOWS_ASIO__)
typedef StkFloat MY_FLOAT;
#pragma deprecated(MY_FLOAT)
#elif defined(__GXX__)
typedef StkFloat MY_FLOAT __attribute__ ((deprecated));
#else
typedef StkFloat MY_FLOAT; // temporary
#endif
//! STK error handling class.
/*!
This is a fairly abstract exception handling class. There could
@@ -104,36 +116,53 @@ public:
static const StkFormat STK_FLOAT64; /*!< Normalized between plus/minus 1.0. */
//! Static method which returns the current STK sample rate.
static StkFloat sampleRate(void) { return srate_; }
static StkFloat sampleRate( void ) { return srate_; }
//! Static method which sets the STK sample rate.
//! Static method that sets the STK sample rate.
/*!
The sample rate set using this method is queried by all STK
classes which depend on its value. It is initialized to the
default SRATE set in Stk.h. Many STK classes use the sample rate
during instantiation. Therefore, if you wish to use a rate which
is different from the default rate, it is imperative that it be
set \e BEFORE STK objects are instantiated.
set \e BEFORE STK objects are instantiated. A few classes that
make use of the global STK sample rate are automatically notified
when the rate changes so that internal class data can be
appropriately updated. However, this has not been fully
implemented. Specifically, classes that appropriately update
their own data when either a setFrequency() or noteOn() function
is called do not currently receive the automatic notification of
rate change. If the user wants a specific class instance to
ignore such notifications, perhaps in a multi-rate context, the
function Stk::ignoreSampleRateChange() should be called.
*/
static void setSampleRate(StkFloat rate) { if (rate > 0.0) srate_ = rate; }
static void setSampleRate( StkFloat rate );
//! A function to enable/disable the automatic updating of class data when the STK sample rate changes.
/*!
This function allows the user to enable or disable class data
updates in response to global sample rate changes on a class by
class basis.
*/
void ignoreSampleRateChange( bool ignore = true ) { ignoreSampleRateChange_ = ignore; };
//! Static method which returns the current rawwave path.
static std::string rawwavePath(void) { return rawwavepath_; }
//! Static method which sets the STK rawwave path.
static void setRawwavePath(std::string path);
static void setRawwavePath( std::string path );
//! Static method which byte-swaps a 16-bit data type.
static void swap16(unsigned char *ptr);
static void swap16( unsigned char *ptr );
//! Static method which byte-swaps a 32-bit data type.
static void swap32(unsigned char *ptr);
static void swap32( unsigned char *ptr );
//! Static method which byte-swaps a 64-bit data type.
static void swap64(unsigned char *ptr);
static void swap64( unsigned char *ptr );
//! Static cross-platform method to sleep for a number of milliseconds.
static void sleep(unsigned long milliseconds);
static void sleep( unsigned long milliseconds );
//! Static function for error reporting and handling using c-strings.
static void handleError( const char *message, StkError::Type type );
@@ -152,16 +181,27 @@ private:
static std::string rawwavepath_;
static bool showWarnings_;
static bool printErrors_;
static std::vector<Stk *> alertList_;
protected:
std::ostringstream errorString_;
bool ignoreSampleRateChange_;
//! Default constructor.
Stk(void);
Stk( void );
//! Class destructor.
virtual ~Stk(void);
virtual ~Stk( void );
//! This function should be implemented in subclasses that depend on the sample rate.
virtual void sampleRateChanged( StkFloat newRate, StkFloat oldRate );
//! Add class pointer to list for sample rate change notification.
void addSampleRateAlert( Stk *ptr );
//! Remove class pointer from list for sample rate change notification.
void removeSampleRateAlert( Stk *ptr );
//! Internal function for error reporting which assumes message in \c errorString_ variable.
void handleError( StkError::Type type );
@@ -181,7 +221,7 @@ protected:
to inter- or de-interleave the data and to convert to and return
other data types.
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
@@ -348,13 +388,12 @@ const StkFloat ONE_OVER_128 = 0.0078125;
#if defined(__WINDOWS_DS__) || defined(__WINDOWS_ASIO__) || defined(__WINDOWS_MM__)
#define __OS_WINDOWS__
#define __STK_REALTIME__
#elif defined(__LINUX_OSS__) || defined(__LINUX_ALSA__) || defined(__LINUX_JACK__)
#elif defined(__LINUX_OSS__) || defined(__LINUX_ALSA__) || defined(__UNIX_JACK__)
#define __OS_LINUX__
#define __STK_REALTIME__
#elif defined(__IRIX_AL__)
#define __OS_IRIX__
#define __STK_REALTIME__
#elif defined(__MACOSX_CORE__)
#elif defined(__MACOSX_CORE__) || defined(__UNIX_JACK__)
#define __OS_MACOSX__
#define __STK_REALTIME__
#endif

View File

@@ -6,7 +6,7 @@
using the C rand() function. The quality of the
rand() function varies from one OS to another.
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/

View File

@@ -19,7 +19,7 @@
less than or equal to zero indicate a closed
or lost connection or the occurence of an error.
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/

View File

@@ -19,7 +19,7 @@
less than or equal to zero indicate a closed
or lost connection or the occurence of an error.
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/

View File

@@ -16,7 +16,7 @@
THREAD_RETURN THREAD_TYPE thread_function(void *ptr)
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/

View File

@@ -26,7 +26,7 @@
type who should worry about this (making
money) worry away.
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/

View File

@@ -8,7 +8,7 @@
frequency response while maintaining a nearly
constant filter gain.
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
@@ -27,6 +27,9 @@ class TwoPole : protected Filter
//! Class destructor.
~TwoPole();
//! A function to enable/disable the automatic updating of class data when the STK sample rate changes.
void ignoreSampleRateChange( bool ignore = true ) { ignoreSampleRateChange_ = ignore; };
//! Clears the internal states of the filter.
void clear(void);
@@ -79,6 +82,10 @@ class TwoPole : protected Filter
channels in the StkFrames object.
*/
StkFrames& tick( StkFrames& frames, unsigned int channel = 0 );
protected:
virtual void sampleRateChanged( StkFloat newRate, StkFloat oldRate );
};
#endif

View File

@@ -8,7 +8,7 @@
frequency response while maintaining a
constant filter gain.
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
@@ -26,6 +26,9 @@ class TwoZero : protected Filter
//! Class destructor.
~TwoZero();
//! A function to enable/disable the automatic updating of class data when the STK sample rate changes.
void ignoreSampleRateChange( bool ignore = true ) { ignoreSampleRateChange_ = ignore; };
//! Clears the internal states of the filter.
void clear(void);
@@ -75,6 +78,10 @@ class TwoZero : protected Filter
channels in the StkFrames object.
*/
StkFrames& tick( StkFrames& frames, unsigned int channel = 0 );
protected:
virtual void sampleRateChanged( StkFloat newRate, StkFloat oldRate );
};
#endif

View File

@@ -17,7 +17,7 @@
read/write methods. Values less than or equal to zero indicate
the occurence of an error.
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/

View File

@@ -21,7 +21,7 @@
- Vibrato Gain = 1
- Loudness (Spectral Tilt) = 128
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/

View File

@@ -25,7 +25,7 @@
an ensemble. Alternately, control changes can
be sent to all voices on a given channel.
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/

View File

@@ -12,7 +12,7 @@
which return references or pointers to multi-channel sample
frames.
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/
@@ -83,6 +83,7 @@ public:
protected:
virtual void computeFrame( void );
virtual void sampleRateChanged( StkFloat newRate, StkFloat oldRate );
StkFrames firstFrame_;
StkFloat phaseOffset_;

View File

@@ -26,7 +26,7 @@
type who should worry about this (making
money) worry away.
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/

View File

@@ -13,7 +13,7 @@
Both interleaved and non-interleaved data is supported via the use
of StkFrames objects.
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/

View File

@@ -16,7 +16,7 @@
Currently, WvOut is non-interpolating and the output rate is
always Stk::sampleRate().
by Perry R. Cook and Gary P. Scavone, 1995 - 2005.
by Perry R. Cook and Gary P. Scavone, 1995 - 2007.
*/
/***************************************************/