use of blue.soundObject.SoundObject 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.soundObject.SoundObject in project blue by kunstmusik.
the class SoundObjectLibrary method saveAsXML.
public Element saveAsXML(Map<Object, String> objRefMap) {
Element retVal = new Element("soundObjectLibrary");
for (SoundObject sObj : this) {
String objRefId = Integer.toString(new VMID().hashCode());
objRefMap.put(sObj, objRefId);
Element elem = sObj.saveAsXML(objRefMap);
elem.setAttribute("objRefId", objRefId);
retVal.addElement(elem);
}
return retVal;
}
use of blue.soundObject.SoundObject in project blue by kunstmusik.
the class PatternLayerPanel method otherMenuButtonActionPerformed.
// GEN-LAST:event_soloToggleButtonActionPerformed
@SuppressWarnings("unchecked")
private void otherMenuButtonActionPerformed(java.awt.event.ActionEvent evt) {
// GEN-FIRST:event_otherMenuButtonActionPerformed
Class<? extends SoundObject> current = patternLayer.getSoundObject().getClass();
for (Component c : changeSObjMenu.getMenuComponents()) {
JMenuItem menuItem = (JMenuItem) c;
Class<? extends SoundObject> clazz = (Class<? extends SoundObject>) menuItem.getClientProperty("sObjClass");
menuItem.setEnabled(!current.equals(clazz));
}
ScoreController controller = ScoreController.getInstance();
Collection<? extends ScoreObject> selected = controller.getSelectedScoreObjects();
setSObjFromBufferMenuItem.setEnabled(selected.size() == 1 && selected.iterator().next() instanceof SoundObject);
jPopupMenu1.show(otherMenuButton, 0, otherMenuButton.getHeight());
}
use of blue.soundObject.SoundObject in project blue by kunstmusik.
the class OpenProjectAction method reconcileAudioFiles.
private static void reconcileAudioFiles(PolyObject pObj, Map<String, String> map) {
for (SoundObject sObj : pObj.getSoundObjects(true)) {
if (sObj instanceof AudioFile) {
AudioFile af = (AudioFile) sObj;
String soundFileName = af.getSoundFileName();
if (map.containsKey(soundFileName)) {
af.setSoundFileName(map.get(soundFileName));
}
} else if (sObj instanceof PolyObject) {
reconcileAudioFiles((PolyObject) sObj, map);
}
}
}
use of blue.soundObject.SoundObject in project blue by kunstmusik.
the class BlueLiveTopComponent method triggerLiveObject.
protected void triggerLiveObject(LiveObject liveObject) {
NoteList nl = null;
try {
SoundObject sObj = liveObject.getSoundObject();
if (sObj.getTimeBehavior() != SoundObject.TIME_BEHAVIOR_NOT_SUPPORTED) {
sObj.setTimeBehavior(SoundObject.TIME_BEHAVIOR_NONE);
}
nl = sObj.generateForCSD(compileData, 0.0f, -1.0f);
} catch (Exception e) {
Exceptions.printStackTrace(e);
}
if (nl == null) {
return;
}
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);
}
}
Aggregations