21 Commits

Author SHA1 Message Date
garyscavone
7840967816 Revert "Fix for #108" 2021-03-19 13:30:25 -04:00
Gary Scavone
8132c90515 Added throw() to ~StkError declaration to support all C++ versions. 2021-03-18 15:09:01 -04:00
garyscavone
73004ac9c4 Merge pull request #110 from vuki/master
Fix for #108
2021-03-18 14:44:50 -04:00
garyscavone
a49f6e71e7 Merge pull request #109 from vuki/makefix
Add missing TapDelay to src/Makefile
2021-03-18 14:42:37 -04:00
Grzegorz Szwoch (sound)
926a9faca7 Fix for #108 2021-03-18 19:42:26 +01:00
Grzegorz Szwoch (sound)
34192d9a63 Fix for #108 2021-03-18 19:39:41 +01:00
Grzegorz Szwoch (sound)
fb2b0aa305 Add missing TapDelay to src/Makefile 2021-03-18 19:11:33 +01:00
garyscavone
ba967ff851 Merge pull request #108 from vuki/wrappointer
Add StkFrames constructor that wraps pointer to existing buffer
2021-03-18 11:47:11 -04:00
Grzegorz Szwoch (sound)
109f0bd9a8 Add StkFrames constructor that wraps pointer to existing buffer 2021-03-08 09:26:15 +01:00
Gary Scavone
7b94384705 Doxygen fix for underscores 2021-03-05 14:47:44 -05:00
garyscavone
b379160f2b Merge pull request #107 from vuki/operators
StkFrames: add * and *= operators for multiplication by StkFloat; ret…
2021-02-25 20:39:46 -05:00
Grzegorz Szwoch (sound)
4b5b142531 StkFrames: add * and *= operators for multiplication by StkFloat; return reference from += and *- operators 2021-02-25 13:17:58 +01:00
garyscavone
f1a75a8691 Merge pull request #106 from vuki/stkerror
Make StkError inherit from std::exception
2021-02-24 09:18:15 -05:00
Grzegorz Szwoch (sound)
e5cab23433 Make StkError inherit from std::exception 2021-02-24 11:13:47 +01:00
garyscavone
5a8b2234c7 Merge pull request #105 from vuki/master
Fix infinite loop in RtWvOut destructor
2021-02-23 17:22:56 -05:00
Grzegorz Szwoch (sound)
314835cc70 Fix infinite loop in RtWvOut destructor 2021-02-23 21:19:36 +01:00
garyscavone
fb15f76d45 Merge pull request #97 from ryandesign/autoconf-vars
Support exec_prefix, bindir, includedir, libdir
2020-05-08 12:37:06 -04:00
garyscavone
921493d4fe Merge pull request #96 from ryandesign/LDFLAGS
Use any LDFLAGS set when running ./configure
2020-05-08 12:35:47 -04:00
Ryan Schmidt
4cbdd0d3dc Support exec_prefix, bindir, includedir, libdir
Autoconf configure scripts allow the user to specify alternate
directories for exec_prefix, bindir, includedir, and libdir (see
./configure --help). Now, they are honored by the Makefile.
2020-05-06 13:33:45 -05:00
Ryan Schmidt
c97f5b4b3a Use any LDFLAGS set when running ./configure 2020-05-06 12:47:50 -05:00
garyscavone
809cb26e12 Merge pull request #95 from thestk/cocoapods-update
Update iOS demo project
2020-04-12 11:12:00 -04:00
11 changed files with 96 additions and 26 deletions

View File

@@ -38,19 +38,19 @@ STK compiles with realtime support on the following flavors of the Unix operatin
<TR>
<TD>Linux</TD>
<TD>ALSA</TD>
<TD>__LINUX_ALSA__, __LITTLE_ENDIAN__</TD>
<TD>__LINUX_ALSA__, \__LITTLE_ENDIAN__</TD>
<TD><TT>asound, pthread</TT></TD>
</TR>
<TR>
<TD>Linux</TD>
<TD>OSS (version 4.0 only, use ALSA for MIDI support)</TD>
<TD>__LINUX_OSS__, __LINUX_ALSA__, __LITTLE_ENDIAN__</TD>
<TD>__LINUX_OSS__, \__LINUX_ALSA__, \__LITTLE_ENDIAN__</TD>
<TD><TT>asound, pthread</TT></TD>
</TR>
<TR>
<TD>Linux and Macintosh OS-X</TD>
<TD>Jack</TD>
<TD>__UNIX_JACK__, __LITTLE_ENDIAN__</TD>
<TD>__UNIX_JACK__, \__LITTLE_ENDIAN__</TD>
<TD><TT>asound, pthread, jack</TT></TD>
</TR>
<TR>

View File

@@ -6,6 +6,7 @@
#include <iostream>
#include <sstream>
#include <vector>
#include <stdexcept>
//#include <cstdlib>
/*! \namespace stk
@@ -82,7 +83,7 @@ typedef double StkFloat;
be sub-classes to take care of more specific error conditions ... or
not.
*/
class StkError
class StkError : public std::exception
{
public:
enum Type {
@@ -110,10 +111,10 @@ protected:
public:
//! The constructor.
StkError(const std::string& message, Type type = StkError::UNSPECIFIED)
: message_(message), type_(type) {}
: std::exception(), message_(message), type_(type) {}
//! The destructor.
virtual ~StkError(void) {};
virtual ~StkError(void) throw() {};
//! Prints thrown error message to stderr.
virtual void printMessage(void) { std::cerr << '\n' << message_ << "\n\n"; }
@@ -126,6 +127,8 @@ public:
//! Returns the thrown error message as a C string.
virtual const char *getMessageCString(void) { return message_.c_str(); }
virtual const char *what(void) const throw() { return message_.c_str(); }
};
@@ -282,6 +285,9 @@ public:
//! Overloaded constructor that initializes the frame data to the specified size with \c value.
StkFrames( const StkFloat& value, unsigned int nFrames, unsigned int nChannels );
//! Overloaded constructor that wraps the provided pointer to \c data.
StkFrames( StkFloat* data, unsigned int nFrames, unsigned int nChannels = 1 );
//! The destructor.
~StkFrames();
@@ -321,7 +327,7 @@ public:
self. No range checking is performed unless _STK_DEBUG_ is
defined.
*/
void operator+= ( StkFrames& f );
StkFrames& operator+= ( StkFrames& f );
//! Assignment by product operator into self.
/*!
@@ -329,7 +335,16 @@ public:
self. No range checking is performed unless _STK_DEBUG_ is
defined.
*/
void operator*= ( StkFrames& f );
StkFrames& operator*= ( StkFrames& f );
//! Scaling operator (StkFrame * StkFloat).
StkFrames operator* ( StkFloat v ) const;
//! Scaling operator (StkFloat * StkFrame)
friend StkFrames operator*(StkFloat v, const StkFrames& f);
//! Scaling operator (inline).
StkFrames& operator*= ( StkFloat v );
//! Channel / frame subscript operator that returns a reference.
/*!
@@ -428,6 +443,7 @@ private:
unsigned int nChannels_;
size_t size_;
size_t bufferSize_;
bool ownData_;
};
@@ -508,7 +524,7 @@ inline StkFrames StkFrames::operator+(const StkFrames &f) const
return sum;
}
inline void StkFrames :: operator+= ( StkFrames& f )
inline StkFrames& StkFrames :: operator+= ( StkFrames& f )
{
#if defined(_STK_DEBUG_)
if ( f.frames() != nFrames_ || f.channels() != nChannels_ ) {
@@ -522,9 +538,10 @@ inline void StkFrames :: operator+= ( StkFrames& f )
StkFloat *dptr = data_;
for ( unsigned int i=0; i<size_; i++ )
*dptr++ += *fptr++;
return *this;
}
inline void StkFrames :: operator*= ( StkFrames& f )
inline StkFrames& StkFrames :: operator*= ( StkFrames& f )
{
#if defined(_STK_DEBUG_)
if ( f.frames() != nFrames_ || f.channels() != nChannels_ ) {
@@ -538,8 +555,40 @@ inline void StkFrames :: operator*= ( StkFrames& f )
StkFloat *dptr = data_;
for ( unsigned int i=0; i<size_; i++ )
*dptr++ *= *fptr++;
return *this;
}
inline StkFrames StkFrames::operator*(StkFloat v) const
{
StkFrames res((unsigned int)nFrames_, nChannels_);
StkFloat *resPtr = &res[0];
const StkFloat *dPtr = data_;
for (unsigned int i = 0; i < size_; i++) {
*resPtr++ = v * *dPtr++;
}
return res;
}
inline StkFrames operator*(StkFloat v, const StkFrames& f)
{
StkFrames res((unsigned int)f.nFrames_, f.nChannels_);
StkFloat *resPtr = &res[0];
StkFloat *dPtr = f.data_;
for (unsigned int i = 0; i < f.size_; i++) {
*resPtr++ = v * *dPtr++;
}
return res;
}
inline StkFrames& StkFrames :: operator*= ( StkFloat v )
{
StkFloat *dptr = data_;
for ( unsigned int i=0; i<size_; i++ )
*dptr++ *= v;
return *this;
}
// Here are a few other useful typedefs.
typedef unsigned short UINT16;
typedef unsigned int UINT32;

View File

@@ -35,6 +35,7 @@ DEFS = @CPPFLAGS@
DEFS += @byte_order@
CFLAGS = @CXXFLAGS@
CFLAGS += -I$(INCLUDE) -I$(INCLUDE)/../src/include
LDFLAGS = @LDFLAGS@
LIBRARY = @LIBS@
REALTIME = @realtime@

View File

@@ -24,6 +24,7 @@ DEFS = @CPPFLAGS@
DEFS += @byte_order@
CFLAGS = @CXXFLAGS@
CFLAGS += -I$(INCLUDE) -I$(INCLUDE)/../src/include
LDFLAGS = @LDFLAGS@
LIBRARY = @LIBS@
REALTIME = @realtime@

View File

@@ -24,6 +24,7 @@ DEFS = @CPPFLAGS@
DEFS += @byte_order@
CFLAGS = @CXXFLAGS@
CFLAGS += -I$(INCLUDE) -I$(INCLUDE)/../src/include
LDFLAGS = @LDFLAGS@
LIBRARY = @LIBS@
REALTIME = @realtime@

View File

@@ -18,6 +18,7 @@ DEFS = @CPPFLAGS@
DEFS += @byte_order@
CFLAGS = @CXXFLAGS@
CFLAGS += -I$(INCLUDE) -I$(INCLUDE)/../src/include
LDFLAGS = @LDFLAGS@
LIBRARY = @LIBS@
REALTIME = @realtime@

View File

@@ -14,6 +14,7 @@ DEFS = @CPPFLAGS@
DEFS += @byte_order@
CFLAGS = @CXXFLAGS@
CFLAGS += -I$(INCLUDE) -Iinclude
LDFLAGS = @LDFLAGS@
LIBRARY = @LIBS@
REALTIME = @realtime@

View File

@@ -25,6 +25,7 @@ DEFS = @CPPFLAGS@
DEFS += @byte_order@
CFLAGS = @CXXFLAGS@
CFLAGS += -I$(INCLUDE) -I$(INCLUDE)/../src/include
LDFLAGS = @LDFLAGS@
LIBRARY = @LIBS@
REALTIME = @realtime@

View File

@@ -10,16 +10,18 @@ AR = ar -rsc
RM = /bin/rm
LN = /bin/ln
OBJECT_PATH = @object_path@
LIBDIR = @libdir@
PREFIX = @prefix@
INCLUDEDIR = @includedir@
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
libdir = @libdir@
includedir = @includedir@
vpath %.o $(OBJECT_PATH)
OBJECTS = Stk.o Generator.o Noise.o Blit.o BlitSaw.o BlitSquare.o Granulate.o \
Envelope.o ADSR.o Asymp.o Modulate.o SineWave.o FileLoop.o SingWave.o \
FileRead.o FileWrite.o WvIn.o FileWvIn.o WvOut.o FileWvOut.o \
Filter.o Fir.o Iir.o OneZero.o OnePole.o PoleZero.o TwoZero.o TwoPole.o \
BiQuad.o FormSwep.o Delay.o DelayL.o DelayA.o \
BiQuad.o FormSwep.o Delay.o DelayL.o DelayA.o TapDelay.o\
\
Effect.o PRCRev.o JCRev.o NRev.o FreeVerb.o \
Chorus.o Echo.o PitShift.o LentPitShift.o \
@@ -48,6 +50,7 @@ DEFS = @CPPFLAGS@
DEFS += @byte_order@
CFLAGS = @CXXFLAGS@
CFLAGS += $(INCLUDE) -Iinclude -fPIC
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@
REALTIME = @realtime@
@@ -93,13 +96,13 @@ $(SHAREDLIB) : $(OBJECTS)
$(LN) -s @sharedname@ $(SHAREDLIB)
install-headers:
install -d $(DESTDIR)$(PREFIX)$(INCLUDEDIR)/stk
cp -R ../include/*.h $(DESTDIR)$(PREFIX)$(INCLUDEDIR)/stk
install -d $(DESTDIR)$(includedir)/stk
cp -R ../include/*.h $(DESTDIR)$(includedir)/stk
install: $(SHAREDLIB) install-headers
install -d $(DESTDIR)$(PREFIX)$(LIBDIR)
install -m 644 @sharedname@ $(DESTDIR)$(PREFIX)$(LIBDIR)
ln -sf @sharedname@ $(DESTDIR)$(PREFIX)$(LIBDIR)/$(SHAREDLIB)
install -d $(DESTDIR)$(libdir)
install -m 644 @sharedname@ $(DESTDIR)$(libdir)
ln -sf @sharedname@ $(DESTDIR)$(libdir)/$(SHAREDLIB)
$(OBJECTS) : Stk.h

View File

@@ -122,7 +122,7 @@ RtWvOut :: ~RtWvOut( void )
{
// Change status flag to signal callback to clear the buffer and close.
status_ = EMPTYING;
while ( status_ != FINISHED || dac_.isStreamRunning() == true ) Stk::sleep( 100 );
while ( status_ != FINISHED && dac_.isStreamRunning() == true ) Stk::sleep( 100 );
dac_.closeStream();
}

View File

@@ -229,7 +229,7 @@ void Stk :: handleError( std::string message, StkError::Type type )
//
StkFrames :: StkFrames( unsigned int nFrames, unsigned int nChannels )
: data_( 0 ), nFrames_( nFrames ), nChannels_( nChannels )
: data_( 0 ), nFrames_( nFrames ), nChannels_( nChannels ), ownData_(true)
{
size_ = nFrames_ * nChannels_;
bufferSize_ = size_;
@@ -248,7 +248,7 @@ StkFrames :: StkFrames( unsigned int nFrames, unsigned int nChannels )
}
StkFrames :: StkFrames( const StkFloat& value, unsigned int nFrames, unsigned int nChannels )
: data_( 0 ), nFrames_( nFrames ), nChannels_( nChannels )
: data_( 0 ), nFrames_( nFrames ), nChannels_( nChannels ), ownData_(true)
{
size_ = nFrames_ * nChannels_;
bufferSize_ = size_;
@@ -266,13 +266,21 @@ StkFrames :: StkFrames( const StkFloat& value, unsigned int nFrames, unsigned in
dataRate_ = Stk::sampleRate();
}
StkFrames :: StkFrames( StkFloat* data, unsigned int nFrames, unsigned int nChannels )
: data_( data ), nFrames_( nFrames ), nChannels_( nChannels ), ownData_(false)
{
size_ = nFrames_ * nChannels_;
bufferSize_ = size_;
dataRate_ = Stk::sampleRate();
}
StkFrames :: ~StkFrames()
{
if ( data_ ) free( data_ );
if ( data_ && ownData_ ) free( data_ );
}
StkFrames :: StkFrames( const StkFrames& f )
: data_(0), size_(0), bufferSize_(0)
: data_(0), size_(0), bufferSize_(0), ownData_(true)
{
resize( f.frames(), f.channels() );
dataRate_ = Stk::sampleRate();
@@ -281,7 +289,7 @@ StkFrames :: StkFrames( const StkFrames& f )
StkFrames& StkFrames :: operator= ( const StkFrames& f )
{
if ( data_ ) free( data_ );
if ( data_ && ownData_ ) free( data_ );
data_ = 0;
size_ = 0;
bufferSize_ = 0;
@@ -298,15 +306,19 @@ void StkFrames :: resize( size_t nFrames, unsigned int nChannels )
size_ = nFrames_ * nChannels_;
if ( size_ > bufferSize_ ) {
if ( data_ ) free( data_ );
if ( data_ && ownData_ ) free( data_ );
data_ = (StkFloat *) malloc( size_ * sizeof( StkFloat ) );
#if defined(_STK_DEBUG_)
if ( data_ == NULL ) {
std::string error = "StkFrames::resize: memory allocation error!";
Stk::handleError( error, StkError::MEMORY_ALLOCATION );
}
if ( ownData_ ) {
Stk::handleError( "Pointer to external data was lost after resize", StkError::WARNING );
}
#endif
bufferSize_ = size_;
ownData_ = true;
}
}