1 /*
   2  * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 package com.sun.media.sound;
  26 
  27 import javax.sound.midi.MidiChannel;
  28 
  29 /**
  30  * A MidiChannel proxy object used for external access to synthesizer internal
  31  * channel objects.
  32  *
  33  * @author Karl Helgason
  34  */
  35 public final class SoftChannelProxy implements MidiChannel {
  36 
  37     private MidiChannel channel = null;
  38 
  39     public MidiChannel getChannel() {
  40         return channel;
  41     }
  42 
  43     public void setChannel(MidiChannel channel) {
  44         this.channel = channel;
  45     }
  46 
  47     public void allNotesOff() {
  48         if (channel == null)
  49             return;
  50         channel.allNotesOff();
  51     }
  52 
  53     public void allSoundOff() {
  54         if (channel == null)
  55             return;
  56         channel.allSoundOff();
  57     }
  58 
  59     public void controlChange(int controller, int value) {
  60         if (channel == null)
  61             return;
  62         channel.controlChange(controller, value);
  63     }
  64 
  65     public int getChannelPressure() {
  66         if (channel == null)
  67             return 0;
  68         return channel.getChannelPressure();
  69     }
  70 
  71     public int getController(int controller) {
  72         if (channel == null)
  73             return 0;
  74         return channel.getController(controller);
  75     }
  76 
  77     public boolean getMono() {
  78         if (channel == null)
  79             return false;
  80         return channel.getMono();
  81     }
  82 
  83     public boolean getMute() {
  84         if (channel == null)
  85             return false;
  86         return channel.getMute();
  87     }
  88 
  89     public boolean getOmni() {
  90         if (channel == null)
  91             return false;
  92         return channel.getOmni();
  93     }
  94 
  95     public int getPitchBend() {
  96         if (channel == null)
  97             return 8192;
  98         return channel.getPitchBend();
  99     }
 100 
 101     public int getPolyPressure(int noteNumber) {
 102         if (channel == null)
 103             return 0;
 104         return channel.getPolyPressure(noteNumber);
 105     }
 106 
 107     public int getProgram() {
 108         if (channel == null)
 109             return 0;
 110         return channel.getProgram();
 111     }
 112 
 113     public boolean getSolo() {
 114         if (channel == null)
 115             return false;
 116         return channel.getSolo();
 117     }
 118 
 119     public boolean localControl(boolean on) {
 120         if (channel == null)
 121             return false;
 122         return channel.localControl(on);
 123     }
 124 
 125     public void noteOff(int noteNumber) {
 126         if (channel == null)
 127             return;
 128         channel.noteOff(noteNumber);
 129     }
 130 
 131     public void noteOff(int noteNumber, int velocity) {
 132         if (channel == null)
 133             return;
 134         channel.noteOff(noteNumber, velocity);
 135     }
 136 
 137     public void noteOn(int noteNumber, int velocity) {
 138         if (channel == null)
 139             return;
 140         channel.noteOn(noteNumber, velocity);
 141     }
 142 
 143     public void programChange(int program) {
 144         if (channel == null)
 145             return;
 146         channel.programChange(program);
 147     }
 148 
 149     public void programChange(int bank, int program) {
 150         if (channel == null)
 151             return;
 152         channel.programChange(bank, program);
 153     }
 154 
 155     public void resetAllControllers() {
 156         if (channel == null)
 157             return;
 158         channel.resetAllControllers();
 159     }
 160 
 161     public void setChannelPressure(int pressure) {
 162         if (channel == null)
 163             return;
 164         channel.setChannelPressure(pressure);
 165     }
 166 
 167     public void setMono(boolean on) {
 168         if (channel == null)
 169             return;
 170         channel.setMono(on);
 171     }
 172 
 173     public void setMute(boolean mute) {
 174         if (channel == null)
 175             return;
 176         channel.setMute(mute);
 177     }
 178 
 179     public void setOmni(boolean on) {
 180         if (channel == null)
 181             return;
 182         channel.setOmni(on);
 183     }
 184 
 185     public void setPitchBend(int bend) {
 186         if (channel == null)
 187             return;
 188         channel.setPitchBend(bend);
 189     }
 190 
 191     public void setPolyPressure(int noteNumber, int pressure) {
 192         if (channel == null)
 193             return;
 194         channel.setPolyPressure(noteNumber, pressure);
 195     }
 196 
 197     public void setSolo(boolean soloState) {
 198         if (channel == null)
 199             return;
 200         channel.setSolo(soloState);
 201     }
 202 }