@@ -91,10 +91,16 @@ public void changeVolume(MidiMessage msg) {
9191
9292 float scaled_volume = (((float ) value / 127 ) * 100 ) / 100 ;
9393
94-
9594 if (audioSetTimer >= 1 ) {
9695 audioSetTimer = 0 ;
96+ if (debug ) {
97+ System .out .println ("Control: " + control );
98+ }
9799 if (control == 0 ) {
100+ if (id0 .isEmpty ()) {
101+ System .out .println ("id0 is empty... refreshing config..." );
102+ getConfig ();
103+ }
98104 try {
99105 for (int id : id0 ) {
100106 String command = String .format ("wpctl set-volume %s, %s" , id , scaled_volume );
@@ -104,11 +110,15 @@ public void changeVolume(MidiMessage msg) {
104110 Process process = Runtime .getRuntime ().exec (command );
105111 }
106112 } catch (IOException e ) {
107- System .out .println ("Erorr : " + e .getMessage ());
113+ System .out .println ("Error : " + e .getMessage ());
108114 }
109115 }
110116 if (control == 1 ) {
111117 try {
118+ if (id1 .isEmpty ()) {
119+ System .out .println ("id1 is empty... refreshing config..." );
120+ getConfig ();
121+ }
112122 for (int id : id1 ) {
113123 String command = String .format ("wpctl set-volume %s, %s" , id , scaled_volume );
114124 if (debug ) {
@@ -117,11 +127,15 @@ public void changeVolume(MidiMessage msg) {
117127 Process process = Runtime .getRuntime ().exec (command );
118128 }
119129 } catch (IOException e ) {
120- System .out .println ("Erorr : " + e .getMessage ());
130+ System .out .println ("Error : " + e .getMessage ());
121131 }
122132 }
123133 if (control == 2 ) {
124134 try {
135+ if (id2 .isEmpty ()) {
136+ System .out .println ("id2 is empty... refreshing config..." );
137+ getConfig ();
138+ }
125139 for (int id : id2 ) {
126140 String command = String .format ("wpctl set-volume %s, %s" , id , scaled_volume );
127141 if (debug ) {
@@ -130,11 +144,15 @@ public void changeVolume(MidiMessage msg) {
130144 Process process = Runtime .getRuntime ().exec (command );
131145 }
132146 } catch (IOException e ) {
133- System .out .println ("Erorr : " + e .getMessage ());
147+ System .out .println ("Error : " + e .getMessage ());
134148 }
135149 }
136150 if (control == 3 ) {
137151 try {
152+ if (id3 .isEmpty ()) {
153+ System .out .println ("id3 is empty... refreshing config..." );
154+ getConfig ();
155+ }
138156 for (int id : id3 ) {
139157 String command = String .format ("wpctl set-volume %s, %s" , id , scaled_volume );
140158 if (debug ) {
@@ -143,11 +161,15 @@ public void changeVolume(MidiMessage msg) {
143161 Process process = Runtime .getRuntime ().exec (command );
144162 }
145163 } catch (IOException e ) {
146- System .out .println ("Erorr : " + e .getMessage ());
164+ System .out .println ("Error : " + e .getMessage ());
147165 }
148166 }
149167 if (control == 4 ) {
150168 try {
169+ if (id4 .isEmpty ()) {
170+ System .out .println ("id4 is empty... refreshing config..." );
171+ getConfig ();
172+ }
151173 for (int id : id4 ) {
152174 String command = String .format ("wpctl set-volume %s, %s" , id , scaled_volume );
153175 if (debug ) {
@@ -156,10 +178,14 @@ public void changeVolume(MidiMessage msg) {
156178 Process process = Runtime .getRuntime ().exec (command );
157179 }
158180 } catch (IOException e ) {
159- System .out .println ("Erorr : " + e .getMessage ());
181+ System .out .println ("Error : " + e .getMessage ());
160182 }
161183 }
162184 if (control == 5 ) {
185+ if (id5 .isEmpty ()) {
186+ System .out .println ("id5 is empty... refreshing config..." );
187+ getConfig ();
188+ }
163189 try {
164190 for (int id : id5 ) {
165191 String command = String .format ("wpctl set-volume %s, %s" , id , scaled_volume );
@@ -169,10 +195,14 @@ public void changeVolume(MidiMessage msg) {
169195 Process process = Runtime .getRuntime ().exec (command );
170196 }
171197 } catch (IOException e ) {
172- System .out .println ("Erorr : " + e .getMessage ());
198+ System .out .println ("Error : " + e .getMessage ());
173199 }
174200 }
175201 if (control == 6 ) {
202+ if (id6 .isEmpty ()) {
203+ System .out .println ("id6 is empty... refreshing config..." );
204+ getConfig ();
205+ }
176206 try {
177207 for (int id : id6 ) {
178208 String command = String .format ("wpctl set-volume %s, %s" , id , scaled_volume );
@@ -182,10 +212,14 @@ public void changeVolume(MidiMessage msg) {
182212 Process process = Runtime .getRuntime ().exec (command );
183213 }
184214 } catch (IOException e ) {
185- System .out .println ("Erorr : " + e .getMessage ());
215+ System .out .println ("Error : " + e .getMessage ());
186216 }
187217 }
188218 if (control == 7 ) {
219+ if (id7 .isEmpty ()) {
220+ System .out .println ("id7 is empty... refreshing config..." );
221+ getConfig ();
222+ }
189223 try {
190224 for (int id : id7 ) {
191225 String command = String .format ("wpctl set-volume %s, %s" , id , scaled_volume );
@@ -195,7 +229,7 @@ public void changeVolume(MidiMessage msg) {
195229 Process process = Runtime .getRuntime ().exec (command );
196230 }
197231 } catch (IOException e ) {
198- System .out .println ("Erorr : " + e .getMessage ());
232+ System .out .println ("Error : " + e .getMessage ());
199233 }
200234 }
201235 }
@@ -265,9 +299,6 @@ public void changeVolume(MidiMessage msg) {
265299
266300 /**
267301 * getId to get id of a application from pw-dump
268- * Problem is that its really slow to generate the dump and parse the json
269- * Therefore only get the updated id's every 100 midi messages.
270- *
271302 * */
272303 public List <Integer > getId (String name ) {
273304
0 commit comments