2 * 11/19/04 1.0 moved to LGPL.
\r
3 * 12/12/99 Initial implementation. mdm@techie.com.
\r
4 *-----------------------------------------------------------------------
\r
5 * This program is free software; you can redistribute it and/or modify
\r
6 * it under the terms of the GNU Library General Public License as published
\r
7 * by the Free Software Foundation; either version 2 of the License, or
\r
8 * (at your option) any later version.
\r
10 * This program is distributed in the hope that it will be useful,
\r
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
13 * GNU Library General Public License for more details.
\r
15 * You should have received a copy of the GNU Library General Public
\r
16 * License along with this program; if not, write to the Free Software
\r
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
\r
18 *----------------------------------------------------------------------
\r
24 * A Type-safe representation of the the supported output channel
\r
27 * This class is immutable and, hence, is thread safe.
\r
29 * @author Mat McGowan 12/12/99
\r
33 @METHODDEFAULT("OUT<IN")
\r
34 public class OutputChannels
\r
37 * Flag to indicate output should include both channels.
\r
39 @LOC("T") public static final int BOTH_CHANNELS = 0;
\r
42 * Flag to indicate output should include the left channel only.
\r
44 @LOC("T") public static final int LEFT_CHANNEL = 1;
\r
47 * Flag to indicate output should include the right channel only.
\r
49 @LOC("T") public static final int RIGHT_CHANNEL = 2;
\r
52 * Flag to indicate output is mono.
\r
54 @LOC("T") public static final int DOWNMIX_CHANNELS = 3;
\r
57 @LOC("B") public static final OutputChannels LEFT = new OutputChannels(LEFT_CHANNEL);
\r
58 @LOC("B") public static final OutputChannels RIGHT = new OutputChannels(RIGHT_CHANNEL);
\r
59 @LOC("B") public static final OutputChannels BOTH = new OutputChannels(BOTH_CHANNELS);
\r
60 @LOC("B") public static final OutputChannels DOWNMIX = new OutputChannels(DOWNMIX_CHANNELS);
\r
63 @LOC("T") private /*final*/ int outputChannels;
\r
66 * Creates an <code>OutputChannels</code> instance
\r
67 * corresponding to the given channel code.
\r
69 * @param code one of the OutputChannels channel code constants.
\r
71 * @throws IllegalArgumentException if code is not a valid
\r
74 static public OutputChannels fromInt(int code)
\r
84 case DOWNMIX_CHANNELS:
\r
87 throw new IllegalArgumentException("Invalid channel code: "+code);
\r
91 private OutputChannels(@LOC("IN") int channels)
\r
93 outputChannels = channels;
\r
95 if (channels<0 || channels>3)
\r
96 throw new IllegalArgumentException("channels");
\r
100 * Retrieves the code representing the desired output channels.
\r
101 * Will be one of LEFT_CHANNEL, RIGHT_CHANNEL, BOTH_CHANNELS
\r
102 * or DOWNMIX_CHANNELS.
\r
104 * @return the channel code represented by this instance.
\r
106 public int getChannelsOutputCode()
\r
108 return outputChannels;
\r
112 * Retrieves the number of output channels represented
\r
113 * by this channel output type.
\r
115 * @return The number of output channels for this channel output
\r
116 * type. This will be 2 for BOTH_CHANNELS only, and 1
\r
117 * for all other types.
\r
119 public int getChannelCount()
\r
121 int count = (outputChannels==BOTH_CHANNELS) ? 2 : 1;
\r
126 public boolean equals(Object o)
\r
128 boolean equals = false;
\r
130 if (o instanceof OutputChannels)
\r
132 OutputChannels oc = (OutputChannels)o;
\r
133 equals = (oc.outputChannels == outputChannels);
\r
139 public int hashCode()
\r
141 return outputChannels;
\r