src/codeandchords/ModuleMenu.java
protected int[] applyThresholdSBModulate(float curAmp, int inputNum, int colorPos)
	{
		// Error checking:
		if(colorPos < 0 || colorPos >= this.colorSelect.length) {
			throw new IllegalArgumentException("ModuleTemplate.applyThresholdSBModulate: int parameter colorPos is " + colorPos + 
					", which is out of bounds; must be between 0 and " + (this.colorSelect.length - 1));
		}

		// Converts the current amplitude into a number between 0 and 100,
		// depending on where curAmp is in relation to the saturation or brightness forte threshold:
		float	satMappingVal		= Math.max(Math.min(PApplet.map(curAmp, 0, Math.max(this.satBrightThresholdVals[inputNum][0], this.minThreshold + 1), 0, 100), 100), 0);
		float	brightMappingVal	= Math.max(Math.min(PApplet.map(curAmp, 0, Math.max(this.satBrightThresholdVals[inputNum][1], this.minThreshold + 1), 0, 100), 100), 0);


		// Notice how hueSatBrightPercentMod is accessed at 1 and 2, since hue is also a part of it,
		// but satBrightPercentVals is accessed at 0 and 1, since it is only for saturation and brightness.
		this.hueSatBrightPercentMod[1]	= (this.satBrightPercentVals[inputNum][0] * satMappingVal) / 100;
		this.hueSatBrightPercentMod[2]	= (this.satBrightPercentVals[inputNum][1] * brightMappingVal) / 100;

		float[] hsb = new float[3];

		// Converts this position of hsbColors from RGB to HSB:
		Color.RGBtoHSB(this.hsbColors[inputNum][colorPos][0], this.hsbColors[inputNum][colorPos][1], this.hsbColors[inputNum][colorPos][2], hsb);

		for(int j = 0; j < this.hueSatBrightPercentMod.length; j++)
		{
			if(this.hueSatBrightPercentMod[j] <= 0)
			{
				if(j == 0) {
					hsb[0] = (hsb[0] + this.hueSatBrightnessMod[0] + this.hueSatBrightPercentMod[0] + 1) % 1;
				} else {

					hsb[j] = Math.max(Math.min(hsb[j] + this.hueSatBrightnessMod[j] + this.hueSatBrightPercentMod[j], 1), 0);
				}  // if/else - == 0
			} // if percent greater than 0
			else
			{
				if(j == 0) {
					hsb[j] = (hsb[j] + this.hueSatBrightnessMod[j] + this.hueSatBrightPercentMod[j] + 1) % 1;
				} else {
					hsb[j] = Math.max(Math.min(this.hueSatBrightnessMod[j] + this.hueSatBrightPercentMod[j], 1), 0);
				}  // if/else - == 0

			} // else - percent less than 0
		} // for - hueSatBrightPercentMod

		// Converts the color back to RGB:
		int oc = Color.HSBtoRGB(hsb[0], hsb[1],  hsb[2]);
		Color a = new Color(oc);

		return new int[] { a.getRed(), a.getGreen(), a.getBlue() };
	}
/**
	 * Applies the values of the threshold saturation and brightness Sliders 
	 * to the color of the ColorWheel at the given position and returns the affected color.
	 * 
	 * @param curAmp	the current amplitude
	 * @param colorPos	the position in this.colorSelect to which the sat/brightness should be applied
	 * @return			the color with saturation and brightness adjustments
	 */
Applies the values of the threshold saturation and brightness Sliders
to the color of the ColorWheel at the given position and returns the affected color.

@param curAmp        the current amplitude
@param colorPos      the position in this.colorSelect to which the sat/brightness should be applied
@return                      the color with saturation and brightness adjustments
Applies the values of the threshold saturation and brightness Sliders to the color of the ColorWheel at the given position and returns the affected color . @param curAmp the current amplitude @param colorPos the position in this . colorSelect to which the sat / brightness should be applied @return the color with saturation and brightness adjustments
protected int[] applyThresholdSBModulate(float curAmp, int inputNum, int colorPos)
	{
		if(colorPos < 0 || colorPos >= this.colorSelect.length) {
			throw new IllegalArgumentException("ModuleTemplate.applyThresholdSBModulate: int parameter colorPos is " + colorPos + 
					", which is out of bounds; must be between 0 and " + (this.colorSelect.length - 1));
		}
		float	satMappingVal		= Math.max(Math.min(PApplet.map(curAmp, 0, Math.max(this.satBrightThresholdVals[inputNum][0], this.minThreshold + 1), 0, 100), 100), 0);
		float	brightMappingVal	= Math.max(Math.min(PApplet.map(curAmp, 0, Math.max(this.satBrightThresholdVals[inputNum][1], this.minThreshold + 1), 0, 100), 100), 0);
		this.hueSatBrightPercentMod[1]	= (this.satBrightPercentVals[inputNum][0] * satMappingVal) / 100;
		this.hueSatBrightPercentMod[2]	= (this.satBrightPercentVals[inputNum][1] * brightMappingVal) / 100;
		float[] hsb = new float[3];
		Color.RGBtoHSB(this.hsbColors[inputNum][colorPos][0], this.hsbColors[inputNum][colorPos][1], this.hsbColors[inputNum][colorPos][2], hsb);
		for(int j = 0; j < this.hueSatBrightPercentMod.length; j++)
		{
			if(this.hueSatBrightPercentMod[j] <= 0)
			{
				if(j == 0) {
					hsb[0] = (hsb[0] + this.hueSatBrightnessMod[0] + this.hueSatBrightPercentMod[0] + 1) % 1;
				} else {
					hsb[j] = Math.max(Math.min(hsb[j] + this.hueSatBrightnessMod[j] + this.hueSatBrightPercentMod[j], 1), 0);
				}  
			} 
			else
			{
				if(j == 0) {
					hsb[j] = (hsb[j] + this.hueSatBrightnessMod[j] + this.hueSatBrightPercentMod[j] + 1) % 1;
				} else {
					hsb[j] = Math.max(Math.min(this.hueSatBrightnessMod[j] + this.hueSatBrightPercentMod[j], 1), 0);
				}  
			} 
		} 
		int oc = Color.HSBtoRGB(hsb[0], hsb[1],  hsb[2]);
		Color a = new Color(oc);
		return new int[] { a.getRed(), a.getGreen(), a.getBlue() };
	}
protected int [ ] applyThresholdSBModulate ( float curAmp , int inputNum , int colorPos ) { if ( colorPos < 0 || colorPos >= this . colorSelect . length ) { throw new IllegalArgumentException ( "ModuleTemplate.applyThresholdSBModulate: int parameter colorPos is " + colorPos + ", which is out of bounds; must be between 0 and " + ( this . colorSelect . length - 1 ) ) ; } float satMappingVal = Math . max ( Math . min ( PApplet . map ( curAmp , 0 , Math . max ( this . satBrightThresholdVals [ inputNum ] [ 0 ] , this . minThreshold + 1 ) , 0 , 100 ) , 100 ) , 0 ) ; float brightMappingVal = Math . max ( Math . min ( PApplet . map ( curAmp , 0 , Math . max ( this . satBrightThresholdVals [ inputNum ] [ 1 ] , this . minThreshold + 1 ) , 0 , 100 ) , 100 ) , 0 ) ; this . hueSatBrightPercentMod [ 1 ] = ( this . satBrightPercentVals [ inputNum ] [ 0 ] * satMappingVal ) / 100 ; this . hueSatBrightPercentMod [ 2 ] = ( this . satBrightPercentVals [ inputNum ] [ 1 ] * brightMappingVal ) / 100 ; float [ ] hsb = new float [ 3 ] ; Color . RGBtoHSB ( this . hsbColors [ inputNum ] [ colorPos ] [ 0 ] , this . hsbColors [ inputNum ] [ colorPos ] [ 1 ] , this . hsbColors [ inputNum ] [ colorPos ] [ 2 ] , hsb ) ; for ( int j = 0 ; j < this . hueSatBrightPercentMod . length ; j ++ ) { if ( this . hueSatBrightPercentMod [ j ] <= 0 ) { if ( j == 0 ) { hsb [ 0 ] = ( hsb [ 0 ] + this . hueSatBrightnessMod [ 0 ] + this . hueSatBrightPercentMod [ 0 ] + 1 ) % 1 ; } else { hsb [ j ] = Math . max ( Math . min ( hsb [ j ] + this . hueSatBrightnessMod [ j ] + this . hueSatBrightPercentMod [ j ] , 1 ) , 0 ) ; } } else { if ( j == 0 ) { hsb [ j ] = ( hsb [ j ] + this . hueSatBrightnessMod [ j ] + this . hueSatBrightPercentMod [ j ] + 1 ) % 1 ; } else { hsb [ j ] = Math . max ( Math . min ( this . hueSatBrightnessMod [ j ] + this . hueSatBrightPercentMod [ j ] , 1 ) , 0 ) ; } } } int oc = Color . HSBtoRGB ( hsb [ 0 ] , hsb [ 1 ] , hsb [ 2 ] ) ; Color a = new Color ( oc ) ; return new int [ ] { a . getRed ( ) , a . getGreen ( ) , a . getBlue ( ) } ; }
Applies the values of the threshold saturation and brightness Sliders
 to the color of the ColorWheel at the given position and returns the affected color.
Applies the values of the threshold saturation and brightness Sliders to the color of the ColorWheel at the given position and returns the affected color .
// Error checking: // Converts the current amplitude into a number between 0 and 100, // depending on where curAmp is in relation to the saturation or brightness forte threshold: // Notice how hueSatBrightPercentMod is accessed at 1 and 2, since hue is also a part of it, // but satBrightPercentVals is accessed at 0 and 1, since it is only for saturation and brightness. // Converts this position of hsbColors from RGB to HSB: // if/else - == 0 // if percent greater than 0 // if/else - == 0 // else - percent less than 0 // for - hueSatBrightPercentMod // Converts the color back to RGB: