question: private void computeDoublesForAllZoomLevels ( ) { int numFrames = mSoundFile . getNumFrames ( ) ; int [ ] frameGains = mSoundFile . getFrameGains ( ) ; double [ ] smoothedGains = new double [ numFrames ] ; if ( numFrames == 1 ) { smoothedGains [ 0 ] = frameGains [ 0 ] ; } else if ( numFrames == 2 ) { smoothedGains [ 0 ] = frameGains [ 0 ] ; smoothedGains [ 1 ] = frameGains [ 1 ] ; } else if ( numFrames > 2 ) { smoothedGains [ 0 ] = ( double ) ( ( frameGains [ 0 ] / 2.0 ) + ( frameGains [ 1 ] / 2.0 ) ) ; for ( int i = 1 ; i < numFrames - 1 ; i ++ ) { smoothedGains [ i ] = ( double ) ( ( frameGains [ i - 1 ] / 3.0 ) + ( frameGains [ i ] / 3.0 ) + ( frameGains [ i + 1 ] / 3.0 ) ) ; } smoothedGains [ numFrames - 1 ] = ( double ) ( ( frameGains [ numFrames - 2 ] / 2.0 ) + ( frameGains [ numFrames - 1 ] / 2.0 ) ) ; } double maxGain = 1.0 ; for ( int i = 0 ; i < numFrames ; i ++ ) { if ( smoothedGains [ i ] > maxGain ) { maxGain = smoothedGains [ i ] ; } } double scaleFactor = 1.0 ; if ( maxGain > 255.0 ) { scaleFactor = 255 / maxGain ; } maxGain = 0 ; int gainHist [ ] = new int [ 256 ] ; for ( int i = 0 ; i < numFrames ; i ++ ) { int smoothedGain = ( int ) ( smoothedGains [ i ] * scaleFactor ) ; if ( smoothedGain < 0 ) smoothedGain = 0 ; if ( smoothedGain > 255 ) smoothedGain = 255 ; if ( smoothedGain > maxGain ) maxGain = smoothedGain ; gainHist [ smoothedGain ] ++ ; } double minGain = 0 ; int sum = 0 ; while ( minGain < 255 && sum < numFrames / 20 ) { sum += gainHist [ ( int ) minGain ] ; minGain ++ ; } sum = 0 ; while ( maxGain > 2 && sum < numFrames / 100 ) { sum += gainHist [ ( int ) maxGain ] ; maxGain -- ; } double [ ] heights = new double [ numFrames ] ; double range = maxGain - minGain ; for ( int i = 0 ; i < numFrames ; i ++ ) { double value = ( smoothedGains [ i ] * scaleFactor - minGain ) / range ; if ( value < 0.0 ) value = 0.0 ; if ( value > 1.0 ) value = 1.0 ; heights [ i ] = value * value ; } algo ( mSoundFile . getNumFrames ( ) ) ; totalZooms = algoValues . size ( ) + 2 ; mNumZoomLevels = totalZooms ; mLenByZoomLevel = new int [ totalZooms ] ; mZoomFactorByZoomLevel = new double [ totalZooms ] ; mValuesByZoomLevel = new double [ totalZooms ] [ ] ; mLenByZoomLevel [ 0 ] = numFrames * 2 ; mZoomFactorByZoomLevel [ 0 ] = 2.0 ; mValuesByZoomLevel [ 0 ] = new double [ mLenByZoomLevel [ 0 ] ] ; if ( numFrames > 0 ) { mValuesByZoomLevel [ 0 ] [ 0 ] = 0.5 * heights [ 0 ] ; mValuesByZoomLevel [ 0 ] [ 1 ] = heights [ 0 ] ; } for ( int i = 1 ; i < numFrames ; i ++ ) { mValuesByZoomLevel [ 0 ] [ 2 * i ] = 0.5 * ( heights [ i - 1 ] + heights [ i ] ) ; mValuesByZoomLevel [ 0 ] [ 2 * i + 1 ] = heights [ i ] ; } mLenByZoomLevel [ 1 ] = numFrames ; mValuesByZoomLevel [ 1 ] = new double [ mLenByZoomLevel [ 1 ] ] ; mZoomFactorByZoomLevel [ 1 ] = 1.0 ; for ( int i = 0 ; i < mLenByZoomLevel [ 1 ] ; i ++ ) { mValuesByZoomLevel [ 1 ] [ i ] = heights [ i ] ; } int location = 0 ; for ( int j = 2 ; j < totalZooms ; j ++ ) { mLenByZoomLevel [ j ] = algoValues . get ( location ) ; mValuesByZoomLevel [ j ] = new double [ mLenByZoomLevel [ j ] ] ; mZoomFactorByZoomLevel [ j ] = mZoomFactorByZoomLevel [ j - 1 ] / 1.5 ; for ( int i = 0 ; i < mLenByZoomLevel [ j ] ; i ++ ) { mValuesByZoomLevel [ j ] [ i ] = 0.5 * ( mValuesByZoomLevel [ j - 1 ] [ ( int ) ( divisorValues . get ( location ) * i ) ] + mValuesByZoomLevel [ j - 1 ] [ ( int ) ( divisorValues . get ( location ) * i ) + 1 ] ) ; } location ++ ; } Log . i ( "Scope" , "Squeezed..!!" ) ; mInitialized = true ; }
target:  Called once when a new sound file is added