private void openDevice() { // Obtain information about all the installed synthesizers. nkDevice = null; nkTransmitter = null; MidiDevice.Info[] infos = MidiSystem.getMidiDeviceInfo(); for (int i = 0; i < infos.length; i++) { try { MidiDevice device = MidiSystem.getMidiDevice(infos[i]); MidiDevice.Info d = infos[i]; if( d.getName().contains(deviceName) ) { System.out.println("Opening " + d.getName()); System.out.println(" max receivers: " + device.getMaxReceivers()); System.out.println(" max transmitters: " + device.getMaxTransmitters());
nkDevice = device; nkTransmitter = device.getTransmitter(); nkTransmitter.setReceiver(new MidiInputReceiver(device.getDeviceInfo().getName())); nkDevice.open(); } } catch (MidiUnavailableException e) { // Handle or throw exception... System.out.println("Exception occurred while getting MIDI devices!"); System.out.println(e.getMessage()); e.printStackTrace(); } } }
--
You received this message because you are subscribed to the Google Groups "beadsproject" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beadsproject+unsubscribe@googlegroups.com.
To post to this group, send email to beadsp...@googlegroups.com.
Visit this group at https://groups.google.com/group/beadsproject.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "beadsproject" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beadsproject+unsubscribe@googlegroups.com.
To post to this group, send email to beadsp...@googlegroups.com.
Visit this group at https://groups.google.com/group/beadsproject.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to beadsproject...@googlegroups.com.
To post to this group, send email to beadsp...@googlegroups.com.
Visit this group at https://groups.google.com/group/beadsproject.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to beadsproject+unsubscribe@googlegroups.com.
To post to this group, send email to beadsp...@googlegroups.com.
Visit this group at https://groups.google.com/group/beadsproject.
For more options, visit https://groups.google.com/d/optout.
package cc.ludic;
import javafx.application.Application;
import javafx.stage.Stage;
import javax.sound.midi.*;
/**
* Created by federico on 10/4/17.
*/
public class MidiExample extends Application {
private MidiDevice nkDevice;
private Transmitter nkTransmitter;
@Override
public void start(Stage primaryStage) throws Exception {
openDevice();
}
private void openDevice()
{
// Obtain information about all the installed synthesizers.
nkDevice = null;
nkTransmitter = null;
MidiDevice.Info[] infos = MidiSystem.getMidiDeviceInfo();
for (int i = 0; i < infos.length; i++)
{
try
{
System.out.println(infos[i].toString());
String deviceName = "SLIDER";
MidiDevice device = MidiSystem.getMidiDevice(infos[i]);
MidiDevice.Info d = infos[i];
if( d.getName().contains(deviceName) )
{
System.out.println("Opening " + d.getName());
System.out.println(" max receivers: " + device.getMaxReceivers());
System.out.println(" max transmitters: " + device.getMaxTransmitters());
nkDevice = device;
nkTransmitter = device.getTransmitter();
nkTransmitter.setReceiver(new MidiInputReceiver(device.getDeviceInfo().getName()));
nkDevice.open();
}
}
catch (MidiUnavailableException e)
{
// Handle or throw exception...
System.out.println("Exception occurred while getting MIDI devices!");
System.out.println(e.getMessage());
e.printStackTrace();
}
}
}
}
class MidiInputReceiver implements Receiver {And here is the output:
public MidiInputReceiver(String name) {
System.out.println(name);
}
@Override
public void send(MidiMessage message, long timeStamp) {
}
@Override
public void close() {
}
}
GervillMidi Bus 1Bus IAC 2SLIDER/KNOBOpening SLIDER/KNOBmax receivers: 0max transmitters: -1SLIDER/KNOBMidi Bus 1Bus IAC 2CTRLReal Time Sequencer
--
You received this message because you are subscribed to the Google Groups "beadsproject" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beadsproject+unsubscribe@googlegroups.com.
To post to this group, send email to beadsp...@googlegroups.com.
Visit this group at https://groups.google.com/group/beadsproject.
For more options, visit https://groups.google.com/d/optout.