/[svn]/jsampler/trunk/src/org/jsampler/task/Global.java
ViewVC logotype

Contents of /jsampler/trunk/src/org/jsampler/task/Global.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1688 - (show annotations) (download)
Thu Feb 14 16:52:36 2008 UTC (16 years, 2 months ago) by iliev
File size: 4640 byte(s)
* Implemented a backend list with option to manually choose a backend
  to connect on startup(Edit/Preferences, then click the `Backend' tab)
  and option to change the backend without restarting JSampler
  (Actions/Change Backend or Ctrl + B)

* Added confirmation messages for removing sampler channels and
  audio/MIDI devices (Edit/Preferences, then click the `View' tab)

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.task;
24
25 import java.util.logging.Level;
26
27 import org.jsampler.CC;
28 import org.jsampler.HF;
29
30 import org.linuxsampler.lscp.ServerInfo;
31 import org.linuxsampler.lscp.Instrument;
32
33 import static org.jsampler.JSI18n.i18n;
34
35
36 /**
37 * Provides tasks for managing the global settings of the sampler.
38 * @author Grigor Iliev
39 */
40 public class Global {
41
42 /** Forbits the instantiation of this class. */
43 private Global() { }
44
45 /**
46 * This task retrieves information about the LinuxSampler instance.
47 * @author Grigor Iliev
48 */
49 public static class GetServerInfo extends EnhancedTask<ServerInfo> {
50 /** Creates a new instance of <code>GetServerInfo</code>. */
51 public
52 GetServerInfo() {
53 setTitle("Global.GetServerInfo_task");
54 setDescription(i18n.getMessage("Global.GetServerInfo.desc"));
55 }
56
57 /** The entry point of the task. */
58 public void
59 run() {
60 try { setResult(CC.getClient().getServerInfo()); }
61 catch(Exception x) {
62 setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x));
63 CC.getLogger().log(Level.FINE, getErrorMessage(), x);
64 }
65 }
66 }
67
68 /**
69 * This task resets the whole sampler.
70 * @author Grigor Iliev
71 */
72 public static class ResetSampler extends EnhancedTask {
73 /** Creates a new instance of <code>ResetSampler</code>. */
74 public
75 ResetSampler() {
76 setTitle("Global.ResetSampler_task");
77 setDescription(i18n.getMessage("Global.ResetSampler.desc"));
78 }
79
80 /** The entry point of the task. */
81 public void
82 run() {
83 try { CC.getClient().resetSampler(); }
84 catch(Exception x) {
85 setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x));
86 CC.getLogger().log(Level.FINE, getErrorMessage(), x);
87 }
88 }
89 }
90
91 /**
92 * This task gets the global volume of the sampler.
93 */
94 public static class GetVolume extends EnhancedTask<Float> {
95 /** Creates a new instance of <code>GetVolume</code>. */
96 public
97 GetVolume() {
98 setTitle("Global.GetVolume_task");
99 setDescription(i18n.getMessage("Global.GetVolume.desc"));
100 }
101
102 /** The entry point of the task. */
103 public void
104 run() {
105 try { setResult(CC.getClient().getVolume()); }
106 catch(Exception x) {
107 setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x));
108 CC.getLogger().log(Level.FINE, getErrorMessage(), x);
109 }
110 }
111 }
112
113
114 /**
115 * This task sets the global volume of the sampler.
116 */
117 public static class SetVolume extends EnhancedTask {
118 private float volume;
119
120 /**
121 * Creates new instance of <code>SetVolume</code>.
122 * @param volume The new volume value.
123 */
124 public
125 SetVolume(float volume) {
126 setTitle("Global.SetVolume_task");
127 setDescription(i18n.getMessage("Global.SetVolume.desc"));
128 this.volume = volume;
129 }
130
131 /** The entry point of the task. */
132 public void
133 run() {
134 try {
135 CC.getClient().setVolume(volume);
136 } catch(Exception x) {
137 setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x));
138 CC.getLogger().log(Level.FINE, getErrorMessage(), x);
139 }
140 }
141 }
142
143 /**
144 * This task gets the list of instruments in the specified instrument file.
145 */
146 public static class GetFileInstruments extends EnhancedTask<Instrument[]> {
147 private final String filename;
148
149 /** Creates a new instance of <code>GetFileInstruments</code>. */
150 public
151 GetFileInstruments(String filename) {
152 this.filename = filename;
153 setTitle("Global.GetFileInstruments_task");
154 setDescription(i18n.getMessage("Global.GetFileInstruments.desc"));
155 }
156
157 /** The entry point of the task. */
158 public void
159 run() {
160 try { setResult(CC.getClient().getFileInstruments(filename)); }
161 catch(Exception x) {
162 String s = getDescription() + ": " + HF.getErrorMessage(x);
163 CC.getLogger().log(Level.FINER, s, x);
164 }
165 }
166 }
167
168 public static class DummyTask extends EnhancedTask {
169 public void
170 run() { }
171 }
172 }

  ViewVC Help
Powered by ViewVC