Subversion Repositories svn.mios

Rev

Rev 213 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
213 tk 1
/*
2
 * @(#)SIDV2librarian.java  beta1   2008/01/21
3
 *
4
 * Copyright (C) 2008    Rutger Vlek (rutgervlek@hotmail.com)
5
 *
6
 * This application is free software; you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation; either version 2 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * This application is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this application; if not, write to the Free Software
18
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19
 */
20
 
21
package org.midibox.sidedit;
22
 
23
import java.util.Iterator;
24
import java.util.LinkedList;
25
import java.util.Observable;
26
import java.util.Observer;
27
 
28
import javax.sound.midi.MidiMessage;
29
import javax.sound.midi.Receiver;
30
 
31
public class SIDSysexParameterControlManager extends Observable implements
32
        Observer, Receiver {
33
 
628 adamjking 34
    protected LinkedList sysexParameters;
213 tk 35
 
36
    protected Receiver receiver;
37
 
38
    public SIDSysexParameterControlManager(Receiver receiver) {
628 adamjking 39
 
213 tk 40
        this.receiver = receiver;
41
        sysexParameters = new LinkedList();
42
    }
43
 
44
    public Receiver getReceiver() {
45
        return receiver;
46
    }
47
 
48
    public void setReceiver(Receiver receiver) {
49
        this.receiver = receiver;
50
 
51
        Iterator it = sysexParameters.iterator();
52
 
53
        while (it.hasNext()) {
54
            SIDSysexParameterControl sysexParameter = (SIDSysexParameterControl) it
55
                    .next();
56
            sysexParameter.setReceiver(receiver);
628 adamjking 57
 
213 tk 58
        }
59
    }
60
 
61
    public LinkedList getSIDSysexParameters() {
62
        return sysexParameters;
63
    }
64
 
65
    public void addSIDSysexParameter(SIDSysexParameter sysexParameter) {
66
        sysexParameters.remove(sysexParameter);
67
        sysexParameters.add(sysexParameter);
68
        sysexParameter.deleteObserver(this);
69
        sysexParameter.addObserver(this);
70
    }
71
 
72
    public void removeSIDSysexParameter(SIDSysexParameter sysexParameter) {
73
        sysexParameter.deleteObserver(this);
74
        sysexParameter.addObserver(this);
75
    }
76
 
77
    public void close() {
78
 
79
    }
80
 
81
    public void send(MidiMessage message, long timestamp) {
82
        Object[] parametersArray = sysexParameters.toArray();
83
 
84
        for (int p = 0; p < parametersArray.length; p++) {
85
            if (parametersArray[p] != null) {
628 adamjking 86
                ((SIDSysexParameter) parametersArray[p]).send(message,
87
                        timestamp);
213 tk 88
            }
89
        }
90
    }
91
 
92
    public void update(Observable observable, Object object) {
628 adamjking 93
 
213 tk 94
    }
95
}