mirror of
https://github.com/thestk/stk
synced 2026-01-11 20:11:52 +00:00
Version 4.1.2
This commit is contained in:
committed by
Stephen Sinclair
parent
6e0d1955a8
commit
586b0add5f
@@ -53,9 +53,11 @@ public:
|
||||
|
||||
//! Return the value at \e tapDelay samples from the delay-line input.
|
||||
/*!
|
||||
The valid range for \e tapDelay is 1 to the delay-line length.
|
||||
The tap point is determined modulo the delay-line length and is
|
||||
relative to the last input value (i.e., a tapDelay of zero returns
|
||||
the last input value).
|
||||
*/
|
||||
MY_FLOAT contentsAt(long tapDelay) const;
|
||||
MY_FLOAT contentsAt(unsigned long tapDelay) const;
|
||||
|
||||
//! Return the last computed output value.
|
||||
MY_FLOAT lastOut(void) const;
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#define __INSTRMNT_H
|
||||
|
||||
#include "Stk.h"
|
||||
#include <iostream.h>
|
||||
#include <iostream>
|
||||
|
||||
class Instrmnt : public Stk
|
||||
{
|
||||
@@ -36,6 +36,12 @@ class Instrmnt : public Stk
|
||||
//! Return the last output value.
|
||||
MY_FLOAT lastOut() const;
|
||||
|
||||
//! Return the last left output value.
|
||||
MY_FLOAT lastOutLeft() const;
|
||||
|
||||
//! Return the last right output value.
|
||||
MY_FLOAT lastOutRight() const;
|
||||
|
||||
//! Compute one output sample.
|
||||
virtual MY_FLOAT tick() = 0;
|
||||
|
||||
|
||||
@@ -19,12 +19,26 @@ class Noise : public Stk
|
||||
{
|
||||
public:
|
||||
|
||||
//! Default constructor.
|
||||
//! Default constructor which seeds the random number generator with the system time.
|
||||
Noise();
|
||||
|
||||
//! Constructor which seeds the random number generator with a given seed.
|
||||
/*!
|
||||
If the seed value is zero, the random number generator is
|
||||
seeded with the system time.
|
||||
*/
|
||||
Noise( unsigned int seed );
|
||||
|
||||
//! Class destructor.
|
||||
virtual ~Noise();
|
||||
|
||||
//! Seed the random number generator with a specific seed value.
|
||||
/*!
|
||||
If no seed is provided or the seed value is zero, the random
|
||||
number generator is seeded with the current system time.
|
||||
*/
|
||||
void setSeed( unsigned int seed = 0 );
|
||||
|
||||
//! Return a random number between -1.0 and 1.0 using rand().
|
||||
virtual MY_FLOAT tick();
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -85,14 +85,13 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
RtAudio *audio;
|
||||
MY_FLOAT *data;
|
||||
MY_FLOAT *lastOutput;
|
||||
int bufferSize;
|
||||
bool stopped;
|
||||
int stream;
|
||||
long counter;
|
||||
unsigned int channels;
|
||||
RtAudio *audio_;
|
||||
MY_FLOAT *data_;
|
||||
MY_FLOAT *lastOutput_;
|
||||
int bufferSize_;
|
||||
bool stopped_;
|
||||
long counter_;
|
||||
unsigned int channels_;
|
||||
|
||||
};
|
||||
|
||||
|
||||
60
include/RtError.h
Normal file
60
include/RtError.h
Normal file
@@ -0,0 +1,60 @@
|
||||
/************************************************************************/
|
||||
/*! \class RtError
|
||||
\brief Exception handling class for RtAudio & RtMidi.
|
||||
|
||||
The RtError class is quite simple but it does allow errors to be
|
||||
"caught" by RtError::Type. See the RtAudio and RtMidi
|
||||
documentation to know which methods can throw an RtError.
|
||||
|
||||
*/
|
||||
/************************************************************************/
|
||||
|
||||
#ifndef RTERROR_H
|
||||
#define RTERROR_H
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
class RtError
|
||||
{
|
||||
public:
|
||||
//! Defined RtError types.
|
||||
enum Type {
|
||||
WARNING, /*!< A non-critical error. */
|
||||
DEBUG_WARNING, /*!< A non-critical error which might be useful for debugging. */
|
||||
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. */
|
||||
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){}
|
||||
|
||||
//! The destructor.
|
||||
virtual ~RtError(void) {};
|
||||
|
||||
//! Prints thrown error message to stderr.
|
||||
virtual void printMessage(void) { std::cerr << '\n' << message_ << "\n\n"; }
|
||||
|
||||
//! Returns the thrown error message type.
|
||||
virtual const Type& getType(void) { return type_; }
|
||||
|
||||
//! Returns the thrown error message string.
|
||||
virtual const std::string& getMessage(void) { return message_; }
|
||||
|
||||
//! Returns the thrown error message as a C string.
|
||||
virtual const char *getMessageString(void) { return message_.c_str(); }
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -90,10 +90,9 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
RtAudio *audio;
|
||||
bool stopped;
|
||||
int stream;
|
||||
long counter;
|
||||
RtAudio *audio_;
|
||||
bool stopped_;
|
||||
long counter_;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -23,10 +23,12 @@
|
||||
|
||||
#include "WvOut.h"
|
||||
#include "RtAudio.h"
|
||||
#include "Thread.h"
|
||||
|
||||
class RtWvOut : protected WvOut
|
||||
{
|
||||
public:
|
||||
|
||||
//! Default constructor.
|
||||
/*!
|
||||
The \e device argument is passed to RtAudio during
|
||||
@@ -82,10 +84,9 @@ class RtWvOut : protected WvOut
|
||||
|
||||
protected:
|
||||
|
||||
RtAudio *audio;
|
||||
bool stopped;
|
||||
int stream;
|
||||
int bufferSize;
|
||||
RtAudio *audio_;
|
||||
bool stopped_;
|
||||
int bufferSize_;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
#define __SK_ChannelPressure_ __SK_AfterTouch_
|
||||
#define __SK_PitchWheel_ 224
|
||||
#define __SK_PitchBend_ __SK_PitchWheel_
|
||||
#define __SK_PitchChange_ 249
|
||||
#define __SK_PitchChange_ 49
|
||||
|
||||
#define __SK_Clock_ 248
|
||||
#define __SK_SongStart_ 250
|
||||
|
||||
@@ -3,10 +3,10 @@
|
||||
\brief STK base class
|
||||
|
||||
Nearly all STK classes inherit from this class.
|
||||
The global sample rate can be queried and
|
||||
modified via Stk. In addition, this class
|
||||
provides error handling and byte-swapping
|
||||
functions.
|
||||
The global sample rate and rawwave path variables
|
||||
can be queried and modified via Stk. In addition,
|
||||
this class provides error handling and
|
||||
byte-swapping functions.
|
||||
|
||||
by Perry R. Cook and Gary P. Scavone, 1995 - 2002.
|
||||
*/
|
||||
@@ -15,11 +15,24 @@
|
||||
#if !defined(__STK_H)
|
||||
#define __STK_H
|
||||
|
||||
// Most data in STK is passed and calculated with the following
|
||||
// user-definable floating-point type. You can change this to "float"
|
||||
// if you prefer or perhaps a "long double" in the future.
|
||||
#include <string>
|
||||
|
||||
// Most data in STK is passed and calculated with the
|
||||
// following user-definable floating-point type. You
|
||||
// can change this to "float" if you prefer or perhaps
|
||||
// a "long double" in the future.
|
||||
typedef double MY_FLOAT;
|
||||
|
||||
// The "MY_FLOAT" type will be deprecated in STK
|
||||
// versions higher than 4.1.2 and replaced with the variable
|
||||
// "StkFloat".
|
||||
//typedef double StkFloat;
|
||||
//#if defined(__WINDOWS_DS__) || defined(__WINDOWS_ASIO__)
|
||||
// #pragma deprecated(MY_FLOAT)
|
||||
//#else
|
||||
// typedef StkFloat MY_FLOAT __attribute__ ((deprecated));
|
||||
//#endif
|
||||
|
||||
//! STK error handling class.
|
||||
/*!
|
||||
This is a fairly abstract exception handling class. There could
|
||||
@@ -74,8 +87,8 @@ public:
|
||||
static const STK_FORMAT STK_SINT8; /*!< -128 to +127 */
|
||||
static const STK_FORMAT STK_SINT16; /*!< -32768 to +32767 */
|
||||
static const STK_FORMAT STK_SINT32; /*!< -2147483648 to +2147483647. */
|
||||
static const STK_FORMAT STK_FLOAT32; /*!< Normalized between plus/minus 1.0. */
|
||||
static const STK_FORMAT STK_FLOAT64; /*!< Normalized between plus/minus 1.0. */
|
||||
static const STK_FORMAT MY_FLOAT32; /*!< Normalized between plus/minus 1.0. */
|
||||
static const STK_FORMAT MY_FLOAT64; /*!< Normalized between plus/minus 1.0. */
|
||||
|
||||
//! Static method which returns the current STK sample rate.
|
||||
static MY_FLOAT sampleRate(void);
|
||||
@@ -91,6 +104,12 @@ public:
|
||||
*/
|
||||
static void setSampleRate(MY_FLOAT newRate);
|
||||
|
||||
//! Static method which returns the current rawwave path.
|
||||
static std::string rawwavePath(void);
|
||||
|
||||
//! Static method which sets the STK rawwave path.
|
||||
static void setRawwavePath(std::string newPath);
|
||||
|
||||
//! Static method which byte-swaps a 16-bit data type.
|
||||
static void swap16(unsigned char *ptr);
|
||||
|
||||
@@ -105,6 +124,7 @@ public:
|
||||
|
||||
private:
|
||||
static MY_FLOAT srate;
|
||||
static std::string rawwavepath;
|
||||
|
||||
protected:
|
||||
|
||||
@@ -130,22 +150,23 @@ typedef double FLOAT64;
|
||||
#define TRUE 1
|
||||
|
||||
// The default sampling rate.
|
||||
#define SRATE (MY_FLOAT) 22050.0
|
||||
|
||||
// Real-time audio input and output buffer size. If clicks are
|
||||
// occuring in the input and/or output sound stream, a larger buffer
|
||||
// size may help. Larger buffer sizes, however, produce more latency.
|
||||
#define SRATE (MY_FLOAT) 44100.0
|
||||
|
||||
// The default real-time audio input and output buffer size. If
|
||||
// clicks are occuring in the input and/or output sound stream, a
|
||||
// larger buffer size may help. Larger buffer sizes, however, produce
|
||||
// more latency.
|
||||
#define RT_BUFFER_SIZE 512
|
||||
|
||||
// The RAWWAVE_PATH definition is concatenated to the beginning of all
|
||||
// references to rawwave files in the various STK core classes
|
||||
// (ex. Clarinet.cpp). If you wish to move the rawwaves directory to
|
||||
// a different location in your file system, you will need to set this
|
||||
// path definition appropriately. The current definition is a
|
||||
// relative reference that will work for the programs in the STK
|
||||
// projects directory. The path can also be specified to configure and
|
||||
// set via the Makefiles.
|
||||
// The default rawwave path value is set with the preprocessor
|
||||
// definition RAWWAVE_PATH. This can be specified as an argument to
|
||||
// the configure script, in an integrated development environment, or
|
||||
// below. The global STK rawwave path variable can be dynamically set
|
||||
// with the Stk::setRawwavePath() function. This value is
|
||||
// concatenated to the beginning of all references to rawwave files in
|
||||
// the various STK core classes (ex. Clarinet.cpp). If you wish to
|
||||
// move the rawwaves directory to a different location in your file
|
||||
// system, you will need to set this path definition appropriately.
|
||||
#if !defined(RAWWAVE_PATH)
|
||||
#define RAWWAVE_PATH "../../rawwaves/"
|
||||
#endif
|
||||
@@ -158,7 +179,7 @@ typedef double FLOAT64;
|
||||
#if defined(__WINDOWS_DS__) || defined(__WINDOWS_ASIO__)
|
||||
#define __OS_WINDOWS__
|
||||
#define __STK_REALTIME__
|
||||
#elif defined(__LINUX_OSS__) || defined(__LINUX_ALSA__)
|
||||
#elif defined(__LINUX_OSS__) || defined(__LINUX_ALSA__) || defined(__LINUX_JACK__)
|
||||
#define __OS_LINUX__
|
||||
#define __STK_REALTIME__
|
||||
#elif defined(__IRIX_AL__)
|
||||
|
||||
@@ -82,7 +82,7 @@ class TcpWvOut : protected WvOut
|
||||
protected:
|
||||
|
||||
// Write a buffer of length \e frames via the socket connection.
|
||||
void writeData( long frames );
|
||||
void writeData( unsigned long frames );
|
||||
|
||||
char msg[256];
|
||||
char *buffer;
|
||||
|
||||
@@ -112,12 +112,18 @@ public:
|
||||
//! Mix the output for all sounding voices.
|
||||
MY_FLOAT tick();
|
||||
|
||||
//! Computer \e vectorSize output mixes and return them in \e vector.
|
||||
//! Compute \e vectorSize output mixes and return them in \e vector.
|
||||
MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize);
|
||||
|
||||
//! Return the last output value.
|
||||
MY_FLOAT lastOut() const;
|
||||
|
||||
//! Return the last left output value.
|
||||
MY_FLOAT lastOutLeft() const;
|
||||
|
||||
//! Return the last right output value.
|
||||
MY_FLOAT lastOutRight() const;
|
||||
|
||||
protected:
|
||||
|
||||
typedef struct {
|
||||
@@ -135,7 +141,8 @@ protected:
|
||||
long tags;
|
||||
int muteTime;
|
||||
MY_FLOAT lastOutput;
|
||||
|
||||
MY_FLOAT lastOutputLeft;
|
||||
MY_FLOAT lastOutputRight;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -60,7 +60,7 @@ public:
|
||||
An StkError will be thrown if the file is not found, its format is
|
||||
unknown, or a read error occurs.
|
||||
*/
|
||||
WvIn( const char *fileName, bool raw = FALSE );
|
||||
WvIn( const char *fileName, bool raw = FALSE, bool doNormalize = TRUE );
|
||||
|
||||
//! Class destructor.
|
||||
virtual ~WvIn();
|
||||
@@ -70,7 +70,7 @@ public:
|
||||
An StkError will be thrown if the file is not found, its format is
|
||||
unknown, or a read error occurs.
|
||||
*/
|
||||
void openFile( const char *fileName, bool raw = FALSE );
|
||||
void openFile( const char *fileName, bool raw = FALSE, bool doNormalize = TRUE );
|
||||
|
||||
//! If a file is open, close it.
|
||||
void closeFile(void);
|
||||
|
||||
@@ -83,19 +83,19 @@ class WvOut : public Stk
|
||||
|
||||
//! Output a single sample to all channels in a sample frame.
|
||||
/*!
|
||||
An StkError is thrown if a file read error occurs.
|
||||
An StkError is thrown if a file write error occurs.
|
||||
*/
|
||||
virtual void tick(const MY_FLOAT sample);
|
||||
|
||||
//! Output each sample in \e vector to all channels in \e vectorSize sample frames.
|
||||
/*!
|
||||
An StkError is thrown if a file read error occurs.
|
||||
An StkError is thrown if a file write error occurs.
|
||||
*/
|
||||
virtual void tick(const MY_FLOAT *vector, unsigned int vectorSize);
|
||||
|
||||
//! Output the \e frameVector of sample frames of the given length.
|
||||
/*!
|
||||
An StkError is thrown if a file read error occurs.
|
||||
An StkError is thrown if a file write error occurs.
|
||||
*/
|
||||
virtual void tickFrame(const MY_FLOAT *frameVector, unsigned int frames = 1);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user