code: public static float gain(float a, float b) {
  /*
  		float p = (float)Math.log(1.0 - b) / (float)Math.log(0.5);
  
  		if (a < .001)
  			return 0.0f;
  		else if (a > .999)
  			return 1.0f;
  		if (a < 0.5)
  			return (float)Math.pow(2 * a, p) / 2;
  		else
  			return 1.0f - (float)Math.pow(2 * (1. - a), p) / 2;
  */
  		float c = (1.0f/b-2.0f) * (1.0f-2.0f*a);
  		if (a < 0.5)
  			return a/(c+1.0f);
  		else
  			return (c-a)/(c-1.0f);
  	}
docs: A variant of the gamma function.
  @param a the number to apply gain to
  @param b the gain parameter. 0.5 means no change, smaller values reduce gain, larger values increase gain.
  @return the output value