use of blue.services.render.DeviceInfo in project blue by kunstmusik.
the class DriverUtilities method getAudioDevicesAlsa.
protected static List<DeviceInfo> getAudioDevicesAlsa(boolean isInput) {
List<DeviceInfo> devices = new ArrayList<>();
String searchVal = isInput ? "capture" : "playback";
String prepend = isInput ? "adc:hw:" : "dac:hw:";
File f = new File("/proc/asound/pcm");
String values;
try {
values = TextUtilities.getTextFromFile(f);
StringTokenizer st = new StringTokenizer(values, "\n");
while (st.hasMoreTokens()) {
String line = st.nextToken();
if (line.contains(searchVal)) {
String[] parts = line.split(":");
String[] cardId = parts[0].split("-");
int card = Integer.parseInt(cardId[0]);
int num = Integer.parseInt(cardId[1]);
String displayName = String.format("(%d:%d) %s : %s", card, num, parts[1], parts[2]);
String deviceId = String.format("%s%d:%d", prepend, card, num);
DeviceInfo info = new DeviceInfo(displayName, deviceId);
devices.add(info);
}
}
} catch (IOException ex) {
ex.printStackTrace();
return null;
}
return devices;
}
use of blue.services.render.DeviceInfo in project blue by kunstmusik.
the class DriverUtilities method getAudioDevicesJackLsp.
protected static List<DeviceInfo> getAudioDevicesJackLsp(boolean isInput) {
List<DeviceInfo> devices = new ArrayList<>();
ProcessRunner pc = new ProcessRunner();
String retVal = null;
String portType = "audio";
String subType = isInput ? "output" : "input";
String prepend = isInput ? "adc:" : "dac:";
String path = System.getenv("PATH");
if (!File.pathSeparator.equals(";")) {
path += File.pathSeparator + "/usr/local/bin";
}
String[] paths = path.split(File.pathSeparator);
String jackLspPath = findExecutableInPath("jack_lsp", paths);
if (jackLspPath == null || jackLspPath.length() == 0) {
return null;
}
try {
pc.execWaitAndCollect(jackLspPath + " -t -p", null);
retVal = pc.getCollectedOutput();
} catch (IOException ex) {
ex.printStackTrace();
}
if (retVal == null || retVal.length() == 0) {
return null;
}
parseJackLspOutput(retVal, portType, subType, prepend, devices);
return devices;
}
use of blue.services.render.DeviceInfo in project blue by kunstmusik.
the class DriverUtilities method getAudioDevicesJackCsound.
protected static List<DeviceInfo> getAudioDevicesJackCsound(String csoundCommand, DiskRenderService service, boolean isInput) {
int csVersion = service.getCsoundVersion(csoundCommand);
if (csVersion < 5) {
return null;
}
List<DeviceInfo> devices = new ArrayList<>();
String jackCSD = TextUtilities.getTextFromSystemResource(DriverUtilities.class, "tempJack.csd");
String retVal = null;
// INITIAL RUN TO FIND OUT TRUE SRATE
String tempText = jackCSD.replaceAll("\\$SR", "1000");
File tempFile = FileUtilities.createTempTextFile("temp", ".csd", null, tempText);
String ioFlag = isInput ? "-iadc:xxx" : "-odac:xxx";
String[] args = new String[] { csoundCommand, ioFlag, "-B4096", "-+msg_color=false", "-+rtaudio=jack", tempFile.getAbsolutePath() };
retVal = service.execWaitAndCollect(args, null);
String sr = null;
if (retVal != null && retVal.contains("does not match JACK sample rate")) {
String[] lines = retVal.split("\n");
for (int i = 0; i < lines.length; i++) {
String line = lines[i];
if (line.contains("does not match JACK sample rate")) {
sr = line.substring(line.lastIndexOf(" ") + 1);
break;
}
}
} else {
// MIGHT WANT TO GIVE MESSAGE SAYING COULD NOT CONNECT TO JACK
return null;
}
if (sr == null) {
return null;
}
tempText = jackCSD.replaceAll("\\$SR", sr);
tempFile = FileUtilities.createTempTextFile("temp", ".csd", null, tempText);
args[args.length - 1] = tempFile.getAbsolutePath();
retVal = service.execWaitAndCollect(args, null);
if (retVal == null) {
return null;
}
// Find Devices
if (csVersion == 5) {
StringTokenizer st = new StringTokenizer(retVal, "\n");
String prepend = isInput ? "adc:" : "dac:";
while (st.hasMoreTokens()) {
String line = st.nextToken().trim();
if (line.endsWith("channel)") || line.endsWith("channels)")) {
String deviceName = prepend + line.substring(1, line.lastIndexOf("\""));
String description = deviceName + " " + line.substring(line.indexOf("("));
DeviceInfo info = new DeviceInfo(description, deviceName);
devices.add(info);
}
}
} else {
List<DeviceInfo> temp = parseCsoundOutput(retVal, isInput);
for (DeviceInfo info : temp) {
String[] parts = info.toString().split("\\s+");
devices.add(new DeviceInfo(info.toString(), parts[0]));
}
}
return devices;
}
Aggregations