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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1867 - (hide annotations) (download)
Mon Mar 16 22:12:32 2009 UTC (15 years, 1 month ago) by iliev
File size: 3005 byte(s)
* proper handling of connection failures
* renamed Channels Panels to Channel Lanes
* code cleanup

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

  ViewVC Help
Powered by ViewVC