Search in sources :

Example 1 with SoundObject

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;
}
Also used : SoundObject(blue.soundObject.SoundObject) Element(electric.xml.Element)

Example 2 with SoundObject

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;
}
Also used : NoteProcessorException(blue.noteProcessor.NoteProcessorException) NoteList(blue.soundObject.NoteList) SoundObject(blue.soundObject.SoundObject) NoteProcessorException(blue.noteProcessor.NoteProcessorException)

Example 3 with SoundObject

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);
        }
    }
}
Also used : SoundObject(blue.soundObject.SoundObject) HashMap(java.util.HashMap) Instance(blue.soundObject.Instance)

Example 4 with SoundObject

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;
}
Also used : SoundObject(blue.soundObject.SoundObject) Element(electric.xml.Element) Elements(electric.xml.Elements)

Example 5 with SoundObject

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);
        }
    }
}
Also used : AudioFile(blue.soundObject.AudioFile) SoundObject(blue.soundObject.SoundObject) PolyObject(blue.soundObject.PolyObject)

Aggregations

SoundObject (blue.soundObject.SoundObject)53 SoundLayer (blue.SoundLayer)12 Instance (blue.soundObject.Instance)11 PolyObject (blue.soundObject.PolyObject)11 ScoreObject (blue.score.ScoreObject)8 ArrayList (java.util.ArrayList)8 Element (electric.xml.Element)7 Point (java.awt.Point)7 IOException (java.io.IOException)6 BlueData (blue.BlueData)5 Layer (blue.score.layers.Layer)5 NoteList (blue.soundObject.NoteList)5 ScoreController (blue.ui.core.score.ScoreController)5 HashMap (java.util.HashMap)5 SoundObjectLibrary (blue.SoundObjectLibrary)4 ScoreObjectLayer (blue.score.layers.ScoreObjectLayer)4 Document (electric.xml.Document)4 ParseException (electric.xml.ParseException)4 File (java.io.File)4 LiveObject (blue.blueLive.LiveObject)3