mirror of
https://github.com/thestk/stk
synced 2026-05-01 19:58:36 +00:00
Compare commits
21 Commits
cocoapods-
...
revert-110
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7840967816 | ||
|
|
8132c90515 | ||
|
|
73004ac9c4 | ||
|
|
a49f6e71e7 | ||
|
|
926a9faca7 | ||
|
|
34192d9a63 | ||
|
|
fb2b0aa305 | ||
|
|
ba967ff851 | ||
|
|
109f0bd9a8 | ||
|
|
7b94384705 | ||
|
|
b379160f2b | ||
|
|
4b5b142531 | ||
|
|
f1a75a8691 | ||
|
|
e5cab23433 | ||
|
|
5a8b2234c7 | ||
|
|
314835cc70 | ||
|
|
fb15f76d45 | ||
|
|
921493d4fe | ||
|
|
4cbdd0d3dc | ||
|
|
c97f5b4b3a | ||
|
|
809cb26e12 |
@@ -38,19 +38,19 @@ STK compiles with realtime support on the following flavors of the Unix operatin
|
|||||||
<TR>
|
<TR>
|
||||||
<TD>Linux</TD>
|
<TD>Linux</TD>
|
||||||
<TD>ALSA</TD>
|
<TD>ALSA</TD>
|
||||||
<TD>__LINUX_ALSA__, __LITTLE_ENDIAN__</TD>
|
<TD>__LINUX_ALSA__, \__LITTLE_ENDIAN__</TD>
|
||||||
<TD><TT>asound, pthread</TT></TD>
|
<TD><TT>asound, pthread</TT></TD>
|
||||||
</TR>
|
</TR>
|
||||||
<TR>
|
<TR>
|
||||||
<TD>Linux</TD>
|
<TD>Linux</TD>
|
||||||
<TD>OSS (version 4.0 only, use ALSA for MIDI support)</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>
|
<TD><TT>asound, pthread</TT></TD>
|
||||||
</TR>
|
</TR>
|
||||||
<TR>
|
<TR>
|
||||||
<TD>Linux and Macintosh OS-X</TD>
|
<TD>Linux and Macintosh OS-X</TD>
|
||||||
<TD>Jack</TD>
|
<TD>Jack</TD>
|
||||||
<TD>__UNIX_JACK__, __LITTLE_ENDIAN__</TD>
|
<TD>__UNIX_JACK__, \__LITTLE_ENDIAN__</TD>
|
||||||
<TD><TT>asound, pthread, jack</TT></TD>
|
<TD><TT>asound, pthread, jack</TT></TD>
|
||||||
</TR>
|
</TR>
|
||||||
<TR>
|
<TR>
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <stdexcept>
|
||||||
//#include <cstdlib>
|
//#include <cstdlib>
|
||||||
|
|
||||||
/*! \namespace stk
|
/*! \namespace stk
|
||||||
@@ -82,7 +83,7 @@ typedef double StkFloat;
|
|||||||
be sub-classes to take care of more specific error conditions ... or
|
be sub-classes to take care of more specific error conditions ... or
|
||||||
not.
|
not.
|
||||||
*/
|
*/
|
||||||
class StkError
|
class StkError : public std::exception
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum Type {
|
enum Type {
|
||||||
@@ -110,10 +111,10 @@ protected:
|
|||||||
public:
|
public:
|
||||||
//! The constructor.
|
//! The constructor.
|
||||||
StkError(const std::string& message, Type type = StkError::UNSPECIFIED)
|
StkError(const std::string& message, Type type = StkError::UNSPECIFIED)
|
||||||
: message_(message), type_(type) {}
|
: std::exception(), message_(message), type_(type) {}
|
||||||
|
|
||||||
//! The destructor.
|
//! The destructor.
|
||||||
virtual ~StkError(void) {};
|
virtual ~StkError(void) throw() {};
|
||||||
|
|
||||||
//! Prints thrown error message to stderr.
|
//! Prints thrown error message to stderr.
|
||||||
virtual void printMessage(void) { std::cerr << '\n' << message_ << "\n\n"; }
|
virtual void printMessage(void) { std::cerr << '\n' << message_ << "\n\n"; }
|
||||||
@@ -126,6 +127,8 @@ public:
|
|||||||
|
|
||||||
//! Returns the thrown error message as a C string.
|
//! Returns the thrown error message as a C string.
|
||||||
virtual const char *getMessageCString(void) { return message_.c_str(); }
|
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.
|
//! Overloaded constructor that initializes the frame data to the specified size with \c value.
|
||||||
StkFrames( const StkFloat& value, unsigned int nFrames, unsigned int nChannels );
|
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.
|
//! The destructor.
|
||||||
~StkFrames();
|
~StkFrames();
|
||||||
|
|
||||||
@@ -321,7 +327,7 @@ public:
|
|||||||
self. No range checking is performed unless _STK_DEBUG_ is
|
self. No range checking is performed unless _STK_DEBUG_ is
|
||||||
defined.
|
defined.
|
||||||
*/
|
*/
|
||||||
void operator+= ( StkFrames& f );
|
StkFrames& operator+= ( StkFrames& f );
|
||||||
|
|
||||||
//! Assignment by product operator into self.
|
//! Assignment by product operator into self.
|
||||||
/*!
|
/*!
|
||||||
@@ -329,7 +335,16 @@ public:
|
|||||||
self. No range checking is performed unless _STK_DEBUG_ is
|
self. No range checking is performed unless _STK_DEBUG_ is
|
||||||
defined.
|
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.
|
//! Channel / frame subscript operator that returns a reference.
|
||||||
/*!
|
/*!
|
||||||
@@ -428,6 +443,7 @@ private:
|
|||||||
unsigned int nChannels_;
|
unsigned int nChannels_;
|
||||||
size_t size_;
|
size_t size_;
|
||||||
size_t bufferSize_;
|
size_t bufferSize_;
|
||||||
|
bool ownData_;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -508,7 +524,7 @@ inline StkFrames StkFrames::operator+(const StkFrames &f) const
|
|||||||
return sum;
|
return sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void StkFrames :: operator+= ( StkFrames& f )
|
inline StkFrames& StkFrames :: operator+= ( StkFrames& f )
|
||||||
{
|
{
|
||||||
#if defined(_STK_DEBUG_)
|
#if defined(_STK_DEBUG_)
|
||||||
if ( f.frames() != nFrames_ || f.channels() != nChannels_ ) {
|
if ( f.frames() != nFrames_ || f.channels() != nChannels_ ) {
|
||||||
@@ -522,9 +538,10 @@ inline void StkFrames :: operator+= ( StkFrames& f )
|
|||||||
StkFloat *dptr = data_;
|
StkFloat *dptr = data_;
|
||||||
for ( unsigned int i=0; i<size_; i++ )
|
for ( unsigned int i=0; i<size_; i++ )
|
||||||
*dptr++ += *fptr++;
|
*dptr++ += *fptr++;
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void StkFrames :: operator*= ( StkFrames& f )
|
inline StkFrames& StkFrames :: operator*= ( StkFrames& f )
|
||||||
{
|
{
|
||||||
#if defined(_STK_DEBUG_)
|
#if defined(_STK_DEBUG_)
|
||||||
if ( f.frames() != nFrames_ || f.channels() != nChannels_ ) {
|
if ( f.frames() != nFrames_ || f.channels() != nChannels_ ) {
|
||||||
@@ -538,8 +555,40 @@ inline void StkFrames :: operator*= ( StkFrames& f )
|
|||||||
StkFloat *dptr = data_;
|
StkFloat *dptr = data_;
|
||||||
for ( unsigned int i=0; i<size_; i++ )
|
for ( unsigned int i=0; i<size_; i++ )
|
||||||
*dptr++ *= *fptr++;
|
*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.
|
// Here are a few other useful typedefs.
|
||||||
typedef unsigned short UINT16;
|
typedef unsigned short UINT16;
|
||||||
typedef unsigned int UINT32;
|
typedef unsigned int UINT32;
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ DEFS = @CPPFLAGS@
|
|||||||
DEFS += @byte_order@
|
DEFS += @byte_order@
|
||||||
CFLAGS = @CXXFLAGS@
|
CFLAGS = @CXXFLAGS@
|
||||||
CFLAGS += -I$(INCLUDE) -I$(INCLUDE)/../src/include
|
CFLAGS += -I$(INCLUDE) -I$(INCLUDE)/../src/include
|
||||||
|
LDFLAGS = @LDFLAGS@
|
||||||
LIBRARY = @LIBS@
|
LIBRARY = @LIBS@
|
||||||
|
|
||||||
REALTIME = @realtime@
|
REALTIME = @realtime@
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ DEFS = @CPPFLAGS@
|
|||||||
DEFS += @byte_order@
|
DEFS += @byte_order@
|
||||||
CFLAGS = @CXXFLAGS@
|
CFLAGS = @CXXFLAGS@
|
||||||
CFLAGS += -I$(INCLUDE) -I$(INCLUDE)/../src/include
|
CFLAGS += -I$(INCLUDE) -I$(INCLUDE)/../src/include
|
||||||
|
LDFLAGS = @LDFLAGS@
|
||||||
LIBRARY = @LIBS@
|
LIBRARY = @LIBS@
|
||||||
|
|
||||||
REALTIME = @realtime@
|
REALTIME = @realtime@
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ DEFS = @CPPFLAGS@
|
|||||||
DEFS += @byte_order@
|
DEFS += @byte_order@
|
||||||
CFLAGS = @CXXFLAGS@
|
CFLAGS = @CXXFLAGS@
|
||||||
CFLAGS += -I$(INCLUDE) -I$(INCLUDE)/../src/include
|
CFLAGS += -I$(INCLUDE) -I$(INCLUDE)/../src/include
|
||||||
|
LDFLAGS = @LDFLAGS@
|
||||||
LIBRARY = @LIBS@
|
LIBRARY = @LIBS@
|
||||||
|
|
||||||
REALTIME = @realtime@
|
REALTIME = @realtime@
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ DEFS = @CPPFLAGS@
|
|||||||
DEFS += @byte_order@
|
DEFS += @byte_order@
|
||||||
CFLAGS = @CXXFLAGS@
|
CFLAGS = @CXXFLAGS@
|
||||||
CFLAGS += -I$(INCLUDE) -I$(INCLUDE)/../src/include
|
CFLAGS += -I$(INCLUDE) -I$(INCLUDE)/../src/include
|
||||||
|
LDFLAGS = @LDFLAGS@
|
||||||
LIBRARY = @LIBS@
|
LIBRARY = @LIBS@
|
||||||
|
|
||||||
REALTIME = @realtime@
|
REALTIME = @realtime@
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ DEFS = @CPPFLAGS@
|
|||||||
DEFS += @byte_order@
|
DEFS += @byte_order@
|
||||||
CFLAGS = @CXXFLAGS@
|
CFLAGS = @CXXFLAGS@
|
||||||
CFLAGS += -I$(INCLUDE) -Iinclude
|
CFLAGS += -I$(INCLUDE) -Iinclude
|
||||||
|
LDFLAGS = @LDFLAGS@
|
||||||
LIBRARY = @LIBS@
|
LIBRARY = @LIBS@
|
||||||
|
|
||||||
REALTIME = @realtime@
|
REALTIME = @realtime@
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ DEFS = @CPPFLAGS@
|
|||||||
DEFS += @byte_order@
|
DEFS += @byte_order@
|
||||||
CFLAGS = @CXXFLAGS@
|
CFLAGS = @CXXFLAGS@
|
||||||
CFLAGS += -I$(INCLUDE) -I$(INCLUDE)/../src/include
|
CFLAGS += -I$(INCLUDE) -I$(INCLUDE)/../src/include
|
||||||
|
LDFLAGS = @LDFLAGS@
|
||||||
LIBRARY = @LIBS@
|
LIBRARY = @LIBS@
|
||||||
|
|
||||||
REALTIME = @realtime@
|
REALTIME = @realtime@
|
||||||
|
|||||||
@@ -10,16 +10,18 @@ AR = ar -rsc
|
|||||||
RM = /bin/rm
|
RM = /bin/rm
|
||||||
LN = /bin/ln
|
LN = /bin/ln
|
||||||
OBJECT_PATH = @object_path@
|
OBJECT_PATH = @object_path@
|
||||||
LIBDIR = @libdir@
|
prefix = @prefix@
|
||||||
PREFIX = @prefix@
|
exec_prefix = @exec_prefix@
|
||||||
INCLUDEDIR = @includedir@
|
bindir = @bindir@
|
||||||
|
libdir = @libdir@
|
||||||
|
includedir = @includedir@
|
||||||
vpath %.o $(OBJECT_PATH)
|
vpath %.o $(OBJECT_PATH)
|
||||||
|
|
||||||
OBJECTS = Stk.o Generator.o Noise.o Blit.o BlitSaw.o BlitSquare.o Granulate.o \
|
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 \
|
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 \
|
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 \
|
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 \
|
Effect.o PRCRev.o JCRev.o NRev.o FreeVerb.o \
|
||||||
Chorus.o Echo.o PitShift.o LentPitShift.o \
|
Chorus.o Echo.o PitShift.o LentPitShift.o \
|
||||||
@@ -48,6 +50,7 @@ DEFS = @CPPFLAGS@
|
|||||||
DEFS += @byte_order@
|
DEFS += @byte_order@
|
||||||
CFLAGS = @CXXFLAGS@
|
CFLAGS = @CXXFLAGS@
|
||||||
CFLAGS += $(INCLUDE) -Iinclude -fPIC
|
CFLAGS += $(INCLUDE) -Iinclude -fPIC
|
||||||
|
LDFLAGS = @LDFLAGS@
|
||||||
LIBS = @LIBS@
|
LIBS = @LIBS@
|
||||||
|
|
||||||
REALTIME = @realtime@
|
REALTIME = @realtime@
|
||||||
@@ -93,13 +96,13 @@ $(SHAREDLIB) : $(OBJECTS)
|
|||||||
$(LN) -s @sharedname@ $(SHAREDLIB)
|
$(LN) -s @sharedname@ $(SHAREDLIB)
|
||||||
|
|
||||||
install-headers:
|
install-headers:
|
||||||
install -d $(DESTDIR)$(PREFIX)$(INCLUDEDIR)/stk
|
install -d $(DESTDIR)$(includedir)/stk
|
||||||
cp -R ../include/*.h $(DESTDIR)$(PREFIX)$(INCLUDEDIR)/stk
|
cp -R ../include/*.h $(DESTDIR)$(includedir)/stk
|
||||||
|
|
||||||
install: $(SHAREDLIB) install-headers
|
install: $(SHAREDLIB) install-headers
|
||||||
install -d $(DESTDIR)$(PREFIX)$(LIBDIR)
|
install -d $(DESTDIR)$(libdir)
|
||||||
install -m 644 @sharedname@ $(DESTDIR)$(PREFIX)$(LIBDIR)
|
install -m 644 @sharedname@ $(DESTDIR)$(libdir)
|
||||||
ln -sf @sharedname@ $(DESTDIR)$(PREFIX)$(LIBDIR)/$(SHAREDLIB)
|
ln -sf @sharedname@ $(DESTDIR)$(libdir)/$(SHAREDLIB)
|
||||||
|
|
||||||
|
|
||||||
$(OBJECTS) : Stk.h
|
$(OBJECTS) : Stk.h
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ RtWvOut :: ~RtWvOut( void )
|
|||||||
{
|
{
|
||||||
// Change status flag to signal callback to clear the buffer and close.
|
// Change status flag to signal callback to clear the buffer and close.
|
||||||
status_ = EMPTYING;
|
status_ = EMPTYING;
|
||||||
while ( status_ != FINISHED || dac_.isStreamRunning() == true ) Stk::sleep( 100 );
|
while ( status_ != FINISHED && dac_.isStreamRunning() == true ) Stk::sleep( 100 );
|
||||||
dac_.closeStream();
|
dac_.closeStream();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
24
src/Stk.cpp
24
src/Stk.cpp
@@ -229,7 +229,7 @@ void Stk :: handleError( std::string message, StkError::Type type )
|
|||||||
//
|
//
|
||||||
|
|
||||||
StkFrames :: StkFrames( unsigned int nFrames, unsigned int nChannels )
|
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_;
|
size_ = nFrames_ * nChannels_;
|
||||||
bufferSize_ = size_;
|
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 )
|
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_;
|
size_ = nFrames_ * nChannels_;
|
||||||
bufferSize_ = size_;
|
bufferSize_ = size_;
|
||||||
@@ -266,13 +266,21 @@ StkFrames :: StkFrames( const StkFloat& value, unsigned int nFrames, unsigned in
|
|||||||
dataRate_ = Stk::sampleRate();
|
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()
|
StkFrames :: ~StkFrames()
|
||||||
{
|
{
|
||||||
if ( data_ ) free( data_ );
|
if ( data_ && ownData_ ) free( data_ );
|
||||||
}
|
}
|
||||||
|
|
||||||
StkFrames :: StkFrames( const StkFrames& f )
|
StkFrames :: StkFrames( const StkFrames& f )
|
||||||
: data_(0), size_(0), bufferSize_(0)
|
: data_(0), size_(0), bufferSize_(0), ownData_(true)
|
||||||
{
|
{
|
||||||
resize( f.frames(), f.channels() );
|
resize( f.frames(), f.channels() );
|
||||||
dataRate_ = Stk::sampleRate();
|
dataRate_ = Stk::sampleRate();
|
||||||
@@ -281,7 +289,7 @@ StkFrames :: StkFrames( const StkFrames& f )
|
|||||||
|
|
||||||
StkFrames& StkFrames :: operator= ( const StkFrames& f )
|
StkFrames& StkFrames :: operator= ( const StkFrames& f )
|
||||||
{
|
{
|
||||||
if ( data_ ) free( data_ );
|
if ( data_ && ownData_ ) free( data_ );
|
||||||
data_ = 0;
|
data_ = 0;
|
||||||
size_ = 0;
|
size_ = 0;
|
||||||
bufferSize_ = 0;
|
bufferSize_ = 0;
|
||||||
@@ -298,15 +306,19 @@ void StkFrames :: resize( size_t nFrames, unsigned int nChannels )
|
|||||||
|
|
||||||
size_ = nFrames_ * nChannels_;
|
size_ = nFrames_ * nChannels_;
|
||||||
if ( size_ > bufferSize_ ) {
|
if ( size_ > bufferSize_ ) {
|
||||||
if ( data_ ) free( data_ );
|
if ( data_ && ownData_ ) free( data_ );
|
||||||
data_ = (StkFloat *) malloc( size_ * sizeof( StkFloat ) );
|
data_ = (StkFloat *) malloc( size_ * sizeof( StkFloat ) );
|
||||||
#if defined(_STK_DEBUG_)
|
#if defined(_STK_DEBUG_)
|
||||||
if ( data_ == NULL ) {
|
if ( data_ == NULL ) {
|
||||||
std::string error = "StkFrames::resize: memory allocation error!";
|
std::string error = "StkFrames::resize: memory allocation error!";
|
||||||
Stk::handleError( error, StkError::MEMORY_ALLOCATION );
|
Stk::handleError( error, StkError::MEMORY_ALLOCATION );
|
||||||
}
|
}
|
||||||
|
if ( ownData_ ) {
|
||||||
|
Stk::handleError( "Pointer to external data was lost after resize", StkError::WARNING );
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
bufferSize_ = size_;
|
bufferSize_ = size_;
|
||||||
|
ownData_ = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user