mirror of
https://github.com/thestk/stk
synced 2026-04-23 07:48:36 +00:00
add channel arg to WvIn::tick
StkFrames& tick( StkFrames& frames ) ` is now StkFrames& tick( StkFrames& frames, unsigned int channel = 0 )` . same applies to FIleLoop and FileWvIn
This commit is contained in:
@@ -140,17 +140,15 @@ class FileLoop : protected FileWvIn
|
|||||||
*/
|
*/
|
||||||
StkFloat tick( unsigned int channel = 0 );
|
StkFloat tick( unsigned int channel = 0 );
|
||||||
|
|
||||||
//! Fill the StkFrames argument with computed frames and return the same reference.
|
//! Fill the StkFrames object with computed sample frames, starting at the specified channel and return the same reference.
|
||||||
/*!
|
/*!
|
||||||
The number of channels in the StkFrames argument should equal
|
The \c channel argument plus the number of output channels must
|
||||||
the number of channels in the file data. However, this is only
|
be less than the number of channels in the StkFrames argument (the
|
||||||
checked if _STK_DEBUG_ is defined during compilation, in which
|
first channel is specified by 0). However, range checking is only
|
||||||
case an incompatibility will trigger an StkError exception. If no
|
performed if _STK_DEBUG_ is defined during compilation, in which
|
||||||
file data is loaded, the function does nothing (a warning will be
|
case an out-of-range value will trigger an StkError exception.
|
||||||
issued if _STK_DEBUG_ is defined during compilation and
|
|
||||||
Stk::showWarnings() has been set to \e true).
|
|
||||||
*/
|
*/
|
||||||
StkFrames& tick( StkFrames& frames );
|
virtual StkFrames& tick( StkFrames& frames,unsigned int channel = 0 );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
|||||||
@@ -150,16 +150,15 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual StkFloat tick( unsigned int channel = 0 );
|
virtual StkFloat tick( unsigned int channel = 0 );
|
||||||
|
|
||||||
//! Fill the StkFrames argument with computed frames and return the same reference.
|
//! Fill the StkFrames object with computed sample frames, starting at the specified channel and return the same reference.
|
||||||
/*!
|
/*!
|
||||||
The number of channels in the StkFrames argument must equal
|
The \c channel argument plus the number of output channels must
|
||||||
the number of channels in the file data. However, this is only
|
be less than the number of channels in the StkFrames argument (the
|
||||||
checked if _STK_DEBUG_ is defined during compilation, in which
|
first channel is specified by 0). However, range checking is only
|
||||||
case an incompatibility will trigger an StkError exception. If no
|
performed if _STK_DEBUG_ is defined during compilation, in which
|
||||||
file data is loaded, the function does nothing (a warning will be
|
case an out-of-range value will trigger an StkError exception.
|
||||||
issued if _STK_DEBUG_ is defined during compilation).
|
|
||||||
*/
|
*/
|
||||||
virtual StkFrames& tick( StkFrames& frames );
|
virtual StkFrames& tick( StkFrames& frames,unsigned int channel = 0 );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
|||||||
@@ -31,8 +31,8 @@ public:
|
|||||||
//! Compute one sample frame and return the specified \c channel value.
|
//! Compute one sample frame and return the specified \c channel value.
|
||||||
virtual StkFloat tick( unsigned int channel = 0 ) = 0;
|
virtual StkFloat tick( unsigned int channel = 0 ) = 0;
|
||||||
|
|
||||||
//! Fill the StkFrames argument with computed frames and return the same reference.
|
//! Fill the StkFrames object with computed sample frames, starting at the specified channel and return the same reference.
|
||||||
virtual StkFrames& tick( StkFrames& frames ) = 0;
|
virtual StkFrames& tick( StkFrames& frames, unsigned int channel = 0 ) = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
|||||||
@@ -193,32 +193,39 @@ StkFloat FileLoop :: tick( unsigned int channel )
|
|||||||
return lastFrame_[channel];
|
return lastFrame_[channel];
|
||||||
}
|
}
|
||||||
|
|
||||||
StkFrames& FileLoop :: tick( StkFrames& frames )
|
StkFrames& FileLoop :: tick( StkFrames& frames, unsigned int channel)
|
||||||
{
|
{
|
||||||
if ( !file_.isOpen() ) {
|
if ( !file_.isOpen() ) {
|
||||||
#if defined(_STK_DEBUG_)
|
#if defined(_STK_DEBUG_)
|
||||||
oStream_ << "FileLoop::tick(): no file data is loaded!";
|
oStream_ << "FileLoop::tick(): no file data is loaded!";
|
||||||
handleError( StkError::WARNING );
|
handleError( StkError::DEBUG_PRINT );
|
||||||
#endif
|
#endif
|
||||||
return frames;
|
return frames;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int nChannels = lastFrame_.channels();
|
unsigned int nChannels = lastFrame_.channels();
|
||||||
#if defined(_STK_DEBUG_)
|
#if defined(_STK_DEBUG_)
|
||||||
if ( nChannels != frames.channels() ) {
|
if ( channel > frames.channels() - nChannels ) {
|
||||||
oStream_ << "FileLoop::tick(): StkFrames argument is incompatible with file data!";
|
oStream_ << "FileLoop::tick(): channel and StkFrames arguments are incompatible!";
|
||||||
handleError( StkError::FUNCTION_ARGUMENT );
|
handleError( StkError::FUNCTION_ARGUMENT );
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
unsigned int j, counter = 0;
|
StkFloat *samples = &frames[channel];
|
||||||
for ( unsigned int i=0; i<frames.frames(); i++ ) {
|
unsigned int j, hop = frames.channels() - nChannels;
|
||||||
this->tick();
|
if ( nChannels == 1 ) {
|
||||||
for ( j=0; j<nChannels; j++ )
|
for ( unsigned int i=0; i<frames.frames(); i++, samples += hop )
|
||||||
frames[counter++] = lastFrame_[j];
|
*samples++ = tick();
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
for ( unsigned int i=0; i<frames.frames(); i++, samples += hop ) {
|
||||||
|
*samples++ = tick();
|
||||||
|
for ( j=1; j<nChannels; j++ )
|
||||||
|
*samples++ = lastFrame_[j];
|
||||||
|
}
|
||||||
|
}
|
||||||
return frames;
|
return frames;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // stk namespace
|
} // stk namespace
|
||||||
|
|||||||
@@ -222,7 +222,7 @@ StkFloat FileWvIn :: tick( unsigned int channel )
|
|||||||
return lastFrame_[channel];
|
return lastFrame_[channel];
|
||||||
}
|
}
|
||||||
|
|
||||||
StkFrames& FileWvIn :: tick( StkFrames& frames )
|
StkFrames& FileWvIn :: tick( StkFrames& frames, unsigned int channel)
|
||||||
{
|
{
|
||||||
if ( !file_.isOpen() ) {
|
if ( !file_.isOpen() ) {
|
||||||
#if defined(_STK_DEBUG_)
|
#if defined(_STK_DEBUG_)
|
||||||
@@ -234,20 +234,27 @@ StkFrames& FileWvIn :: tick( StkFrames& frames )
|
|||||||
|
|
||||||
unsigned int nChannels = lastFrame_.channels();
|
unsigned int nChannels = lastFrame_.channels();
|
||||||
#if defined(_STK_DEBUG_)
|
#if defined(_STK_DEBUG_)
|
||||||
if ( nChannels != frames.channels() ) {
|
if ( channel > frames.channels() - nChannels ) {
|
||||||
oStream_ << "FileWvIn::tick(): StkFrames argument is incompatible with file data!";
|
oStream_ << "FileWvIn::tick(): channel and StkFrames arguments are incompatible!";
|
||||||
handleError( StkError::FUNCTION_ARGUMENT );
|
handleError( StkError::FUNCTION_ARGUMENT );
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
unsigned int j, counter = 0;
|
StkFloat *samples = &frames[channel];
|
||||||
for ( unsigned int i=0; i<frames.frames(); i++ ) {
|
unsigned int j, hop = frames.channels() - nChannels;
|
||||||
this->tick();
|
if ( nChannels == 1 ) {
|
||||||
for ( j=0; j<nChannels; j++ )
|
for ( unsigned int i=0; i<frames.frames(); i++, samples += hop )
|
||||||
frames[counter++] = lastFrame_[j];
|
*samples++ = tick();
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
for ( unsigned int i=0; i<frames.frames(); i++, samples += hop ) {
|
||||||
|
*samples++ = tick();
|
||||||
|
for ( j=1; j<nChannels; j++ )
|
||||||
|
*samples++ = lastFrame_[j];
|
||||||
|
}
|
||||||
|
}
|
||||||
return frames;
|
return frames;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // stk namespace
|
} // stk namespace
|
||||||
|
|||||||
Reference in New Issue
Block a user