View Javadoc
1   package net.kreatious.pianoleopard.midi;
2   
3   import java.util.Collections;
4   import java.util.List;
5   
6   import javax.sound.midi.MidiDevice;
7   import javax.sound.midi.MidiMessage;
8   import javax.sound.midi.Receiver;
9   import javax.sound.midi.Transmitter;
10  
11  /**
12   * Provides a do-nothing implementation of a MIDI device that is unconnected to
13   * any actual devices.
14   *
15   * @author Jay-R Studer
16   */
17  class InitialMidiDevice implements MidiDevice {
18      @Override
19      public Info getDeviceInfo() {
20          return new Info("Piano Leopard Default Device", "Kreatious LLC",
21                  "The initial MIDI device used by Piano Leopard, does nothing", "1.0") {
22          };
23      }
24  
25      @Override
26      public void open() {
27      }
28  
29      @Override
30      public void close() {
31      }
32  
33      @Override
34      public boolean isOpen() {
35          return false;
36      }
37  
38      @Override
39      public long getMicrosecondPosition() {
40          return 0;
41      }
42  
43      @Override
44      public int getMaxReceivers() {
45          return -1;
46      }
47  
48      @Override
49      public int getMaxTransmitters() {
50          return -1;
51      }
52  
53      @Override
54      public Receiver getReceiver() {
55          return new Receiver() {
56              @Override
57              public void send(MidiMessage message, long timeStamp) {
58              }
59  
60              @Override
61              public void close() {
62              }
63          };
64      }
65  
66      @Override
67      public List<Receiver> getReceivers() {
68          return Collections.emptyList();
69      }
70  
71      @Override
72      public Transmitter getTransmitter() {
73          return new Transmitter() {
74              @Override
75              public void setReceiver(Receiver receiver) {
76              }
77  
78              @Override
79              public Receiver getReceiver() {
80                  return null;
81              }
82  
83              @Override
84              public void close() {
85              }
86          };
87      }
88  
89      @Override
90      public List<Transmitter> getTransmitters() {
91          return Collections.emptyList();
92      }
93  }