Subversion Repositories svn.mios

Rev

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

Rev 213 Rev 628
Line 1... Line 1...
1
/*
1
/*
2
 * @(#)VitualMidiDevice.java    beta7   2006/04/23
2
 * @(#)VitualMidiDevice.java    beta8   2006/04/23
3
 *
3
 *
4
 * Copyright (C) 2006    Adam King (adamjking@optusnet.com.au)
4
 * Copyright (C) 2008    Adam King (adamjking@optusnet.com.au)
5
 *
5
 *
6
 * This application is free software; you can redistribute it and/or modify
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
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
8
 * the Free Software Foundation; either version 2 of the License, or
9
 * (at your option) any later version.
9
 * (at your option) any later version.
Line 21... Line 21...
21
package org.midibox.midi;
21
package org.midibox.midi;
22
22
23
import java.util.Iterator;
23
import java.util.Iterator;
24
import java.util.LinkedList;
24
import java.util.LinkedList;
25
import java.util.List;
25
import java.util.List;
-
 
26
import java.util.Observable;
26
27
27
import javax.sound.midi.MidiDevice;
28
import javax.sound.midi.MidiDevice;
28
import javax.sound.midi.MidiMessage;
29
import javax.sound.midi.MidiMessage;
29
import javax.sound.midi.MidiUnavailableException;
30
import javax.sound.midi.MidiUnavailableException;
30
import javax.sound.midi.Receiver;
31
import javax.sound.midi.Receiver;
31
import javax.sound.midi.Transmitter;
32
import javax.sound.midi.Transmitter;
32
33
33
import org.midibox.utils.ObservableMessage;
-
 
34
-
 
35
public class VirtualMidiDevice extends ObservableMessage implements MidiDevice {
34
public class VirtualMidiDevice extends Observable implements MidiDevice {
36
35
37
    protected VirtualMidiDevice.Info info;
36
    protected VirtualMidiDevice.Info info;
38
37
39
    protected int maxNoTransmitters;
38
    protected int maxNoTransmitters;
40
39
Line 43... Line 42...
43
    protected LinkedList transmitters;
42
    protected LinkedList transmitters;
44
43
45
    protected LinkedList receivers;
44
    protected LinkedList receivers;
46
45
47
    protected MidiOutPort midiOutPort;
46
    protected MidiOutPort midiOutPort;
-
 
47
-
 
48
    protected long timeStart = System.currentTimeMillis();
48
49
49
    public VirtualMidiDevice(String name, int maxNoTransmitters,
50
    public VirtualMidiDevice(String name, int maxNoTransmitters,
50
            int maxNoReceivers) {
51
            int maxNoReceivers) {
51
        this.info = new VirtualMidiDevice.MyInfo(name, "midibox.org",
52
        this.info = new VirtualMidiDevice.MyInfo(name, "midibox.org",
52
                "Virtual MIDI Device", "v1.0");
53
                "Virtual MIDI Device", "v1.0");
Line 68... Line 69...
68
    public int getMaxTransmitters() {
69
    public int getMaxTransmitters() {
69
        return maxNoTransmitters;
70
        return maxNoTransmitters;
70
    }
71
    }
71
72
72
    public long getMicrosecondPosition() {
73
    public long getMicrosecondPosition() {
73
        return -1;
74
        return (System.currentTimeMillis() - timeStart) * 1000;
74
    }
75
    }
75
76
76
    public Receiver getReceiver() throws MidiUnavailableException {
77
    public Receiver getReceiver() throws MidiUnavailableException {
77
        MyReceiver receiver = new MyReceiver();
78
        MyReceiver receiver = new MyReceiver();
78
        receivers.add(receiver);
79
        receivers.add(receiver);