94 lines
3.5 KiB
Java
94 lines
3.5 KiB
Java
package de.psychose;
|
|
|
|
import javax.sound.midi.*;
|
|
import java.io.File;
|
|
import java.net.InetAddress;
|
|
import java.net.NetworkInterface;
|
|
import java.net.SocketException;
|
|
import java.util.Collections;
|
|
import java.util.Enumeration;
|
|
import java.util.HashSet;
|
|
|
|
public class Test {
|
|
public static final int NOTE_ON = 0x90;
|
|
public static final int NOTE_OFF = 0x80;
|
|
public static final String[] NOTE_NAMES = {"C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "H"};
|
|
|
|
private static void displayInterfaceInformation(NetworkInterface netint) throws SocketException {
|
|
System.out.printf("Display name: %s%n", netint.getDisplayName());
|
|
System.out.printf("Name: %s%n", netint.getName());
|
|
Enumeration<InetAddress> inetAddresses = netint.getInetAddresses();
|
|
|
|
for (InetAddress inetAddress : Collections.list(inetAddresses)) {
|
|
System.out.printf("InetAddress: %s%n", inetAddress);
|
|
}
|
|
System.out.printf("%n");
|
|
}
|
|
|
|
public static void main(String[] args) throws Exception {
|
|
|
|
SnmpStatClient snmpStatClient = new SnmpStatClient("switch/161");
|
|
|
|
System.out.println(snmpStatClient.getTrafficSum() / 1024 / 1024 + "MB");
|
|
|
|
|
|
if(true) return;
|
|
|
|
Enumeration<NetworkInterface> nets = NetworkInterface.getNetworkInterfaces();
|
|
for (NetworkInterface netint : Collections.list(nets)) {
|
|
displayInterfaceInformation(netint);
|
|
}
|
|
|
|
|
|
if(true) return;
|
|
|
|
Sequence sequence = MidiSystem.getSequence(new File("/home/lucas/jake-avril_14th.mid"));
|
|
|
|
HashSet<String> notes = new HashSet<String>();
|
|
|
|
int trackNumber = 0;
|
|
for (Track track : sequence.getTracks()) {
|
|
trackNumber++;
|
|
System.out.println("Track " + trackNumber + ": size = " + track.size());
|
|
System.out.println();
|
|
for (int i = 0; i < track.size(); i++) {
|
|
MidiEvent event = track.get(i);
|
|
System.out.print("@" + event.getTick() + " ");
|
|
MidiMessage message = event.getMessage();
|
|
if (message instanceof ShortMessage) {
|
|
ShortMessage sm = (ShortMessage) message;
|
|
System.out.print("Channel: " + sm.getChannel() + " ");
|
|
if (sm.getCommand() == NOTE_ON) {
|
|
int key = sm.getData1();
|
|
int octave = (key / 12) - 1;
|
|
int note = key % 12;
|
|
String noteName = NOTE_NAMES[note];
|
|
int velocity = sm.getData2();
|
|
System.out.println("Note on, " + noteName + octave + " key=" + key + " velocity: " + velocity);
|
|
|
|
notes.add(noteName + octave);
|
|
|
|
} else if (sm.getCommand() == NOTE_OFF) {
|
|
int key = sm.getData1();
|
|
int octave = (key / 12) - 1;
|
|
int note = key % 12;
|
|
String noteName = NOTE_NAMES[note];
|
|
int velocity = sm.getData2();
|
|
System.out.println("Note off, " + noteName + octave + " key=" + key + " velocity: " + velocity);
|
|
} else {
|
|
System.out.println("Command:" + sm.getCommand());
|
|
}
|
|
} else {
|
|
System.out.println("Other message: " + message.getClass());
|
|
}
|
|
}
|
|
|
|
System.out.println();
|
|
|
|
|
|
}
|
|
|
|
|
|
System.out.println(notes);
|
|
}
|
|
} |