mirror of
https://github.com/thestk/stk
synced 2026-01-11 20:11:52 +00:00
Added optional argument to FileWvIn and FileLoop to distinguish int-to-float scaling from data normalization. The default values should produce the same behaviour as before.
This commit is contained in:
@@ -28,10 +28,11 @@ FileLoop :: FileLoop( unsigned long chunkThreshold, unsigned long chunkSize )
|
||||
}
|
||||
|
||||
FileLoop :: FileLoop( std::string fileName, bool raw, bool doNormalize,
|
||||
unsigned long chunkThreshold, unsigned long chunkSize )
|
||||
unsigned long chunkThreshold, unsigned long chunkSize,
|
||||
bool doInt2FloatScaling )
|
||||
: FileWvIn( chunkThreshold, chunkSize ), phaseOffset_(0.0)
|
||||
{
|
||||
this->openFile( fileName, raw, doNormalize );
|
||||
this->openFile( fileName, raw, doNormalize, doInt2FloatScaling );
|
||||
Stk::addSampleRateAlert( this );
|
||||
}
|
||||
|
||||
@@ -40,7 +41,7 @@ FileLoop :: ~FileLoop( void )
|
||||
Stk::removeSampleRateAlert( this );
|
||||
}
|
||||
|
||||
void FileLoop :: openFile( std::string fileName, bool raw, bool doNormalize )
|
||||
void FileLoop :: openFile( std::string fileName, bool raw, bool doNormalize, bool doInt2FloatScaling )
|
||||
{
|
||||
// Call close() in case another file is already open.
|
||||
this->closeFile();
|
||||
@@ -53,8 +54,8 @@ void FileLoop :: openFile( std::string fileName, bool raw, bool doNormalize )
|
||||
chunking_ = true;
|
||||
chunkPointer_ = 0;
|
||||
data_.resize( chunkSize_ + 1, file_.channels() );
|
||||
if ( doNormalize ) normalizing_ = true;
|
||||
else normalizing_ = false;
|
||||
if ( doInt2FloatScaling ) int2floatscaling_ = true;
|
||||
else int2floatscaling_ = false;
|
||||
}
|
||||
else {
|
||||
chunking_ = false;
|
||||
@@ -171,7 +172,7 @@ StkFloat FileLoop :: tick( unsigned int channel )
|
||||
}
|
||||
|
||||
// Load more data.
|
||||
file_.read( data_, chunkPointer_, normalizing_ );
|
||||
file_.read( data_, chunkPointer_, int2floatscaling_ );
|
||||
}
|
||||
|
||||
// Adjust index for the current buffer.
|
||||
|
||||
@@ -44,11 +44,11 @@ FileWvIn :: FileWvIn( unsigned long chunkThreshold, unsigned long chunkSize )
|
||||
}
|
||||
|
||||
FileWvIn :: FileWvIn( std::string fileName, bool raw, bool doNormalize,
|
||||
unsigned long chunkThreshold, unsigned long chunkSize )
|
||||
unsigned long chunkThreshold, unsigned long chunkSize, bool doInt2FloatScaling )
|
||||
: finished_(true), interpolate_(false), time_(0.0), rate_(0.0),
|
||||
chunkThreshold_(chunkThreshold), chunkSize_(chunkSize)
|
||||
{
|
||||
openFile( fileName, raw, doNormalize );
|
||||
openFile( fileName, raw, doNormalize, doInt2FloatScaling );
|
||||
Stk::addSampleRateAlert( this );
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ void FileWvIn :: closeFile( void )
|
||||
lastFrame_.resize( 0, 0 );
|
||||
}
|
||||
|
||||
void FileWvIn :: openFile( std::string fileName, bool raw, bool doNormalize )
|
||||
void FileWvIn :: openFile( std::string fileName, bool raw, bool doNormalize, bool doInt2FloatScaling )
|
||||
{
|
||||
// Call close() in case another file is already open.
|
||||
this->closeFile();
|
||||
@@ -84,8 +84,8 @@ void FileWvIn :: openFile( std::string fileName, bool raw, bool doNormalize )
|
||||
chunking_ = true;
|
||||
chunkPointer_ = 0;
|
||||
data_.resize( chunkSize_, file_.channels() );
|
||||
if ( doNormalize ) normalizing_ = true;
|
||||
else normalizing_ = false;
|
||||
if ( doInt2FloatScaling ) int2floatscaling_ = true;
|
||||
else int2floatscaling_ = false;
|
||||
}
|
||||
else {
|
||||
chunking_ = false;
|
||||
@@ -204,7 +204,7 @@ StkFloat FileWvIn :: tick( unsigned int channel )
|
||||
}
|
||||
|
||||
// Load more data.
|
||||
file_.read( data_, chunkPointer_, normalizing_ );
|
||||
file_.read( data_, chunkPointer_, int2floatscaling_ );
|
||||
}
|
||||
|
||||
// Adjust index for the current buffer.
|
||||
|
||||
Reference in New Issue
Block a user