use of blue.soundObject.SoundObject in project blue by kunstmusik.
the class SoundLayer method saveAsXML.
public Element saveAsXML(Map<Object, String> objRefMap) {
Element retVal = new Element("soundLayer");
retVal.setAttribute("name", this.getName());
retVal.setAttribute("muted", Boolean.toString(this.isMuted()));
retVal.setAttribute("solo", Boolean.toString(this.isSolo()));
retVal.setAttribute("heightIndex", Integer.toString(this.getHeightIndex()));
retVal.addElement(npc.saveAsXML());
for (SoundObject sObj : this) {
retVal.addElement(sObj.saveAsXML(objRefMap));
}
for (Iterator iter = automationParameters.iterator(); iter.hasNext(); ) {
String id = (String) iter.next();
retVal.addElement("parameterId").setText(id);
}
return retVal;
}
use of blue.soundObject.SoundObject in project blue by kunstmusik.
the class SoundLayer method generateForCSD.
/**
* Generates notes for the SoundLayer, skipping over soundObjects which do
* not contribute notes between the startTime and endTime arguments.
*
* StartTime and endTime is adjusted by the PolyObject before passing into
* SoundLayer if possible, if not possible, will adjust to render everything
* and filter on top layer.
*/
public NoteList generateForCSD(CompileData compileData, double startTime, double endTime) throws SoundLayerException {
NoteList notes = new NoteList();
Collections.sort(this, sObjComparator);
for (SoundObject sObj : this) {
try {
double sObjStart = sObj.getStartTime();
double sObjDur = sObj.getSubjectiveDuration();
double sObjEnd = sObjStart + sObjDur;
if (sObjEnd > startTime) {
if (endTime <= startTime) {
double adjustedStart = startTime - sObjStart;
if (adjustedStart < 0.0f) {
adjustedStart = 0.0f;
}
notes.merge((sObj).generateForCSD(compileData, adjustedStart, -1.0f));
} else if (sObjStart < endTime) {
double adjustedStart = startTime - sObjStart;
double adjustedEnd = endTime - sObjStart;
if (adjustedStart < 0.0f) {
adjustedStart = 0.0f;
}
if (adjustedEnd >= sObjDur) {
adjustedEnd = -1.0f;
}
notes.merge((sObj).generateForCSD(compileData, adjustedStart, adjustedEnd));
}
}
} catch (Exception e) {
throw new SoundLayerException(this, "Error in SoundLayer: " + this.getName(), e);
}
}
try {
ScoreUtilities.applyNoteProcessorChain(notes, this.npc);
} catch (NoteProcessorException e) {
throw new SoundLayerException(this, "Error in SoundLayer: " + this.getName(), e);
}
return notes;
}
use of blue.soundObject.SoundObject in project blue by kunstmusik.
the class SoundObjectLibrary method checkAndAddInstanceSoundObjects.
public void checkAndAddInstanceSoundObjects(List<Instance> instanceSoundObjects) {
Map<SoundObject, SoundObject> originalToCopyMap = new HashMap<>();
for (Instance instance : instanceSoundObjects) {
final SoundObject instanceSObj = instance.getSoundObject();
if (!this.contains(instanceSObj)) {
SoundObject copy;
if (originalToCopyMap.containsKey(instanceSObj)) {
copy = originalToCopyMap.get(instanceSObj);
} else {
copy = instance.getSoundObject().deepCopy();
this.addSoundObject(copy);
originalToCopyMap.put(instanceSObj, copy);
}
instance.setSoundObject(copy);
}
}
}
use of blue.soundObject.SoundObject in project blue by kunstmusik.
the class SoundObjectLibrary method loadFromXML.
/* SERIALIZATION CODE */
public static SoundObjectLibrary loadFromXML(Element data, Map<String, Object> objRefMap) throws Exception {
SoundObjectLibrary sObjLib = new SoundObjectLibrary();
sObjLib.setInitializing(true);
Elements sObjects = data.getElements("soundObject");
int index = 0;
while (sObjects.hasMoreElements()) {
Element node = sObjects.next();
// skip adding of Instance but increment index
if ("blue.soundObject.Instance".equals(node.getAttributeValue("type"))) {
index++;
continue;
}
SoundObject sObj = (SoundObject) ObjectUtilities.loadFromXML(node, objRefMap);
sObjLib.add(sObj);
if (node.getAttribute("objRefId") != null) {
objRefMap.put(node.getAttributeValue("objRefId"), sObj);
} else {
objRefMap.put(Integer.toString(index++), sObj);
}
}
sObjLib.setInitializing(false);
return sObjLib;
}
use of blue.soundObject.SoundObject in project blue by kunstmusik.
the class OpenProjectAction method checkAudioFiles.
private static void checkAudioFiles(PolyObject pObj, ArrayList<String> filesList) {
for (Iterator<SoundObject> iter = pObj.getSoundObjects(true).iterator(); iter.hasNext(); ) {
SoundObject sObj = iter.next();
if (sObj instanceof AudioFile) {
AudioFile af = (AudioFile) sObj;
String soundFileName = af.getSoundFileName();
if (soundFileName == null) {
continue;
}
if (BlueSystem.findFile(soundFileName) == null) {
if (!filesList.contains(soundFileName)) {
filesList.add(soundFileName);
}
}
} else if (sObj instanceof PolyObject) {
checkAudioFiles((PolyObject) sObj, filesList);
}
}
}
Aggregations