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:
Gary Scavone
2017-05-03 16:15:42 -04:00
parent 9966f06757
commit 9627701d04
4 changed files with 42 additions and 27 deletions

View File

@@ -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.

View File

@@ -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.