1 |
/* |
/* |
2 |
* JSampler - a java front-end for LinuxSampler |
* JSampler - a java front-end for LinuxSampler |
3 |
* |
* |
4 |
* Copyright (C) 2005, 2006 Grigor Kirilov Iliev |
* Copyright (C) 2005-2007 Grigor Iliev <grigor@grigoriliev.com> |
5 |
* |
* |
6 |
* This file is part of JSampler. |
* This file is part of JSampler. |
7 |
* |
* |
22 |
|
|
23 |
package org.jsampler; |
package org.jsampler; |
24 |
|
|
|
import java.util.Vector; |
|
|
|
|
|
import javax.swing.event.ChangeEvent; |
|
|
import javax.swing.event.ChangeListener; |
|
|
|
|
25 |
import org.w3c.dom.Document; |
import org.w3c.dom.Document; |
26 |
import org.w3c.dom.Element; |
import org.w3c.dom.Element; |
27 |
import org.w3c.dom.NamedNodeMap; |
import org.w3c.dom.NamedNodeMap; |
33 |
* |
* |
34 |
* @author Grigor Iliev |
* @author Grigor Iliev |
35 |
*/ |
*/ |
36 |
public class Instrument { |
public class Instrument extends Resource { |
|
private String name = "Untitled"; |
|
|
private String description = ""; |
|
37 |
private String path = null; |
private String path = null; |
38 |
private int instrumentIndex = 0; |
private int instrumentIndex = 0; |
39 |
|
private String engine = "GIG"; |
|
private final Vector<ChangeListener> listeners = new Vector<ChangeListener>(); |
|
|
|
|
40 |
|
|
41 |
/** Creates a new instance of <code>Instrument</code>. */ |
/** Creates a new instance of <code>Instrument</code>. */ |
42 |
public Instrument() { |
public Instrument() { |
43 |
} |
} |
44 |
|
|
45 |
/** |
/** |
|
* Registers the specified listener to be notified when the instrument settings are changed. |
|
|
* @param l The <code>OrchestraListener</code> to register. |
|
|
*/ |
|
|
public void |
|
|
addChangeListener(ChangeListener l) { listeners.add(l); } |
|
|
|
|
|
/** |
|
|
* Removes the specified listener. |
|
|
* @param l The <code>OrchestraListener</code> to remove. |
|
|
*/ |
|
|
public void |
|
|
removeChangeListener(ChangeListener l) { listeners.remove(l); } |
|
|
|
|
|
/** |
|
|
* Gets the name of this instrument. |
|
|
* @return The name of this instrument. |
|
|
*/ |
|
|
public String |
|
|
getName() { return name; } |
|
|
|
|
|
/** |
|
|
* Sets the name of this instrument. |
|
|
* @param name The new name of this instrument. |
|
|
*/ |
|
|
public void |
|
|
setName(String name) { |
|
|
this.name = name; |
|
|
fireChangeEvent(); |
|
|
} |
|
|
|
|
|
/** |
|
|
* Gets a brief description about this instrument. |
|
|
* @return A brief description about this instrument. |
|
|
*/ |
|
|
public String |
|
|
getDescription() { return description; } |
|
|
|
|
|
/** |
|
|
* Sets a description about this instrument. |
|
|
* @param desc A brief description about this instrument. |
|
|
*/ |
|
|
public void |
|
|
setDescription(String desc) { |
|
|
description = desc; |
|
|
fireChangeEvent(); |
|
|
} |
|
|
|
|
|
/** |
|
46 |
* Returns the absolute pathname of the instrument location. |
* Returns the absolute pathname of the instrument location. |
47 |
* @return The absolute pathname of the instrument location. |
* @return The absolute pathname of the instrument location. |
48 |
*/ |
*/ |
77 |
} |
} |
78 |
|
|
79 |
/** |
/** |
80 |
|
* Gets the engine to be used for loading this instrument. |
81 |
|
* @return The engine to be used for loading this instrument. |
82 |
|
*/ |
83 |
|
public String |
84 |
|
getEngine() { return engine; } |
85 |
|
|
86 |
|
/** |
87 |
|
* Sets the engine to be used for loading this instrument. |
88 |
|
*/ |
89 |
|
public void |
90 |
|
setEngine(String engine) { this.engine = engine; } |
91 |
|
|
92 |
|
/** |
93 |
* Returns the name of this instrument. |
* Returns the name of this instrument. |
94 |
* @return The name of this instrument. |
* @return The name of this instrument. |
95 |
*/ |
*/ |
156 |
return s.startsWith("[Instrument Definition]\n"); |
return s.startsWith("[Instrument Definition]\n"); |
157 |
} |
} |
158 |
|
|
|
/** Notifies listeners that the instrument settings has changed. */ |
|
|
private void |
|
|
fireChangeEvent() { |
|
|
ChangeEvent e = new ChangeEvent(this); |
|
|
for(ChangeListener l : listeners) l.stateChanged(e); |
|
|
} |
|
|
|
|
159 |
/** |
/** |
160 |
* Reads and sets the instrument properties by the supplied <code>node</code>. |
* Reads and sets the instrument properties by the supplied <code>node</code>. |
161 |
* @param node The node providing the instrument properties. |
* @param node The node providing the instrument properties. |