ADSR fix for decay/release time calculations; FileRead variable size fixes and argument check.

This commit is contained in:
Gary Scavone
2014-03-12 13:27:05 -04:00
parent 1874c0efa9
commit 0e7077c0f3
2 changed files with 9 additions and 4 deletions

View File

@@ -149,8 +149,8 @@ void ADSR :: setReleaseTime( StkFloat time )
void ADSR :: setAllTimes( StkFloat aTime, StkFloat dTime, StkFloat sLevel, StkFloat rTime )
{
this->setAttackTime( aTime );
this->setDecayTime( dTime );
this->setSustainLevel( sLevel );
this->setDecayTime( dTime );
this->setReleaseTime( rTime );
}

View File

@@ -571,7 +571,7 @@ bool FileRead :: getMatInfo( const char *fileName )
bool doneParsing, haveData, haveSampleRate;
SINT32 chunkSize, rows, columns, nametype;
int dataoffset;
long dataoffset;
doneParsing = false;
haveData = false;
haveSampleRate = false;
@@ -734,7 +734,7 @@ void FileRead :: read( StkFrames& buffer, unsigned long startFrame, bool doNorma
}
// Check the buffer size.
unsigned int nFrames = buffer.frames();
unsigned long nFrames = buffer.frames();
if ( nFrames == 0 ) {
oStream_ << "FileRead::read: StkFrames buffer size is zero ... no data read!";
Stk::handleError( StkError::WARNING ); return;
@@ -745,8 +745,13 @@ void FileRead :: read( StkFrames& buffer, unsigned long startFrame, bool doNorma
Stk::handleError( StkError::FUNCTION_ARGUMENT );
}
if ( startFrame >= fileSize_ ) {
oStream_ << "FileRead::read: startFrame argument is greater than or equal to the file size!";
Stk::handleError( StkError::FUNCTION_ARGUMENT );
}
// Check for file end.
if ( startFrame + nFrames >= fileSize_ )
if ( startFrame + nFrames > fileSize_ )
nFrames = fileSize_ - startFrame;
long i, nSamples = (long) ( nFrames * channels_ );