src/codeandchords/Instrument.java
public void playNote(Note note) throws InterruptedException
	{
		if(note == null)
		{
			throw new IllegalArgumentException("Instrument.playNote: Note parameter is null.");
		}
		
		float	sustainAmp;
		float	sustainTime;
		
		sustainAmp	= (note.getAmplitude() * this.sustain / 100);
		sustainTime	= Math.max(note.getDuration() - this.attack - this.decay, 0);
		
		/*
		 * AD envelopes rise from 0.0 to
		 * 1.0 over a length of time called the Attack. Then they fall back to 0.0 over a
		length of time called the Decay. ADSR envelopes rise to 1 during the
		attack, then fall to a sustain value, where they stay until the event ends,
		and the value falls to 0 over a time called the Release." - Sonifying Processing, p. 31
		 */

		if(!(note.isRest()))
		{
			this.gainEnvelope.clear();
			this.gainEnvelope.addSegment(0, 10);
			//this.gainEnvelope.pause(true);
			//this.gainEnvelope.setValue(0);
		}

		// Attack:
		this.gainEnvelope.addSegment(note.getAmplitude(), this.attack);
		// Decay:
		this.gainEnvelope.addSegment(sustainAmp, this.decay);

		// Sustain (amplitude doesn't change):
		this.gainEnvelope.addSegment(sustainAmp, sustainTime);

		// Release:
		this.gainEnvelope.addSegment(0, this.release);

		//		this.wavePlayer.setFrequency(Pitch.mtof(note.getMidiNum()));

		// Treat -1 like a rest:
		if(note.getMidiNum() != -1)
		{
			this.wavePlayer.pause(false);
			this.gainEnvelope.pause(false);
			this.frequencyGlide.setValue(Pitch.mtof(note.getMidiNum()));
//			System.out.println("Instrument.playNote: " + Pitch.mtof(note.getMidiNum()));
		} else {
//			System.out.println("1/8th rest");
		} // if

	}
/**
	 * Sets the attack, decay, sustain, and release envelopes,
	 * then either pauses the WavePlayer (for rests) or sets it to the 
	 * frequency of the given Note.
	 * 
	 * @param note	Note whose midiNote is turned into a frequency and used to play it.
	 * @throws InterruptedException 
	 */
Sets the attack, decay, sustain, and release envelopes,
then either pauses the WavePlayer (for rests) or sets it to the
frequency of the given Note.

@param note  Note whose midiNote is turned into a frequency and used to play it.
Sets the attack decay sustain and release envelopes then either pauses the WavePlayer ( for rests ) or sets it to the frequency of the given Note . @param note Note whose midiNote is turned into a frequency and used to play it .
public void playNote(Note note) throws InterruptedException
	{
		if(note == null)
		{
			throw new IllegalArgumentException("Instrument.playNote: Note parameter is null.");
		}
		float	sustainAmp;
		float	sustainTime;
		sustainAmp	= (note.getAmplitude() * this.sustain / 100);
		sustainTime	= Math.max(note.getDuration() - this.attack - this.decay, 0);
		/*
		 * AD envelopes rise from 0.0 to
		 * 1.0 over a length of time called the Attack. Then they fall back to 0.0 over a
		length of time called the Decay. ADSR envelopes rise to 1 during the
		attack, then fall to a sustain value, where they stay until the event ends,
		and the value falls to 0 over a time called the Release." - Sonifying Processing, p. 31
		 */
		if(!(note.isRest()))
		{
			this.gainEnvelope.clear();
			this.gainEnvelope.addSegment(0, 10);
		}
		this.gainEnvelope.addSegment(note.getAmplitude(), this.attack);
		this.gainEnvelope.addSegment(sustainAmp, this.decay);
		this.gainEnvelope.addSegment(sustainAmp, sustainTime);
		this.gainEnvelope.addSegment(0, this.release);
		if(note.getMidiNum() != -1)
		{
			this.wavePlayer.pause(false);
			this.gainEnvelope.pause(false);
			this.frequencyGlide.setValue(Pitch.mtof(note.getMidiNum()));
		} else {
		} 
	}
public void playNote ( Note note ) throws InterruptedException { if ( note == null ) { throw new IllegalArgumentException ( "Instrument.playNote: Note parameter is null." ) ; } float sustainAmp ; float sustainTime ; sustainAmp = ( note . getAmplitude ( ) * this . sustain / 100 ) ; sustainTime = Math . max ( note . getDuration ( ) - this . attack - this . decay , 0 ) ; /*
		 * AD envelopes rise from 0.0 to
		 * 1.0 over a length of time called the Attack. Then they fall back to 0.0 over a
		length of time called the Decay. ADSR envelopes rise to 1 during the
		attack, then fall to a sustain value, where they stay until the event ends,
		and the value falls to 0 over a time called the Release." - Sonifying Processing, p. 31
		 */ if ( ! ( note . isRest ( ) ) ) { this . gainEnvelope . clear ( ) ; this . gainEnvelope . addSegment ( 0 , 10 ) ; } this . gainEnvelope . addSegment ( note . getAmplitude ( ) , this . attack ) ; this . gainEnvelope . addSegment ( sustainAmp , this . decay ) ; this . gainEnvelope . addSegment ( sustainAmp , sustainTime ) ; this . gainEnvelope . addSegment ( 0 , this . release ) ; if ( note . getMidiNum ( ) != - 1 ) { this . wavePlayer . pause ( false ) ; this . gainEnvelope . pause ( false ) ; this . frequencyGlide . setValue ( Pitch . mtof ( note . getMidiNum ( ) ) ) ; } else { } }
Sets the attack, decay, sustain, and release envelopes,
 then either pauses the WavePlayer (for rests) or sets it to the
 frequency of the given Note.
Sets the attack decay sustain and release envelopes then either pauses the WavePlayer ( for rests ) or sets it to the frequency of the given Note .
//this.gainEnvelope.pause(true); //this.gainEnvelope.setValue(0); // Attack: // Decay: // Sustain (amplitude doesn't change): // Release: //		this.wavePlayer.setFrequency(Pitch.mtof(note.getMidiNum())); // Treat -1 like a rest: //			System.out.println("Instrument.playNote: " + Pitch.mtof(note.getMidiNum())); //			System.out.println("1/8th rest"); // if