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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1143 - (show annotations) (download)
Mon Apr 2 21:18:31 2007 UTC (17 years ago) by iliev
File size: 3201 byte(s)
* upgrading to version 0.4a

1 /*
2 * JSampler - a java front-end for LinuxSampler
3 *
4 * Copyright (C) 2005-2006 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.jsampler.view.JSChannel;
31
32 import org.linuxsampler.lscp.Client;
33 import org.linuxsampler.lscp.SamplerChannel;
34
35 import static org.jsampler.JSI18n.i18n;
36
37
38 /**
39 * This task duplicates the specified sampler channels.
40 * @author Grigor Iliev
41 */
42 public class DuplicateChannels extends EnhancedTask {
43 SamplerChannel[] chnS;
44
45 /**
46 * Creates a new instance of <code>DuplicateChannels</code>.
47 * @param channel The channel to duplicate.
48 */
49 public
50 DuplicateChannels(SamplerChannel channel) {
51 initTask();
52
53 chnS = new SamplerChannel[1];
54 chnS[0] = channel;
55 }
56
57 /**
58 * Creates a new instance of <code>DuplicateChannels</code>.
59 * @param channels The channels to duplicate.
60 */
61 public
62 DuplicateChannels(JSChannel[] channels) {
63 initTask();
64
65 chnS = new SamplerChannel[channels.length];
66
67 for(int i = 0; i < channels.length; i++) chnS[i] = channels[i].getChannelInfo();
68 }
69
70 private void
71 initTask() {
72 setTitle("DuplicateChannels_task");
73 setDescription(i18n.getMessage("DuplicateChannels.description"));
74 }
75
76 /** The entry point of the task. */
77 public void
78 run() {
79 try {
80 for(SamplerChannel c : chnS) {
81 duplicateSettings(c, CC.getClient().addSamplerChannel());
82 }
83 }
84 catch(Exception x) {
85 setErrorMessage(getDescription() + ": " + HF.getErrorMessage(x));
86 CC.getLogger().log(Level.FINE, getErrorMessage(), x);
87 }
88 }
89
90 private void
91 duplicateSettings(SamplerChannel sc, int c) throws Exception {
92 Client client = CC.getClient();
93
94 if(sc.getMidiInputDevice() >= 0) {
95 client.setChannelMidiInputDevice(c, sc.getMidiInputDevice());
96 client.setChannelMidiInputPort(c, sc.getMidiInputPort());
97 client.setChannelMidiInputChannel(c, sc.getMidiInputChannel());
98 }
99
100 if(sc.getAudioOutputDevice() >= 0) {
101 client.setChannelAudioOutputDevice(c, sc.getAudioOutputDevice());
102 }
103
104 if(sc.getEngine() != null) {
105 client.loadSamplerEngine(sc.getEngine().getName(), c);
106
107 client.setChannelVolume(c, sc.getVolume());
108
109 if(sc.isSoloChannel()) client.setChannelSolo(c, true);
110
111 if(sc.isMuted() && !sc.isMutedBySolo())
112 client.setChannelMute(c, true);
113
114 if(sc.getInstrumentFile() != null) client.loadInstrument (
115 sc.getInstrumentFile(), sc.getInstrumentIndex(), c, true
116 );
117 }
118 }
119 }

  ViewVC Help
Powered by ViewVC