use of blue.blueLive.LiveObject in project blue by kunstmusik.
the class LiveData method loadFromXML.
public static LiveData loadFromXML(Element data, Map<String, Object> objRefMap) throws Exception {
LiveData liveData = new LiveData();
Elements nodes = data.getElements();
boolean doCommandLineUpgrade = true;
ArrayList<LiveObject> oldFormat = new ArrayList<>();
Element liveObjectSetsNode = null;
while (nodes.hasMoreElements()) {
Element node = nodes.next();
String name = node.getName();
switch(name) {
case "commandLine":
liveData.setCommandLine(node.getTextString());
break;
case "commandLineEnabled":
liveData.setCommandLineEnabled(XMLUtilities.readBoolean(node));
doCommandLineUpgrade = false;
break;
case "commandLineOverride":
liveData.setCommandLineOverride(XMLUtilities.readBoolean(node));
doCommandLineUpgrade = false;
break;
case "soundObject":
SoundObject sObj = (SoundObject) ObjectUtilities.loadFromXML(node, objRefMap);
LiveObject lObj = new LiveObject();
lObj.setSObj(sObj);
oldFormat.add(lObj);
break;
case "liveObject":
oldFormat.add(LiveObject.loadFromXML(node, objRefMap));
break;
case "liveObjectBins":
liveData.liveObjectBins = LiveObjectBins.loadFromXML(node, objRefMap);
break;
case "repeat":
liveData.repeat = XMLUtilities.readInt(node);
break;
case "tempo":
liveData.tempo = XMLUtilities.readInt(node);
break;
case "liveObjectSetList":
liveObjectSetsNode = node;
break;
case "repeatEnabled":
liveData.setRepeatEnabled(XMLUtilities.readBoolean(node));
break;
case "liveCodeText":
liveData.setLiveCodeText(node.getTextString());
break;
}
}
if (oldFormat.size() > 0) {
LiveObject[][] liveObjectBins = new LiveObject[1][oldFormat.size()];
for (int i = 0; i < oldFormat.size(); i++) {
liveObjectBins[0][i] = oldFormat.get(i);
}
liveData.liveObjectBins = new LiveObjectBins(liveObjectBins);
}
if (doCommandLineUpgrade) {
liveData.setCommandLineEnabled(true);
liveData.setCommandLineOverride(true);
}
if (liveObjectSetsNode != null) {
liveData.liveObjectSets = LiveObjectSetList.loadFromXML(liveObjectSetsNode, liveData.liveObjectBins);
}
return liveData;
}
use of blue.blueLive.LiveObject in project blue by kunstmusik.
the class BlueLiveTopComponent method triggerButtonActionPerformed.
// GEN-LAST:event_noteTemplateTextMousePressed
private void triggerButtonActionPerformed(java.awt.event.ActionEvent evt) {
if (data == null) {
return;
}
LiveObjectSet liveObjects = data.getLiveData().getLiveObjectBins().getEnabledLiveObjectSet();
if (liveObjects.size() > 0) {
System.out.println("LiveObjectsSize: " + liveObjects.size());
NoteList nl = new NoteList();
try {
for (LiveObject liveObj : liveObjects) {
SoundObject sObj = liveObj.getSoundObject();
if (sObj.getTimeBehavior() != SoundObject.TIME_BEHAVIOR_NOT_SUPPORTED) {
sObj.setTimeBehavior(SoundObject.TIME_BEHAVIOR_NONE);
}
nl.addAll(sObj.generateForCSD(compileData, 0.0f, -1.0f));
}
} catch (Exception e) {
Exceptions.printStackTrace(e);
}
int tempo = (Integer) tempoSpinner.getValue();
ScoreUtilities.scaleScore(nl, 60.0f / tempo);
String scoreText = nl.toString();
if (scoreText != null && scoreText.length() > 0) {
RealtimeRenderManager.getInstance().passToStdin(scoreText);
}
}
}
use of blue.blueLive.LiveObject in project blue by kunstmusik.
the class BlueLiveBinding method triggerLiveData.
protected void triggerLiveData() {
LiveObjectSet liveObjects = data.getLiveObjectBins().getEnabledLiveObjectSet();
if (liveObjects.size() > 0) {
NoteList nl = new NoteList();
try {
for (LiveObject liveObj : liveObjects) {
SoundObject sObj = liveObj.getSoundObject();
if (sObj.getTimeBehavior() != SoundObject.TIME_BEHAVIOR_NOT_SUPPORTED) {
sObj.setTimeBehavior(SoundObject.TIME_BEHAVIOR_NONE);
}
nl.addAll(sObj.generateForCSD(compileData, 0.0f, -1.0f));
}
} catch (Exception e) {
Exceptions.printStackTrace(e);
}
ScoreUtilities.scaleScore(nl, 60.0f / data.getTempo());
String scoreText = nl.toString();
if (scoreText != null && scoreText.length() > 0) {
// FIXME - this is certainly not good code but functions for now...
BlueLiveToolBar.getInstance().sendEvents(scoreText);
}
}
}
Aggregations