mirror of
https://github.com/thestk/stk
synced 2026-04-19 22:16:54 +00:00
Merge pull request #17 from arielelkin/fix-variable-types-in-Granulate
Fix variable types in Granulate
This commit is contained in:
@@ -106,10 +106,11 @@ void Granulate :: reset( void )
|
|||||||
gPointer_ = 0;
|
gPointer_ = 0;
|
||||||
|
|
||||||
// Reset grain parameters.
|
// Reset grain parameters.
|
||||||
unsigned int count, nVoices = grains_.size();
|
size_t count;
|
||||||
|
size_t nVoices = (unsigned int)grains_.size();
|
||||||
for ( unsigned int i=0; i<grains_.size(); i++ ) {
|
for ( unsigned int i=0; i<grains_.size(); i++ ) {
|
||||||
grains_[i].repeats = 0;
|
grains_[i].repeats = 0;
|
||||||
count = (unsigned int ) ( i * gDuration_ * 0.001 * Stk::sampleRate() / nVoices );
|
count = ( i * gDuration_ * 0.001 * Stk::sampleRate() / nVoices );
|
||||||
grains_[i].counter = count;
|
grains_[i].counter = count;
|
||||||
grains_[i].state = GRAIN_STOPPED;
|
grains_[i].state = GRAIN_STOPPED;
|
||||||
}
|
}
|
||||||
@@ -126,14 +127,14 @@ void Granulate :: setVoices( unsigned int nVoices )
|
|||||||
handleError( message.str(), StkError::DEBUG_PRINT );
|
handleError( message.str(), StkError::DEBUG_PRINT );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
unsigned int oldSize = grains_.size();
|
size_t oldSize = grains_.size();
|
||||||
grains_.resize( nVoices );
|
grains_.resize( nVoices );
|
||||||
|
|
||||||
// Initialize new grain voices.
|
// Initialize new grain voices.
|
||||||
unsigned int count;
|
size_t count;
|
||||||
for ( unsigned int i=oldSize; i<nVoices; i++ ) {
|
for ( size_t i=oldSize; i<nVoices; i++ ) {
|
||||||
grains_[i].repeats = 0;
|
grains_[i].repeats = 0;
|
||||||
count = (unsigned int ) ( i * gDuration_ * 0.001 * Stk::sampleRate() / nVoices );
|
count = ( i * gDuration_ * 0.001 * Stk::sampleRate() / nVoices );
|
||||||
grains_[i].counter = count;
|
grains_[i].counter = count;
|
||||||
grains_[i].pointer = gPointer_;
|
grains_[i].pointer = gPointer_;
|
||||||
grains_[i].state = GRAIN_STOPPED;
|
grains_[i].state = GRAIN_STOPPED;
|
||||||
@@ -163,7 +164,7 @@ void Granulate :: calculateGrain( Granulate::Grain& grain )
|
|||||||
// Calculate duration and envelope parameters.
|
// Calculate duration and envelope parameters.
|
||||||
StkFloat seconds = gDuration_ * 0.001;
|
StkFloat seconds = gDuration_ * 0.001;
|
||||||
seconds += ( seconds * gRandomFactor_ * noise.tick() );
|
seconds += ( seconds * gRandomFactor_ * noise.tick() );
|
||||||
unsigned int count = (unsigned long) ( seconds * Stk::sampleRate() );
|
unsigned long count = (unsigned long) ( seconds * Stk::sampleRate() );
|
||||||
grain.attackCount = (unsigned int) ( gRampPercent_ * 0.005 * count );
|
grain.attackCount = (unsigned int) ( gRampPercent_ * 0.005 * count );
|
||||||
grain.decayCount = grain.attackCount;
|
grain.decayCount = grain.attackCount;
|
||||||
grain.sustainCount = count - 2 * grain.attackCount;
|
grain.sustainCount = count - 2 * grain.attackCount;
|
||||||
|
|||||||
Reference in New Issue
Block a user