lib/minim/src/ddf/minim/ugens/Sampler.java
// generate one sample frame of data
generate one sample frame of data
generate one sample frame of data
void generate( float[] sampleFrame )
		{
			if ( triggering )
			{
				beginSample  = (int)Math.min( begin.getLastValue(), sampleData.getBufferSize()-2);
				endSample    = (int)Math.min( end.getLastValue(), sampleData.getBufferSize()-1 );
				playbackRate = rate.getLastValue();
				attackLength = (int)Math.max( sampleRate() * attack.getLastValue(), 1.f );
				attackAmp    = 0;
				attackAmpStep = 1.0f / attackLength;
				release		  = 0;
				sample		  = beginSample;
				outSampleCount = 0;
				done		  = false;
				triggering    = false;
			}
			if ( done ) return;
			final float outAmp = amplitude.getLastValue() * attackAmp;
			for( int c = 0; c < sampleFrame.length; ++c )
			{
				int sourceChannel = c < sampleData.getChannelCount() ? c : sampleData.getChannelCount() - 1;
				sampleFrame[c] += outAmp * sampleData.getSample( sourceChannel, sample );
			}
			sample += playbackRate*basePlaybackRate;
			if ( sample > endSample )
			{
				if ( looping ) 
				{
					sample -= endSample - beginSample;
				}
				else 
				{
					done = true;
				}
			}
			++outSampleCount;
			if ( outSampleCount <= attackLength )
			{
				attackAmp += attackAmpStep;
			}
		}
void generate ( float [ ] sampleFrame ) { if ( triggering ) { beginSample = ( int ) Math . min ( begin . getLastValue ( ) , sampleData . getBufferSize ( ) - 2 ) ; endSample = ( int ) Math . min ( end . getLastValue ( ) , sampleData . getBufferSize ( ) - 1 ) ; playbackRate = rate . getLastValue ( ) ; attackLength = ( int ) Math . max ( sampleRate ( ) * attack . getLastValue ( ) , 1.f ) ; attackAmp = 0 ; attackAmpStep = 1.0f / attackLength ; release = 0 ; sample = beginSample ; outSampleCount = 0 ; done = false ; triggering = false ; } if ( done ) return ; final float outAmp = amplitude . getLastValue ( ) * attackAmp ; for ( int c = 0 ; c < sampleFrame . length ; ++ c ) { int sourceChannel = c < sampleData . getChannelCount ( ) ? c : sampleData . getChannelCount ( ) - 1 ; sampleFrame [ c ] += outAmp * sampleData . getSample ( sourceChannel , sample ) ; } sample += playbackRate * basePlaybackRate ; if ( sample > endSample ) { if ( looping ) { sample -= endSample - beginSample ; } else { done = true ; } } ++ outSampleCount ; if ( outSampleCount <= attackLength ) { attackAmp += attackAmpStep ; } }
generate one sample frame of data
generate one sample frame of data