-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
forwarded osc messages added debug mode fixed bug with initial bone conditions from file
- Loading branch information
1 parent
5b1e1c1
commit 4fb8ba0
Showing
15 changed files
with
429 additions
and
56 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package animata; | ||
|
||
import oscP5.OscMessage; | ||
import oscP5.OscP5; | ||
import processing.core.PApplet; | ||
import netP5.NetAddress; | ||
import netP5.NetInfo; | ||
|
||
public class Animata { | ||
|
||
public static NetAddress net; | ||
public static OscP5 oscP5; | ||
|
||
public static void startOSC(PApplet applet) { | ||
net = new NetAddress(NetInfo.getHostAddress(), 7110); | ||
oscP5 = new OscP5(applet, 12000); | ||
PApplet.println("Sending Animata stuff to " + net.address()); | ||
} | ||
|
||
|
||
private static boolean checkInitialised() { | ||
if (net == null) { | ||
//PApplet.println("need to call init() with valid settings on Animata"); | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
public static void zoomCamera(Float delta) { | ||
if (!checkInitialised()) return; | ||
OscMessage message = new OscMessage("/cameradeltazoom"); | ||
message.add(delta); | ||
oscP5.send(message, net); | ||
System.out.println("message:" + message + " to " + net); | ||
} | ||
|
||
public static void panLayer(Float deltaX) { | ||
if (!checkInitialised()) return; | ||
OscMessage message = new OscMessage("/cameradeltapan"); | ||
message.add(deltaX); | ||
message.add(0.0f); | ||
oscP5.send(message, net); | ||
System.out.println("message:" + message + " to " + net); | ||
} | ||
|
||
public static void setBone(String name, Float n) { | ||
if (!checkInitialised()) return; | ||
OscMessage message = new OscMessage("/anibone"); | ||
message.add(name); | ||
message.add((float) n); | ||
PApplet.println("trying to send to " + net.address() + " = " + n + " to bone " + name); | ||
oscP5.send(message, net); | ||
} | ||
|
||
public static void setAlpha(String layer, float value) { | ||
if(!checkInitialised()) return; | ||
OscMessage message = new OscMessage("/layeralpha"); | ||
message.add(layer); | ||
message.add(value); | ||
oscP5.send(message, net); | ||
} | ||
|
||
public static void setBoneTempo(String bone, Float tempo) { | ||
if(!checkInitialised()) return; | ||
OscMessage message = new OscMessage("/bonetempo"); | ||
message.add(bone); | ||
message.add((float) tempo); | ||
PApplet.println("trying to send to " + net.address() + " = " + tempo + " to bone " + bone); | ||
oscP5.send(message, net); | ||
} | ||
|
||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
package animata; | ||
|
||
import java.util.Observable; | ||
import java.util.Observer; | ||
|
||
import processing.core.PApplet; | ||
|
||
public class Animator extends Observable implements Observer { | ||
|
||
|
||
private static Engine engine; | ||
float targetValue; | ||
float initialValue; | ||
float difference; | ||
float frameIncrement; | ||
public float currentValue = 0; | ||
float frame = 0; | ||
boolean isComplete = false; | ||
|
||
public Animator(float startValue, Observer target) { | ||
engine.addObserver(this); | ||
initialValue = currentValue = startValue; | ||
addObserver(target); | ||
} | ||
|
||
public void set(float value, int _frames) { | ||
targetValue = value; | ||
initialValue = currentValue; | ||
difference = (value - initialValue); | ||
frameIncrement = 1 / (float) _frames; | ||
isComplete = false; | ||
frame = 0; | ||
frame += frameIncrement; | ||
} | ||
|
||
public float getValue() { | ||
return currentValue; | ||
} | ||
|
||
public void update(Observable o, Object arg) { | ||
// Just gonna assume it's always nextFrame. | ||
if (frame >= 1 || frame == 0) return; | ||
frame += frameIncrement; | ||
currentValue = initialValue + (difference * easeOutQuad(frame)); | ||
changed(); | ||
if (frame >= 1) complete(); | ||
} | ||
|
||
void changed() { | ||
setChanged(); | ||
notifyObservers(NEXT_FRAME); | ||
} | ||
|
||
public boolean isComplete() { | ||
return isComplete; | ||
} | ||
|
||
public void complete() { | ||
currentValue = targetValue; | ||
isComplete = true; | ||
notifyObservers("complete"); | ||
} | ||
|
||
public void stop() { | ||
// engine.deleteObserver(this); | ||
} | ||
|
||
float easeOutQuad(float t) { | ||
return -1 * (t /= 1) * (t - 2); | ||
} | ||
|
||
public static void init(PApplet applet) { | ||
engine = new Engine(applet); | ||
|
||
}; | ||
public static final String NEXT_FRAME = "nextFrame"; | ||
public static class Engine extends Observable{ | ||
|
||
public Engine(PApplet applet) { | ||
applet.registerDraw(this); | ||
} | ||
public void draw() { | ||
setChanged(); | ||
notifyObservers(NEXT_FRAME); | ||
} | ||
|
||
} | ||
|
||
} |
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package animata.controls; | ||
|
||
import processing.xml.XMLElement; | ||
import rwmidi.MidiInput; | ||
import animata.NoteParser; | ||
import animata.NoteParser.BadNoteFormatException; | ||
|
||
public class BoneTempoKeyRanges extends Control { | ||
private Integer low; | ||
private Integer high; | ||
private int bonecount; | ||
private float tempo; | ||
private BoneTempoKeys[] ranges; | ||
private String boneRoot; | ||
public BoneTempoKeyRanges(XMLElement element, MidiInput in) { | ||
super(element, in); | ||
try { | ||
low = NoteParser.getNote(element.getStringAttribute("low", "1")); | ||
high = NoteParser.getNote(element.getStringAttribute("high", "100")); | ||
} catch (BadNoteFormatException e) { | ||
System.out.println(e.getMessage()); | ||
} | ||
channel = element.getIntAttribute("channel", 16) - 1; | ||
boneRoot = element.getStringAttribute("bone"); | ||
tempo = element.getFloatAttribute("tempo", 1); | ||
bonecount = element.getIntAttribute("bonecount",1); | ||
addRanges(); | ||
} | ||
|
||
private void addRanges() { | ||
ranges = new BoneTempoKeys[bonecount]; | ||
float step = (((float)high)-((float)low))/((float)bonecount); | ||
for (int i = 0; i < bonecount; i++) { | ||
int rangeLow = low + (int)(i*step); | ||
System.out.println("added range low=" + rangeLow + " step was " + step); | ||
ranges[i] = new BoneTempoKeys(in, rangeLow, rangeLow + (int)step, boneRoot+i, tempo, channel); | ||
} | ||
} | ||
} |
Oops, something went wrong.