Created
November 22, 2016 03:00
-
-
Save tado/5cc402d0d90531a0ff0f579022823280 to your computer and use it in GitHub Desktop.
Perser for log forwarding on Haskap Jam Pack
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SonicPiOsc { | |
String synth; | |
String[] paramList; | |
void perse(OscMessage msg) { | |
if (msg.checkAddrPattern("/log/multi_message")) { | |
String[] allList = split(msg.get(5).stringValue(), ','); | |
String[] synthList = split(allList[0], ':'); | |
synth = synthList[1]; | |
String str = msg.get(5).stringValue(); | |
int index = str.indexOf("{"); | |
index += "{".length(); | |
str = str.substring(index); | |
index = str.indexOf("}"); | |
str = str.substring(0, index); | |
paramList = split(str, ','); | |
} | |
} | |
String getSynth() { | |
return synth; | |
} | |
float getNote() { | |
float note = 0; | |
for (int i = 0; i < paramList.length; i++) { | |
String[] param = split(paramList[i], ':'); | |
if (trim(param[0]).equals("note")) { | |
note = float(trim(param[1])); | |
} | |
} | |
return note; | |
} | |
float getAmp() { | |
float amp = 0; | |
for (int i = 0; i < paramList.length; i++) { | |
String[] param = split(paramList[i], ':'); | |
if (trim(param[0]).equals("amp")) { | |
amp = float(trim(param[1])); | |
} | |
} | |
return amp; | |
} | |
float getPan() { | |
float pan = 0; | |
for (int i = 0; i < paramList.length; i++) { | |
String[] param = split(paramList[i], ':'); | |
if (trim(param[0]).equals("pan")) { | |
pan = float(trim(param[1])); | |
} | |
} | |
return pan; | |
} | |
float getRelease() { | |
float release = 0; | |
for (int i = 0; i < paramList.length; i++) { | |
String[] param = split(paramList[i], ':'); | |
if (trim(param[0]).equals("release")) { | |
release = float(trim(param[1])); | |
} | |
} | |
return release; | |
} | |
void showLog() { | |
for (int i = 0; i < paramList.length; i++) { | |
String[] param = split(paramList[i], ':'); | |
println("Name = " + param[0]); | |
println("value = " + param[1]); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment