Search in sources :

Example 1 with DeviceInfo

use of blue.services.render.DeviceInfo in project blue by kunstmusik.

the class RealtimeRenderSettingsPanel method midiOutButtonActionPerformed.

// GEN-LAST:event_midiInButtonActionPerformed
private void midiOutButtonActionPerformed(java.awt.event.ActionEvent evt) {
    // GEN-FIRST:event_midiOutButtonActionPerformed
    String driver = null;
    if (midiDriverCBox.isSelected()) {
        driver = (String) midiDriverCombo.getSelectedItem();
    }
    String command = csoundExecText.getText();
    RealtimeRenderServiceFactory factory = (RealtimeRenderServiceFactory) renderServiceComboBox.getSelectedItem();
    DiskRenderService service = factory.createDiskRenderService();
    List<DeviceInfo> vals = DriverUtilities.getMidiDevices(command, driver, service, false);
    Object val = chooseDriver(vals);
    if (val != null) {
        DeviceInfo info = (DeviceInfo) val;
        midiOutText.setText(info.getDeviceId());
        fireUpdate();
    }
}
Also used : DeviceInfo(blue.services.render.DeviceInfo) RealtimeRenderServiceFactory(blue.services.render.RealtimeRenderServiceFactory) DiskRenderService(blue.services.render.DiskRenderService)

Example 2 with DeviceInfo

use of blue.services.render.DeviceInfo in project blue by kunstmusik.

the class DriverUtilities method parseAlsaMidiDevices.

protected static List<DeviceInfo> parseAlsaMidiDevices(String seqClients, String portType, String deviceIdFormat) {
    if (seqClients == null || seqClients.isEmpty() || portType == null || portType.isEmpty()) {
        return null;
    }
    List<DeviceInfo> devices = new ArrayList<>();
    String[] lines = seqClients.split("\\r?\\n");
    for (int i = 0; i < lines.length; i++) {
        String line = lines[i].trim();
        if (line.startsWith("Client") && line.contains(":")) {
            String[] parts = line.split("\"");
            String clientName = parts[1];
            String clientType = parts[2].substring(1);
            int clientNum = Integer.parseInt(line.substring(7, line.indexOf(":")).trim());
            while (i < lines.length - 2) {
                i++;
                String tempLine = lines[i].trim();
                if (tempLine.startsWith("Port")) {
                    String capabilities = tempLine.substring(tempLine.lastIndexOf("("));
                    if (capabilities.contains(portType)) {
                        String[] portParts = tempLine.split("\"");
                        int portNum = Integer.parseInt(tempLine.substring(5, tempLine.indexOf(":")).trim());
                        String portName = portParts[1];
                        Object[] nameArgs = { clientName, portName, clientType };
                        String deviceId = String.format(deviceIdFormat, clientNum, portNum);
                        devices.add(new DeviceInfo(ALSA_MIDI_FORMAT.format(nameArgs), deviceId));
                    }
                } else if (tempLine.startsWith("Client")) {
                    i--;
                    break;
                }
            }
        }
    }
    return devices;
}
Also used : DeviceInfo(blue.services.render.DeviceInfo) ArrayList(java.util.ArrayList)

Example 3 with DeviceInfo

use of blue.services.render.DeviceInfo in project blue by kunstmusik.

the class DriverUtilities method getMidiDevicesAlsaSeq.

protected static List<DeviceInfo> getMidiDevicesAlsaSeq(boolean isInput) {
    List<DeviceInfo> devices = null;
    String portType = isInput ? "R" : "W";
    File f = new File("/proc/asound/seq/clients");
    try {
        String values = TextUtilities.getTextFromFile(f);
        devices = parseAlsaMidiDevices(values, portType, "%d:%d");
    } catch (IOException | NumberFormatException ex) {
        // ex.printStackTrace();
        return null;
    }
    return devices;
}
Also used : DeviceInfo(blue.services.render.DeviceInfo) IOException(java.io.IOException) File(java.io.File)

Example 4 with DeviceInfo

use of blue.services.render.DeviceInfo in project blue by kunstmusik.

the class DriverUtilities method getMidiDevicesAlsa.

/* MIDI DEVICE LISTING METHODS */
protected static List<DeviceInfo> getMidiDevicesAlsa(boolean isInput) {
    List<DeviceInfo> devices = null;
    String portType = isInput ? "R" : "W";
    File f = new File("/proc/asound/seq/clients");
    try {
        String values = TextUtilities.getTextFromFile(f);
        devices = parseAlsaMidiDevices(values, portType, "hw:%d,%d");
    } catch (IOException | NumberFormatException ex) {
        // ex.printStackTrace();
        return null;
    }
    return devices;
}
Also used : DeviceInfo(blue.services.render.DeviceInfo) IOException(java.io.IOException) File(java.io.File)

Example 5 with DeviceInfo

use of blue.services.render.DeviceInfo in project blue by kunstmusik.

the class RealtimeRenderSettingsPanel method audioInButtonActionPerformed.

// GEN-LAST:event_audioOutButtonActionPerformed
private void audioInButtonActionPerformed(java.awt.event.ActionEvent evt) {
    // GEN-FIRST:event_audioInButtonActionPerformed
    String driver = null;
    if (audioDriverCBox.isSelected()) {
        driver = (String) audioDriverCombo.getSelectedItem();
    }
    String command = csoundExecText.getText();
    RealtimeRenderServiceFactory factory = (RealtimeRenderServiceFactory) renderServiceComboBox.getSelectedItem();
    DiskRenderService service = factory.createDiskRenderService();
    List<DeviceInfo> vals = DriverUtilities.getAudioDevices(command, driver, service, true);
    Object val = chooseDriver(vals);
    if (val != null) {
        DeviceInfo info = (DeviceInfo) val;
        audioInText.setText(info.getDeviceId());
        fireUpdate();
    }
}
Also used : DeviceInfo(blue.services.render.DeviceInfo) RealtimeRenderServiceFactory(blue.services.render.RealtimeRenderServiceFactory) DiskRenderService(blue.services.render.DiskRenderService)

Aggregations

DeviceInfo (blue.services.render.DeviceInfo)13 ArrayList (java.util.ArrayList)6 DiskRenderService (blue.services.render.DiskRenderService)4 RealtimeRenderServiceFactory (blue.services.render.RealtimeRenderServiceFactory)4 File (java.io.File)4 IOException (java.io.IOException)4 StringTokenizer (java.util.StringTokenizer)2 Test (org.junit.Test)2 ProcessRunner (blue.utilities.ProcessRunner)1 HashMap (java.util.HashMap)1