mirror of
https://github.com/thestk/stk
synced 2026-01-11 20:11:52 +00:00
add StkFrames::operator+
This commit is contained in:
@@ -303,6 +303,14 @@ public:
|
|||||||
checking is performed unless _STK_DEBUG_ is defined.
|
checking is performed unless _STK_DEBUG_ is defined.
|
||||||
*/
|
*/
|
||||||
StkFloat operator[] ( size_t n ) const;
|
StkFloat operator[] ( size_t n ) const;
|
||||||
|
|
||||||
|
//! Sum operator
|
||||||
|
/*!
|
||||||
|
The dimensions of the argument are expected to be the same as
|
||||||
|
self. No range checking is performed unless _STK_DEBUG_ is
|
||||||
|
defined.
|
||||||
|
*/
|
||||||
|
StkFrames operator+(const StkFrames &frames) const;
|
||||||
|
|
||||||
//! Assignment by sum operator into self.
|
//! Assignment by sum operator into self.
|
||||||
/*!
|
/*!
|
||||||
@@ -469,6 +477,25 @@ inline StkFloat StkFrames :: operator() ( size_t frame, unsigned int channel ) c
|
|||||||
|
|
||||||
return data_[ frame * nChannels_ + channel ];
|
return data_[ frame * nChannels_ + channel ];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline StkFrames StkFrames::operator+(const StkFrames &f) const
|
||||||
|
{
|
||||||
|
#if defined(_STK_DEBUG_)
|
||||||
|
if ( f.frames() != nFrames_ || f.channels() != nChannels_ ) {
|
||||||
|
std::ostringstream error;
|
||||||
|
error << "StkFrames::operator+: frames argument must be of equal dimensions!";
|
||||||
|
Stk::handleError( error.str(), StkError::MEMORY_ACCESS );
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
StkFrames sum(nFrames_,nChannels_);
|
||||||
|
StkFloat *sumPtr = &sum[0];
|
||||||
|
const StkFloat *fptr = f.data_;
|
||||||
|
const StkFloat *dPtr = data_;
|
||||||
|
for (unsigned int i = 0; i < size_; i++) {
|
||||||
|
*sumPtr++ = *fptr++ + *dPtr++;
|
||||||
|
}
|
||||||
|
return sum;
|
||||||
|
}
|
||||||
|
|
||||||
inline void StkFrames :: operator+= ( StkFrames& f )
|
inline void StkFrames :: operator+= ( StkFrames& f )
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user