1 |
iliev |
1140 |
/* |
2 |
|
|
* jlscp - a java LinuxSampler control protocol API |
3 |
|
|
* |
4 |
|
|
* Copyright (C) 2005-2006 Grigor Iliev <grigor@grigoriliev.com> |
5 |
|
|
* |
6 |
|
|
* This file is part of jlscp. |
7 |
|
|
* |
8 |
|
|
* jlscp 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 |
|
|
* jlscp 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 jlscp; 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.linuxsampler.lscp; |
24 |
|
|
|
25 |
|
|
/** |
26 |
|
|
* Specifies a position of a MIDI instrument in a MIDI instrument map. |
27 |
|
|
* @author Grigor Iliev |
28 |
|
|
*/ |
29 |
|
|
public class MidiInstrumentEntry implements Comparable<MidiInstrumentEntry> { |
30 |
|
|
private int midiBank; |
31 |
|
|
private int midiProgram; |
32 |
|
|
|
33 |
|
|
/** |
34 |
|
|
* Creates a new instance of <code>MidiInstrumentEntry</code>. |
35 |
|
|
* @param midiBank The MIDI bank number. |
36 |
|
|
* @param midiProgram The MIDI program number. |
37 |
|
|
* @throws IndexOutOfBoundsException If <code>midiBank</code> |
38 |
|
|
* is out of range <code>(midiBank < 0 || midiBank > 16129)</code>, |
39 |
|
|
* or <code>midiProgram</code> is out of range |
40 |
|
|
* <code>(midiProgram < 0 || midiProgram > 127)</code>. |
41 |
|
|
*/ |
42 |
|
|
public |
43 |
|
|
MidiInstrumentEntry(int midiBank, int midiProgram) { |
44 |
|
|
if(midiBank < 0 || midiBank > 16129) |
45 |
|
|
throw new IndexOutOfBoundsException("midiBank is out of range"); |
46 |
|
|
|
47 |
|
|
if(midiProgram < 0 || midiProgram > 127) |
48 |
|
|
throw new IndexOutOfBoundsException("midiProgram is out of range"); |
49 |
|
|
|
50 |
|
|
this.midiBank = midiBank; |
51 |
|
|
this.midiProgram = midiProgram; |
52 |
|
|
} |
53 |
|
|
|
54 |
|
|
/** |
55 |
|
|
* Gets the MIDI bank number. |
56 |
|
|
*/ |
57 |
|
|
public int |
58 |
|
|
getMidiBank() { return midiBank; } |
59 |
|
|
|
60 |
|
|
/** |
61 |
|
|
* Gets the MIDI program number. |
62 |
|
|
*/ |
63 |
|
|
public int |
64 |
|
|
getMidiProgram() { return midiProgram; } |
65 |
|
|
|
66 |
|
|
public boolean |
67 |
|
|
equals(Object obj) { |
68 |
|
|
if(obj == null || !(obj instanceof MidiInstrumentEntry)) return false; |
69 |
|
|
MidiInstrumentEntry e = (MidiInstrumentEntry)obj; |
70 |
|
|
|
71 |
|
|
if(getMidiBank() == e.getMidiBank() && |
72 |
|
|
getMidiProgram() == e.getMidiProgram()) return true; |
73 |
|
|
|
74 |
|
|
return false; |
75 |
|
|
} |
76 |
|
|
|
77 |
|
|
public int |
78 |
|
|
compareTo(MidiInstrumentEntry e) { |
79 |
|
|
if(getMidiBank() < e.getMidiBank()) return -1; |
80 |
|
|
if(getMidiBank() > e.getMidiBank()) return 1; |
81 |
|
|
|
82 |
|
|
if(getMidiProgram() < e.getMidiProgram()) return -1; |
83 |
|
|
if(getMidiProgram() > e.getMidiProgram()) return 1; |
84 |
|
|
|
85 |
|
|
return 0; |
86 |
|
|
} |
87 |
|
|
} |