/* * jlscp - a java LinuxSampler control protocol API * * Copyright (C) 2005 Grigor Kirilov Iliev * * This file is part of jlscp. * * jlscp is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 * as published by the Free Software Foundation. * * jlscp 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 jlscp; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA */ package org.linuxsampler.lscp; import java.util.Vector; /** * This class provides detailed information about an audio output chanel. * @author Grigor Iliev */ public class AudioOutputChannel { private Parameter name; private Parameter mixChannel; private Parameter mcDst; private final Vector prmList = new Vector(); /** Creates a new instance of AudioOutputChannel */ public AudioOutputChannel() { } /** * Gets the name of this audio output channel. * @return The name of this audio output channel. */ public String getName() { return name == null ? null : name.getValue(); } /** * Gets the NAME parameter. * @return A Parameter instance. */ public Parameter getNameParameter() { return name; } /** * Sets the NAME parameter. * @param name A Parameter instance. */ public void setNameParameter(Parameter name) { this.name = name; } /** * Determines whether this channel is a mix-channel. * @return true if this is a mix-channel, false otherwise. */ public boolean isMixChannel() { return mixChannel == null ? false : mixChannel.getValue(); } /** * Gets the IS_MIX_CHANNEL parameter. * @return A Parameter instance. */ public Parameter getMixChannelParameter() { return mixChannel; } /** * Sets whether this channel is a mix-channel. * @param mixChannel Specifies whether this channel is a mix-channel or not. */ public void setMixChannelParameter(Parameter mixChannel) { this.mixChannel = mixChannel; } /** * Gets the number of the real audio channel this mix channel refers to. * @return The number of the real audio channel this mix channel refers to. */ public int getMixChannelDest() { return mcDst == null ? -1 : mcDst.getValue(); } /** * Gets the MIX_CHANNEL_DESTINATION parameter. * @return The MIX_CHANNEL_DESTINATION parameter. */ public Parameter getMixChannelDestParameter() { return mcDst; } /** * Sets the MIX_CHANNEL_DESTINATION parameter. * @param mcDst The new MIX_CHANNEL_DESTINATION parameter. */ public void setMixChannelDestParameter(Parameter mcDst) { this.mcDst = mcDst; } /** * Adds additional parameter to this audio output channel. * @param prm The additional parameter to be added. */ public void addParameter(Parameter prm) { prmList.add(prm); } /** * Gets a Parameter array with the additional parameters * of this audio output channel. * @return A Parameter array with the additional parameters * of this audio output channel. */ public Parameter[] getAdditionalParameters() { return prmList.toArray(new Parameter[prmList.size()]); } /** * Gets a Parameter array providing all parameters * of this audio output channel (including NAME, * IS_MIX_CHANNEL, MIX_CHANNEL_DESTINATION parameters). * @return A Parameter array providing all parameters * of this audio output channel. */ public Parameter[] getAllParameters() { Parameter[] params; if(getMixChannelDestParameter() != null) { params = new Parameter[prmList.size() + 3]; params[2] = getMixChannelDestParameter(); for(int i = 0; i < prmList.size(); i++) params[i + 3] = prmList.get(i); } else { params = new Parameter[prmList.size() + 2]; for(int i = 0; i < prmList.size(); i++) params[i + 2] = prmList.get(i); } params[0] = getNameParameter(); params[1] = getMixChannelParameter(); return params; } /** * Determines whether this audio output channel has additional parameters. * @return true if this audio output channel has additional parameters, * false otherwise. */ public boolean hasAdditionalParameters() { return prmList.size() > 0; } /** * Returns the name of this audio output chanel. * @return The name of this audio output chanel. */ public String toString() { return getName(); } }