Subversion Repositories svn.mios

Rev

Rev 504 | Rev 696 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 504 Rev 628
Line 19... Line 19...
19
 */
19
 */
20
20
21
package org.midibox.sidedit;
21
package org.midibox.sidedit;
22
22
23
import java.util.Observable;
23
import java.util.Observable;
24
import java.lang.Math;
-
 
-
 
24
25
import javax.sound.midi.MidiMessage;
25
import javax.sound.midi.MidiMessage;
26
import javax.sound.midi.Receiver;
26
import javax.sound.midi.Receiver;
27
import javax.sound.midi.SysexMessage;
-
 
28
27
29
import org.midibox.sidlibr.Patch;
28
import org.midibox.sidlibr.Patch;
30
-
 
31
29
32
public class SIDSysexParameter extends Observable implements Receiver {
30
public class SIDSysexParameter extends Observable implements Receiver {
33
31
34
    public final static Object VALUE = new Object();
32
    public final static Object VALUE = new Object();
35
33
Line 47... Line 45...
47
   
45
48
    protected String name;
46
    protected String name;
49
   
47
50
    protected Patch patch;
48
    protected Patch patch;
51
       
49
52
    public SIDSysexParameter(Patch p, int address, int start_b, int reso, String name) {
50
    public SIDSysexParameter(Patch p, int address, int start_b, int reso,
-
 
51
            String name) {
53
        setReceiver(p.getReceiver());
52
        setReceiver(p.getReceiver());
54
        setMidiMaxMinValues(reso);
53
        setMidiMaxMinValues(reso);
55
        this.address = address;
54
        this.address = address;
56
        this.start_bit = start_b;
55
        this.start_bit = start_b;
57
        this.patch = p;
56
        this.patch = p;
Line 60... Line 59...
60
    }
59
    }
61
   
60
62
    public Receiver getReceiver() {
61
    public Receiver getReceiver() {
63
        return receiver;
62
        return receiver;
64
    }
63
    }
-
 
64
65
    protected void setReceiver(Receiver receiver) {
65
    protected void setReceiver(Receiver receiver) {
66
        this.receiver = receiver;
66
        this.receiver = receiver;
67
    }
67
    }
68
68
69
    public int getMidiValue() {
69
    public int getMidiValue() {
Line 82... Line 82...
82
   
82
83
    public void setMidiMaxMinValues(int reso) {
83
    public void setMidiMaxMinValues(int reso) {
84
        if (reso < 0) {
84
        if (reso < 0) {
85
            midimax = (int) Math.floor((Math.pow(2,Math.abs(reso))-1)/2);
85
            midimax = (int) Math.floor((Math.pow(2, Math.abs(reso)) - 1) / 2);
86
            midimin = -((int) Math.ceil((Math.pow(2,Math.abs(reso))-1)/2));
86
            midimin = -((int) Math.ceil((Math.pow(2, Math.abs(reso)) - 1) / 2));
87
        }
-
 
88
        else {
87
        } else {
89
            midimax = (int) Math.pow(2,reso)-1;
88
            midimax = (int) Math.pow(2, reso) - 1;
90
            midimin = 0;
89
            midimin = 0;
91
        }
90
        }
92
        resolution = reso;
91
        resolution = reso;
93
    }
92
    }
Line 110... Line 109...
110
109
111
    public void close() {
110
    public void close() {
112
    }
111
    }
113
   
112
114
    protected int limitMidiValue(int i) {
113
    protected int limitMidiValue(int i) {
115
        if (i > midimax) {i=midimax;}
114
        if (i > midimax) {
-
 
115
            i = midimax;
-
 
116
        }
116
        if (i < midimin) {i=midimin;}
117
        if (i < midimin) {
-
 
118
            i = midimin;
-
 
119
        }
117
        return i;
120
        return i;
118
    }
121
    }
119
}
122
}