1 |
/* |
2 |
* jlscp - a java LinuxSampler control protocol API |
3 |
* |
4 |
* Copyright (C) 2005 Grigor Kirilov Iliev |
5 |
* |
6 |
* This file is part of jlscp. |
7 |
* |
8 |
* jlscp is free software; you can redistribute it and/or modify |
9 |
* it under the terms of the GNU General Public License version 2 |
10 |
* as published by the Free Software Foundation. |
11 |
* |
12 |
* jlscp is distributed in the hope that it will be useful, |
13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 |
* GNU General Public License for more details. |
16 |
* |
17 |
* You should have received a copy of the GNU General Public License |
18 |
* along with jlscp; if not, write to the Free Software |
19 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
20 |
* MA 02111-1307 USA |
21 |
*/ |
22 |
|
23 |
package org.linuxsampler.lscp; |
24 |
|
25 |
/** |
26 |
* Provides information about the current settings of a specific audio output device. |
27 |
* @author Grigor Iliev |
28 |
*/ |
29 |
public class AudioOutputDevice extends AbstractDevice { |
30 |
private Parameter<Integer> channels = null; |
31 |
private Parameter<Integer> samplerate = null; |
32 |
|
33 |
private AudioOutputChannel[] audioChannels = new AudioOutputChannel[0]; |
34 |
|
35 |
|
36 |
/** Creates a new instance of AudioOutputDevice */ |
37 |
public |
38 |
AudioOutputDevice() { |
39 |
|
40 |
} |
41 |
|
42 |
/** |
43 |
* Gets the amount of audio output channels this device currently offers. |
44 |
* @return The amount of audio output channels this device currently offers. |
45 |
*/ |
46 |
public int |
47 |
getChannelCount() { return channels == null ? 0 : channels.getValue(); } |
48 |
|
49 |
/** |
50 |
* Gets the <code>CHANNELS</code> parameter. |
51 |
* @return A <code>Parameter<Integer></code> instance. |
52 |
*/ |
53 |
public Parameter<Integer> |
54 |
getChannelsParameter() { return channels; } |
55 |
|
56 |
/** |
57 |
* Sets the <code>CHANNELS</code> parameter. |
58 |
* @param channels The new <code>CHANNELS</code> parameter. |
59 |
*/ |
60 |
public void |
61 |
setChannelsParameter(Parameter<Integer> channels) { this.channels = channels; } |
62 |
|
63 |
/** |
64 |
* Gets the sample rate this device uses. |
65 |
* @return The sample rate this device uses. |
66 |
*/ |
67 |
public int |
68 |
getSampleRate() { return samplerate == null ? 0 : samplerate.getValue(); } |
69 |
|
70 |
/** |
71 |
* Gets the <code>SAMPLERATE</code> parameter. |
72 |
* @return A <code>Parameter<Integer></code> instance. |
73 |
*/ |
74 |
public Parameter<Integer> |
75 |
getSampleRateParameter() { return samplerate; } |
76 |
|
77 |
/** |
78 |
* Sets the <code>SAMPLERATE</code> parameter. |
79 |
* @param samplerate The new <code>SAMPLERATE</code> parameter. |
80 |
*/ |
81 |
public void |
82 |
setSampleRateParameter(Parameter<Integer> samplerate) { this.samplerate = samplerate; } |
83 |
|
84 |
/** |
85 |
* Gets the current non-<code>null</code> |
86 |
* list of audio channels this device offers. |
87 |
* @return An <code>AudioOutputChannel</code> array |
88 |
* providing all audio channels this device offers. |
89 |
*/ |
90 |
public AudioOutputChannel[] |
91 |
getAudioChannels() { return audioChannels; } |
92 |
|
93 |
/** |
94 |
* Sets the current list of audio output channels. |
95 |
* @param channels The new list of audio output channels. |
96 |
* @throws IllegalArgumentException If <code>channels</code> is <code>null</code>. |
97 |
*/ |
98 |
public void |
99 |
setAudioChannels(AudioOutputChannel[] channels) { |
100 |
if(channels == null) |
101 |
throw new IllegalArgumentException("channels must be non null"); |
102 |
audioChannels = channels; |
103 |
} |
104 |
|
105 |
/** |
106 |
* Gets the audio output channel at the specified index. |
107 |
* @param index The index of the audio output channel to be retrieved. |
108 |
*/ |
109 |
public AudioOutputChannel |
110 |
getAudioChannel(int index) { return audioChannels[index]; } |
111 |
|
112 |
/** |
113 |
* Gets the current number of audio output channels this device offers. |
114 |
* @return The current number of audio output channels this device offers. |
115 |
*/ |
116 |
public int |
117 |
getAudioChannelCount() { return audioChannels.length; } |
118 |
} |