/[svn]/jsampler/trunk/src/org/jsampler/view/SessionViewConfig.java
ViewVC logotype

Contents of /jsampler/trunk/src/org/jsampler/view/SessionViewConfig.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1818 - (show annotations) (download)
Wed Dec 24 17:29:47 2008 UTC (15 years, 4 months ago) by iliev
File size: 3677 byte(s)
* Added support for controlling the global sampler-wide limit of
  maximum voices and disk streams
  (choose Edit/Preferences, then click the `General' tab)
* Fantasia: store the view configuration of audio/MIDI devices and sampler
  channels in the LSCP script when exporting sampler configuration
* Fantasia: Implemented multiple sampler channels' selection
* Fantasia: Added option to move sampler channels up and down
  in the channels list
* Fantasia: Added option to move sampler channels
  to another channels panels

1 /*
2 * JSampler - a java front-end for LinuxSampler
3 *
4 * Copyright (C) 2005-2008 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.view;
24
25 import java.util.LinkedList;
26
27 import org.jsampler.CC;
28
29 /**
30 *
31 * @author Grigor Iliev
32 */
33 public class SessionViewConfig {
34 public static class ChannelConfig {
35 public enum Type {
36 SMALL, NORMAL
37 }
38
39 public int channelsPanel = 0;
40 public Type type = Type.NORMAL;
41 public boolean expanded = false;
42 }
43
44 public static class DeviceConfig {
45 public boolean expanded = false;
46 }
47
48 private final LinkedList<ChannelConfig> channelConfigs = new LinkedList<ChannelConfig>();
49 private final LinkedList<DeviceConfig> midiDeviceConfigs = new LinkedList<DeviceConfig>();
50 private final LinkedList<DeviceConfig> audioDeviceConfigs = new LinkedList<DeviceConfig>();
51
52 public
53 SessionViewConfig(String[] conf) {
54 if(conf == null) return;
55
56 for(int i = 0; i < conf.length; i++) {
57 String s = conf[i];
58 if("[channel]".equals(s)) {
59 channelConfigs.add(parseChannel(conf, i + 1));
60 } else if("[MIDI device]".equals(s)) {
61 midiDeviceConfigs.add(parseDevice(conf, i + 1));
62 } else if("[audio device]".equals(s)) {
63 audioDeviceConfigs.add(parseDevice(conf, i + 1));
64 }
65 }
66 }
67
68 public ChannelConfig
69 pollChannelConfig() { return channelConfigs.poll(); }
70
71 public DeviceConfig
72 pollMidiDeviceConfig() { return midiDeviceConfigs.poll(); }
73
74 public DeviceConfig
75 pollAudioDeviceConfig() { return audioDeviceConfigs.poll(); }
76
77 private ChannelConfig
78 parseChannel(String[] conf, int index) {
79 ChannelConfig channelConfig = new ChannelConfig();
80 for(int i = index; i < conf.length; i++) {
81 if(conf[i].startsWith("[")) return channelConfig;
82 if(conf[i].startsWith("channelsPanel = ")) {
83 String s = conf[i].substring("channelsPanel = ".length());
84 if(s.isEmpty()) continue;
85
86 try {
87 channelConfig.channelsPanel = Integer.parseInt(s) - 1;
88 } catch(Exception x) {
89 CC.getLogger().info("Uknown channels panel: " + s);
90 }
91 } else if(conf[i].startsWith("viewType = ")) {
92 String s = conf[i].substring("viewType = ".length());
93
94 if("SMALL".equals(s)) {
95 channelConfig.type = ChannelConfig.Type.SMALL;
96 } else if("NORMAL".equals(s)) {
97 channelConfig.type = ChannelConfig.Type.NORMAL;
98 } else {
99 CC.getLogger().info("Uknown channel view: " + s);
100 }
101 } else if(conf[i].startsWith("expanded = ")) {
102 String s = conf[i].substring("expanded = ".length());
103 channelConfig.expanded = Boolean.parseBoolean(s);
104 }
105 }
106 return channelConfig;
107 }
108
109 private DeviceConfig
110 parseDevice(String[] conf, int index) {
111 DeviceConfig deviceConfig = new DeviceConfig();
112 for(int i = index; i < conf.length; i++) {
113 if(conf[i].startsWith("[")) return deviceConfig;
114 if(conf[i].startsWith("expanded = ")) {
115 String s = conf[i].substring("expanded = ".length());
116 deviceConfig.expanded = Boolean.parseBoolean(s);
117 }
118 }
119 return deviceConfig;
120 }
121 }

  ViewVC Help
Powered by ViewVC