Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 43 additions & 12 deletions src/main/java/io/github/katacc/AudioController.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,16 @@ public void changeVolume(MidiMessage msg) {

float scaled_volume = (((float) value / 127) * 100) / 100;


if (audioSetTimer >= 1) {
audioSetTimer = 0;
if (debug) {
System.out.println("Control: " + control);
}
if (control == 0) {
if (id0.isEmpty()) {
System.out.println("id0 is empty... refreshing config...");
getConfig();
}
try {
for (int id : id0) {
String command = String.format("wpctl set-volume %s, %s", id, scaled_volume);
Expand All @@ -104,11 +110,15 @@ public void changeVolume(MidiMessage msg) {
Process process = Runtime.getRuntime().exec(command);
}
} catch (IOException e) {
System.out.println("Erorr: " + e.getMessage());
System.out.println("Error: " + e.getMessage());
}
}
if (control == 1) {
try {
if (id1.isEmpty()) {
System.out.println("id1 is empty... refreshing config...");
getConfig();
}
for (int id : id1) {
String command = String.format("wpctl set-volume %s, %s", id, scaled_volume);
if (debug) {
Expand All @@ -117,11 +127,15 @@ public void changeVolume(MidiMessage msg) {
Process process = Runtime.getRuntime().exec(command);
}
} catch (IOException e) {
System.out.println("Erorr: " + e.getMessage());
System.out.println("Error: " + e.getMessage());
}
}
if (control == 2) {
try {
if (id2.isEmpty()) {
System.out.println("id2 is empty... refreshing config...");
getConfig();
}
for (int id : id2) {
String command = String.format("wpctl set-volume %s, %s", id, scaled_volume);
if (debug) {
Expand All @@ -130,11 +144,15 @@ public void changeVolume(MidiMessage msg) {
Process process = Runtime.getRuntime().exec(command);
}
} catch (IOException e) {
System.out.println("Erorr: " + e.getMessage());
System.out.println("Error: " + e.getMessage());
}
}
if (control == 3) {
try {
if (id3.isEmpty()) {
System.out.println("id3 is empty... refreshing config...");
getConfig();
}
for (int id : id3) {
String command = String.format("wpctl set-volume %s, %s", id, scaled_volume);
if (debug) {
Expand All @@ -143,11 +161,15 @@ public void changeVolume(MidiMessage msg) {
Process process = Runtime.getRuntime().exec(command);
}
} catch (IOException e) {
System.out.println("Erorr: " + e.getMessage());
System.out.println("Error: " + e.getMessage());
}
}
if (control == 4) {
try {
if (id4.isEmpty()) {
System.out.println("id4 is empty... refreshing config...");
getConfig();
}
for (int id : id4) {
String command = String.format("wpctl set-volume %s, %s", id, scaled_volume);
if (debug) {
Expand All @@ -156,10 +178,14 @@ public void changeVolume(MidiMessage msg) {
Process process = Runtime.getRuntime().exec(command);
}
} catch (IOException e) {
System.out.println("Erorr: " + e.getMessage());
System.out.println("Error: " + e.getMessage());
}
}
if (control == 5) {
if (id5.isEmpty()) {
System.out.println("id5 is empty... refreshing config...");
getConfig();
}
try {
for (int id : id5) {
String command = String.format("wpctl set-volume %s, %s", id, scaled_volume);
Expand All @@ -169,10 +195,14 @@ public void changeVolume(MidiMessage msg) {
Process process = Runtime.getRuntime().exec(command);
}
} catch (IOException e) {
System.out.println("Erorr: " + e.getMessage());
System.out.println("Error: " + e.getMessage());
}
}
if (control == 6) {
if (id6.isEmpty()) {
System.out.println("id6 is empty... refreshing config...");
getConfig();
}
try {
for (int id : id6) {
String command = String.format("wpctl set-volume %s, %s", id, scaled_volume);
Expand All @@ -182,10 +212,14 @@ public void changeVolume(MidiMessage msg) {
Process process = Runtime.getRuntime().exec(command);
}
} catch (IOException e) {
System.out.println("Erorr: " + e.getMessage());
System.out.println("Error: " + e.getMessage());
}
}
if (control == 7) {
if (id7.isEmpty()) {
System.out.println("id7 is empty... refreshing config...");
getConfig();
}
try {
for (int id : id7) {
String command = String.format("wpctl set-volume %s, %s", id, scaled_volume);
Expand All @@ -195,7 +229,7 @@ public void changeVolume(MidiMessage msg) {
Process process = Runtime.getRuntime().exec(command);
}
} catch (IOException e) {
System.out.println("Erorr: " + e.getMessage());
System.out.println("Error: " + e.getMessage());
}
}
}
Expand Down Expand Up @@ -265,9 +299,6 @@ public void changeVolume(MidiMessage msg) {

/**
* getId to get id of a application from pw-dump
* Problem is that its really slow to generate the dump and parse the json
* Therefore only get the updated id's every 100 midi messages.
*
* */
public List<Integer> getId(String name) {

Expand Down