Permalink
Browse files

Whatever

  • Loading branch information...
1 parent c57ee52 commit d96d67378838dd4fc388c6eaf1d61e8fbd98897a rj committed Feb 2, 2011
View
4 data/scs/jcolliderdefs.sc
@@ -25,9 +25,9 @@ Out.ar([0,1], TGrains.ar(2,Impulse.ar(1/(trigRate*dur)),buffer,rate,centerPos,du
}).store;
-b = Buffer.read(s, "/Users/rj/Documents/workspace/MT4j/data/sounds/amiu.aif");
+b = Buffer.read(s, "/Users/rj/Documents/workspace/MT4j/data/sounds/weirdfish.aif");
pwd
-
+b.play();
g = Synth(\grannyyy, [\trigRate, 1, \buffer, 1]);
g.set(\trigRate, 10);
g.set(\centerPos, 2.3);
View
27 examples/advanced/gestureSound/GestureSound.java
@@ -3,6 +3,8 @@
import java.awt.geom.Point2D;
import java.io.File;
import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.net.SocketAddress;
import java.util.ArrayList;
import java.util.List;
@@ -21,6 +23,9 @@
import advanced.gestureSound.input.InputDelegate;
import de.sciss.jcollider.Buffer;
import de.sciss.jcollider.Synth;
+import de.sciss.net.OSCClient;
+import de.sciss.net.OSCMessage;
+import de.sciss.net.OSCServer;
public class GestureSound extends MTComponent {
@@ -73,7 +78,21 @@ else if (posEvt.getId() == AbstractCursorInputEvt.INPUT_DETECTED) {
}
-
+ public static class OSCMap implements ParamMap {
+ public static OSCManager man = new OSCManager();
+
+ public final String name;
+ public OSCMap(String name) {
+ this.name = name;
+ man.addParam(name);
+ }
+
+ public float map(float in) {
+ man.updateParam(name, in);
+ man.send();
+ return in;
+ }
+ }
public static class CenterPosMap implements ParamMap {
public float pos = 0f;
@@ -139,10 +158,12 @@ void setupGestures() {
b = Buffer.read(sc.server,f.getAbsolutePath());
Synth synth1 = new Synth("grannyyy", new String[] {"trigRate", "buffer", "dur"}, new float[] { 10, b.getBufNum(), 0.1f }, sc.grpAll);
engine.addToMap("curvature", synth1, "centerPos",
- new CenterPosMap(),
+ //new CenterPosMap(),
+ new OSCMap("curvature"),
new Zone() { @Override public boolean in(InputCursor in) {return inQuadrant(in,1)||inQuadrant(in,4);}});
engine.addToMap("velocity", synth1, "trigRate",
- new TrigRateMap(),
+ //new TrigRateMap(),
+ new OSCMap("velocity"),
new Zone() { @Override public boolean in(InputCursor in) {return inQuadrant(in,1)||inQuadrant(in,4);}});
engine.addToMap("curvature", synth1, "rate",
new RateMap(),
View
53 examples/advanced/gestureSound/OSCManager.java
@@ -0,0 +1,53 @@
+package advanced.gestureSound;
+
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.util.HashMap;
+import java.util.Map;
+
+import de.sciss.net.OSCClient;
+import de.sciss.net.OSCMessage;
+import de.sciss.net.OSCServer;
+
+public class OSCManager {
+
+ private OSCServer s;
+
+ private Map<String, Integer> paramMap;
+ private Float[] params;
+
+ public OSCManager() {
+ try {
+ s = OSCServer.newUsing(OSCClient.UDP, 0);
+ s.start();
+ //OSCServer.
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ paramMap = new HashMap<String,Integer>();
+ params = new Float[0];
+ }
+
+ public void send() {
+ //System.out.println("Sending: "+params[0]);
+ OSCMessage msg = new OSCMessage("/oscCustomFeatures", params);
+ try {
+ s.send(msg, new InetSocketAddress( "localhost", 6448 ));
+ } catch (IOException e) { e.printStackTrace(); }
+ }
+
+ public void addParam(String name) {
+ int position = params.length;
+ params = new Float[position+1]; //make it one bigger
+ for (int i=0;i<params.length;i++) params[i]=0.0f;
+ paramMap.put(name, position);
+ }
+
+
+ public void updateParam(String name, float value) {
+ if (paramMap.containsKey(name) && paramMap.get(name) < params.length)
+ params[paramMap.get(name)] = value;
+ }
+
+}
+

0 comments on commit d96d673

Please sign in to comment.