1 |
/* |
2 |
* JSampler - a java front-end for LinuxSampler |
3 |
* |
4 |
* Copyright (C) 2005-2007 Grigor Iliev <grigor@grigoriliev.com> |
5 |
* |
6 |
* This file is part of JSampler. |
7 |
* |
8 |
* JSampler 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 |
* JSampler 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 JSampler; 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.jsampler; |
24 |
|
25 |
import org.jsampler.event.ListListener; |
26 |
import org.jsampler.event.MidiDeviceListListener; |
27 |
import org.jsampler.event.SamplerChannelListListener; |
28 |
import org.jsampler.event.SamplerListener; |
29 |
|
30 |
import org.linuxsampler.lscp.*; |
31 |
|
32 |
|
33 |
/** |
34 |
* A data model representing a sampler. |
35 |
* Note that the setter methods does <b>not</b> alter any settings |
36 |
* on the backend side unless otherwise specified. |
37 |
* @author Grigor Iliev |
38 |
*/ |
39 |
public interface SamplerModel { |
40 |
/** |
41 |
* Registers the specified listener for receiving event messages. |
42 |
* @param l The <code>SamplerListener</code> to register. |
43 |
*/ |
44 |
public void addSamplerListener(SamplerListener l); |
45 |
|
46 |
/** |
47 |
* Removes the specified listener. |
48 |
* @param l The <code>SamplerListener</code> to remove. |
49 |
*/ |
50 |
public void removeSamplerListener(SamplerListener l); |
51 |
|
52 |
/** |
53 |
* Registers the specified listener for receiving event messages. |
54 |
* @param listener The <code>ListListener</code> to register. |
55 |
*/ |
56 |
public void addAudioDeviceListListener(ListListener<AudioDeviceModel> listener); |
57 |
|
58 |
/** |
59 |
* Removes the specified listener. |
60 |
* @param listener The <code>ListListener</code> to remove. |
61 |
*/ |
62 |
public void removeAudioDeviceListListener(ListListener<AudioDeviceModel> listener); |
63 |
|
64 |
/** |
65 |
* Registers the specified listener for receiving event messages. |
66 |
* @param listener The <code>MidiDeviceListListener</code> to register. |
67 |
*/ |
68 |
public void addMidiDeviceListListener(MidiDeviceListListener listener); |
69 |
|
70 |
/** |
71 |
* Removes the specified listener. |
72 |
* @param listener The <code>MidiDeviceListListener</code> to remove. |
73 |
*/ |
74 |
public void removeMidiDeviceListListener(MidiDeviceListListener listener); |
75 |
|
76 |
/** |
77 |
* Registers the specified listener for receiving event messages. |
78 |
* @param listener The <code>ListListener</code> to register. |
79 |
*/ |
80 |
public void addMidiInstrumentMapListListener(ListListener<MidiInstrumentMap> listener); |
81 |
|
82 |
/** |
83 |
* Removes the specified listener. |
84 |
* @param listener The <code>ListListener</code> to remove. |
85 |
*/ |
86 |
public void removeMidiInstrumentMapListListener(ListListener<MidiInstrumentMap> listener); |
87 |
|
88 |
/** |
89 |
* Registers the specified listener for receiving event messages. |
90 |
* @param listener The <code>SamplerChannelListListener</code> to register. |
91 |
*/ |
92 |
public void addSamplerChannelListListener(SamplerChannelListListener listener); |
93 |
|
94 |
/** |
95 |
* Removes the specified listener. |
96 |
* @param listener The <code>SamplerChannelListListener</code> to remove. |
97 |
*/ |
98 |
public void removeSamplerChannelListListener(SamplerChannelListListener listener); |
99 |
|
100 |
/** |
101 |
* Gets information about the LinuxSampler instance the front-end is connected to. |
102 |
* |
103 |
* @return <code>ServerInfo</code> instance containing |
104 |
* information about the LinuxSampler instance the front-end is connected to. |
105 |
*/ |
106 |
public ServerInfo getServerInfo(); |
107 |
|
108 |
/** |
109 |
* Gets all audio output drivers currently available for the LinuxSampler instance. |
110 |
* |
111 |
* @return <code>AudioOutputDriver</code> array containing all audio output drivers |
112 |
* currently available for the LinuxSampler instance. |
113 |
*/ |
114 |
public AudioOutputDriver[] getAudioOutputDrivers(); |
115 |
|
116 |
/** |
117 |
* Gets the model of the audio device with ID <code>deviceId</code>. |
118 |
* @param deviceId The ID of the audio device whose model should be obtained. |
119 |
* @return The model of the specified audio device or <code>null</code> |
120 |
* if there is no audio device with ID <code>deviceId</code>. |
121 |
*/ |
122 |
public AudioDeviceModel getAudioDeviceById(int deviceId); |
123 |
|
124 |
/** |
125 |
* Gets the current number of audio devices. |
126 |
* @return The current number of audio devices. |
127 |
*/ |
128 |
public int getAudioDeviceCount(); |
129 |
|
130 |
/** |
131 |
* Gets the current list of audio device models. |
132 |
* @return The current list of audio device models. |
133 |
*/ |
134 |
public AudioDeviceModel[] getAudioDevices(); |
135 |
|
136 |
/** |
137 |
* Adds the specified audio device. |
138 |
* @param device The audio device to be added. |
139 |
*/ |
140 |
public void addAudioDevice(AudioOutputDevice device); |
141 |
|
142 |
/** |
143 |
* Removes the specified audio device. |
144 |
* @param deviceId The ID of the audio device to be removed. |
145 |
* @return <code>true</code> if the audio device is removed successfully, <code>false</code> |
146 |
* if the device list does not contain audio device with ID <code>deviceId</code>. |
147 |
*/ |
148 |
public boolean removeAudioDeviceById(int deviceId); |
149 |
|
150 |
/** |
151 |
* Removes (on the backend side) the specified audio device. |
152 |
* @param deviceId The ID of the audio device to be removed. |
153 |
*/ |
154 |
public void removeBackendAudioDevice(int deviceId); |
155 |
|
156 |
/** |
157 |
* Gets all MIDI input drivers currently available for the LinuxSampler instance. |
158 |
* |
159 |
* @return <code>MidiInputDriver</code> array containing all MIDI input drivers currently |
160 |
* available for the LinuxSampler instance. |
161 |
*/ |
162 |
public MidiInputDriver[] getMidiInputDrivers(); |
163 |
|
164 |
/** |
165 |
* Gets the model of the MIDI device with ID <code>deviceId</code>. |
166 |
* @param deviceId The ID of the MIDI device whose model should be obtained. |
167 |
* @return The model of the specified MIDI device or <code>null</code> |
168 |
* if there is no MIDI device with ID <code>deviceId</code>. |
169 |
*/ |
170 |
public MidiDeviceModel getMidiDeviceById(int deviceId); |
171 |
|
172 |
/** |
173 |
* Gets the current number of MIDI input devices. |
174 |
* @return The current number of MIDI input devices. |
175 |
*/ |
176 |
public int getMidiDeviceCount(); |
177 |
|
178 |
/** |
179 |
* Gets the current list of MIDI device models. |
180 |
* @return The current list of MIDI device models. |
181 |
*/ |
182 |
public MidiDeviceModel[] getMidiDevices(); |
183 |
|
184 |
/** |
185 |
* Adds the specified MIDI device. |
186 |
* @param device The MIDI device to be added. |
187 |
*/ |
188 |
public void addMidiDevice(MidiInputDevice device); |
189 |
|
190 |
/** |
191 |
* Schedules a new task for adding new MIDI device. |
192 |
* @param driver The desired MIDI input system. |
193 |
* @param parameters An optional list of driver specific parameters. |
194 |
*/ |
195 |
public void addBackendMidiDevice(String driver, Parameter... parameters); |
196 |
|
197 |
/** |
198 |
* Removes the specified MIDI device. |
199 |
* @param deviceId The ID of the MIDI device to be removed. |
200 |
* @return <code>true</code> if the MIDI device is removed successfully, <code>false</code> |
201 |
* if the device list does not contain MIDI device with ID <code>deviceId</code>. |
202 |
*/ |
203 |
public boolean removeMidiDeviceById(int deviceId); |
204 |
|
205 |
/** |
206 |
* Schedules a new task for removing the specified MIDI device. |
207 |
* @param deviceId The ID of the MIDI input device to be destroyed. |
208 |
*/ |
209 |
public void removeBackendMidiDevice(int deviceId); |
210 |
|
211 |
/** |
212 |
* Gets the MIDI instrument map with ID <code>mapId</code>. |
213 |
* @param mapId The ID of the MIDI instrument map to obtain. |
214 |
* @return The MIDI instrument map with the specified ID or <code>null</code> |
215 |
* if there is no MIDI instrument map with ID <code>mapId</code>. |
216 |
*/ |
217 |
public MidiInstrumentMap getMidiInstrumentMapById(int mapId); |
218 |
|
219 |
/** |
220 |
* Gets the MIDI instrument map at the specified position. |
221 |
* @param index The position of the MIDI instrument map to return. |
222 |
* @return The MIDI instrument map at the specified position. |
223 |
*/ |
224 |
public MidiInstrumentMap getMidiInstrumentMap(int index); |
225 |
|
226 |
/** |
227 |
* Gets the current number of MIDI instrument maps. |
228 |
* @return The current number of MIDI instrument maps. |
229 |
*/ |
230 |
public int getMidiInstrumentMapCount(); |
231 |
|
232 |
/** |
233 |
* Gets the current list of MIDI instrument maps. |
234 |
* @return The current list of MIDI instrument maps. |
235 |
*/ |
236 |
public MidiInstrumentMap[] getMidiInstrumentMaps(); |
237 |
|
238 |
/** |
239 |
* Gets the position of the specified MIDI instrument map in the list. |
240 |
* @param map The map whose index should be returned. |
241 |
* @return The position of the specified map in the list, |
242 |
* or -1 if <code>map</code> is <code>null</code> or |
243 |
* the map list does not contain the specified map. |
244 |
*/ |
245 |
public int getMidiInstrumentMapIndex(MidiInstrumentMap map); |
246 |
|
247 |
/** |
248 |
* Adds the specified MIDI instrument map. |
249 |
* @param map The MIDI instrument map to be added. |
250 |
*/ |
251 |
public void addMidiInstrumentMap(MidiInstrumentMap map); |
252 |
|
253 |
/** |
254 |
* Schedules a new task for creating a new MIDI instrument map on the backend side. |
255 |
* @param name The name of the MIDI instrument map. |
256 |
* @throws IllegalArgumentException If <code>name</code> is <code>null</code>. |
257 |
*/ |
258 |
public void addBackendMidiInstrumentMap(String name); |
259 |
|
260 |
/** |
261 |
* Removes the specified MIDI instrument map. |
262 |
* @param mapId The ID of the MIDI instrument map to be removed. |
263 |
* @return <code>true</code> if the MIDI instrument map is removed successfully, |
264 |
* <code>false</code> if the MIDI instrument map's list does not contain |
265 |
* MIDI instrument map with ID <code>mapId</code>. |
266 |
*/ |
267 |
public boolean removeMidiInstrumentMapById(int mapId); |
268 |
|
269 |
/** Removes all MIDI instrument maps. */ |
270 |
public void removeAllMidiInstrumentMaps(); |
271 |
|
272 |
/** |
273 |
* Schedules a new task for removing the |
274 |
* specified MIDI instrument map on the backend side. |
275 |
* @param mapId The numerical ID of the MIDI instrument map to remove. |
276 |
* @throws IllegalArgumentException If <code>mapId</code> is negative. |
277 |
*/ |
278 |
public void removeBackendMidiInstrumentMap(int mapId); |
279 |
|
280 |
/** |
281 |
* Schedules a new task for changing the name of |
282 |
* the specified MIDI instrument map on the backend side. |
283 |
* @param mapId The numerical ID of the MIDI instrument map. |
284 |
* @param name The new name for the specified MIDI instrument map. |
285 |
*/ |
286 |
public void setBackendMidiInstrumentMapName(int mapId, String name); |
287 |
|
288 |
/** |
289 |
* Gets the default MIDI instrument map. |
290 |
* @return The default MIDI instrument map or <code>null</code> |
291 |
* if there are no maps created. |
292 |
*/ |
293 |
public MidiInstrumentMap getDefaultMidiInstrumentMap(); |
294 |
|
295 |
/** |
296 |
* Schedules a new task for mapping a MIDI instrument on the backend side. |
297 |
* @param mapId The id of the MIDI instrument map. |
298 |
* @param bank The index of the MIDI bank, which shall contain the instrument. |
299 |
* @param program The MIDI program number of the new instrument. |
300 |
* @param instrInfo Provides the MIDI instrument settings. |
301 |
*/ |
302 |
public void |
303 |
mapBackendMidiInstrument(int mapId, int bank, int program, MidiInstrumentInfo instrInfo); |
304 |
|
305 |
/** |
306 |
* Schedules a new task for removing a MIDI instrument on the backend side. |
307 |
* @param mapId The id of the MIDI instrument map containing the instrument to be removed. |
308 |
* @param bank The index of the MIDI bank containing the instrument to be removed. |
309 |
* @param program The MIDI program number of the instrument to be removed. |
310 |
*/ |
311 |
public void unmapBackendMidiInstrument(int mapId, int bank, int program); |
312 |
|
313 |
/** |
314 |
* Gets a list of all available engines. |
315 |
* @return A list of all available engines. |
316 |
*/ |
317 |
public SamplerEngine[] getEngines(); |
318 |
|
319 |
/** |
320 |
* Gets the current list of sampler channel models. |
321 |
* @return The current list of sampler channel models. |
322 |
*/ |
323 |
public SamplerChannelModel[] getChannels(); |
324 |
|
325 |
/** |
326 |
* Gets the model of the sampler channel with ID <code>channelId</code>. |
327 |
* @param channelId The ID of the sampler channel whose model should be obtained. |
328 |
* @return The model of the specified sampler channel or <code>null</code> |
329 |
* if there is no channel with ID <code>channelId</code>. |
330 |
*/ |
331 |
public SamplerChannelModel getChannelById(int channelId); |
332 |
|
333 |
/** |
334 |
* Gets the current number of sampler channels. |
335 |
* @return The current number of sampler channels. |
336 |
*/ |
337 |
public int getChannelCount(); |
338 |
|
339 |
/** |
340 |
* Adds a new sampler channel on the backend side. The channel will |
341 |
* be actually added to this model when the backend notifies for its creation. |
342 |
* @see #addChannel |
343 |
*/ |
344 |
public void addBackendChannel(); |
345 |
|
346 |
/** |
347 |
* Adds the specified sampler channel. |
348 |
* @param channel The channel to be added. |
349 |
*/ |
350 |
public void addChannel(SamplerChannel channel); |
351 |
|
352 |
/** |
353 |
* Removes the specified sampler channel. |
354 |
* Note that this method doesn't remove the channel in the backend, |
355 |
* it is used to remove the channel from the model when those channel |
356 |
* is removed in the backend. |
357 |
* @param channelId The ID of the channel to be removed. |
358 |
* @return <code>true</code> if the channel is removed successfully, <code>false</code> |
359 |
* if the channel's list does not contain channel with ID <code>channelId</code>. |
360 |
*/ |
361 |
public boolean removeChannelById(int channelId); |
362 |
|
363 |
/** |
364 |
* Schedules a new task for removing the specified sampler channel on the backend side. |
365 |
* @param channelId The ID of the channel to be removed. |
366 |
*/ |
367 |
public void removeBackendChannel(int channelId); |
368 |
|
369 |
/** |
370 |
* Updates the settings of the specified channel. |
371 |
* @param channel A <code>SamplerChannel</code> instance containing the new settings |
372 |
* for the channel. |
373 |
*/ |
374 |
public void updateChannel(SamplerChannel channel); |
375 |
|
376 |
/** |
377 |
* Schedules a new task for starting an instrument editor for editing |
378 |
* the loaded instrument on the specified sampler channel. |
379 |
* @param channelId The sampler channel number. |
380 |
*/ |
381 |
public void editBackendInstrument(int channelId); |
382 |
|
383 |
/** |
384 |
* Determines whether there is at least one solo channel in the current list |
385 |
* of sampler channels. |
386 |
* @return <code>true</code> if there is at least one solo channel in the current list of |
387 |
* sampler channels, <code>false</code> otherwise. |
388 |
*/ |
389 |
public boolean hasSoloChannel(); |
390 |
|
391 |
/** |
392 |
* Gets the number of solo channels in the current list of sampler channels. |
393 |
* @return The number of solo channels in the current list of sampler channels. |
394 |
*/ |
395 |
public int getSoloChannelCount(); |
396 |
|
397 |
/** |
398 |
* Gets the number of muted channels in the current list of sampler channels. |
399 |
* This number includes the channels muted because of the presence of a solo channel. |
400 |
* @return The number of muted channels in the current list of sampler channels. |
401 |
*/ |
402 |
public int getMutedChannelCount(); |
403 |
|
404 |
/** |
405 |
* Gets the number of channels muted because of the presence of a solo channel. |
406 |
* @return The number of channels muted because of the presence of a solo channel. |
407 |
*/ |
408 |
public int getMutedBySoloChannelCount(); |
409 |
|
410 |
/** |
411 |
* Gets the total number of active voices. |
412 |
* @return The total number of active voices. |
413 |
*/ |
414 |
public int getTotalVoiceCount(); |
415 |
|
416 |
/** |
417 |
* Gets the maximum number of active voices. |
418 |
* @return The maximum number of active voices. |
419 |
*/ |
420 |
public int getTotalVoiceCountMax(); |
421 |
|
422 |
/** |
423 |
* Gets the golobal volume of the sampler. |
424 |
* @return The golobal volume of the sampler. |
425 |
*/ |
426 |
public float getVolume(); |
427 |
|
428 |
/** |
429 |
* Sets the global volume. |
430 |
* @param volume The new volume value. |
431 |
*/ |
432 |
public void setVolume(float volume); |
433 |
|
434 |
/** |
435 |
* Sets the global volume on the backend side. |
436 |
* @param volume The new volume value. |
437 |
*/ |
438 |
public void setBackendVolume(float volume); |
439 |
|
440 |
/** |
441 |
* Schedules a new task for resetting the sampler. |
442 |
*/ |
443 |
public void resetBackend(); |
444 |
|
445 |
/** |
446 |
* Updates the current and the maximum number of active voices in the sampler. |
447 |
* @param count The new number of active voices. |
448 |
* @param countMax The maximum number of active voices. |
449 |
*/ |
450 |
public void updateActiveVoiceInfo(int count, int countMax); |
451 |
} |