import javax.sound.midi.*;


/**
 * An object that synthesizes the sounds made by an instrument
 *
 * @author  Prof. David Bernstein, James Madison University
 * @version 1.0
 */
public class InstrumentSynthesizer implements Presenter
{
    int          midiNote;
    MidiChannel  channel;
    

    /**
     * Explicit Value Constructor
     *
     * @param channel   The MIDI channel on the synthesizer to use
     */
    public InstrumentSynthesizer(MidiChannel channel)
    {
       this.channel = channel;       
    }
    


    /**
     * Set the value to be used the next time this Presnter
     * is turned on (required by Presenter)
     *
     * In this case, it is a String representation of the
     * MIDI note value
     *
     * @param value   The value
     */
    public void setValue(String value)
    {
       midiNote = Integer.parseInt(value);
       
    }
    
    

    /**
     * Turn this presenter off (required by Presenter)
     *
     * In this case, this method turns the MIDI channel
     * off
     */
    public void turnOff()
    {
       channel.noteOff(midiNote);       
    }
    
    

    /**
     * Turn this presenter on (required by Presenter)
     *
     * In this case, this method turns the MIDI channel
     * on
     */
    public void turnOn()
    {
       channel.noteOn(midiNote, 127);       
    }
    
    


}
