/**
 * Created on Dec 4, 2004
 *
 * Copyright (c) Hans-Christoph Steiner <hans@eds.org>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * See file LICENSE for further informations on licensing terms.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */

package typist;

import com.softsynth.jsyn.*;
import com.softsynth.jsyn.circuits.PingSound;

/**
 * @author itpstudent
 */
public class KeyPressSynthNote extends SynthNote {

	private PingSound myPingSound;

	private SynthInput cutoff;

	private SynthInput resonance;

	private SynthInput rate;

	public KeyPressSynthNote() {
		add(myPingSound = new PingSound());

		// INPUTS
		addPort(frequency = myPingSound.frequency);
		frequency.setup(16.0, 1300, 4186.0);

		addPort(amplitude = myPingSound.amplitude);
		amplitude.setup(0.0, 1.5, 2.0);

		addPort(cutoff = myPingSound.cutoff, "cutoff");
		cutoff.setup(500, 1400, 2000);

		addPort(resonance = myPingSound.resonance, "resonance");
		resonance.setup(0.01, 0.92, 1.0);

		addPort(rate = myPingSound.rate, "rate");
		rate.setup(0, 20, 20);

		// OUTPUT
		addPort(output = myPingSound.output);
	}

	public void setStage(int time, int stage) {
		switch (stage) {

			case 0 :
				stop(time);
				start(time);
				myPingSound.setStage(time, 0);
				myPingSound.trigger(time, frequency.get(), amplitude.get());
				break;
			case 1 :
				break;
			default :
				break;
		}
	}

}
