Search in sources :

Example 1 with SoundLayer

use of blue.SoundLayer in project blue by kunstmusik.

the class ScoreSection method convertCSDtoBlue.

private static BlueData convertCSDtoBlue(String CSD, int importMode) {
    BlueData data = new BlueData();
    // String csOptions = TextUtilities.getTextBetweenTags("CsOptions",
    // CSD);
    // if (csOptions != null && csOptions.trim().length() > 0) {
    // data.getProjectProperties().CsOptions = csOptions.trim();
    // }
    String orc = TextUtilities.getTextBetweenTags("CsInstruments", CSD);
    String sco = TextUtilities.getTextBetweenTags("CsScore", CSD);
    if (orc != null) {
        parseCsOrc(data, orc);
    }
    if (sco != null) {
        parseCsScore(data, sco, importMode);
    }
    if (data.getScore().get(0).isEmpty()) {
        PolyObject pObj = (PolyObject) data.getScore().get(0);
        pObj.add(new SoundLayer());
    }
    return data;
}
Also used : BlueData(blue.BlueData) SoundLayer(blue.SoundLayer)

Example 2 with SoundLayer

use of blue.SoundLayer in project blue by kunstmusik.

the class ScoreSection method setSoundObjectsPerInstrument.

// TODO - Possible problems with score processing here if SCO uses carry's,
// ramp's, etc.
private static void setSoundObjectsPerInstrument(BlueData data, ScoreSection section) {
    TreeMap map = new TreeMap();
    StringTokenizer st = new StringTokenizer(section.scoreText, "\n");
    String line = "";
    Note previousNote = null;
    Note note;
    Integer iNum;
    StringBuffer buffer;
    while (st.hasMoreTokens()) {
        line = st.nextToken();
        note = null;
        try {
            note = Note.createNote(line, previousNote);
        } catch (NoteParseException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        if (note == null) {
            continue;
        }
        iNum = new Integer(Integer.parseInt(note.getPField(1)));
        if (map.containsKey(iNum)) {
            buffer = (StringBuffer) map.get(iNum);
            buffer.append(line).append("\n");
        } else {
            buffer = new StringBuffer();
            buffer.append(line).append("\n");
            map.put(iNum, buffer);
        }
        previousNote = note;
    }
    SoundLayer sLayer;
    for (Iterator iter = map.entrySet().iterator(); iter.hasNext(); ) {
        Map.Entry entry = (Entry) iter.next();
        iNum = (Integer) entry.getKey();
        buffer = (StringBuffer) entry.getValue();
        if (buffer == null) {
            continue;
        }
        PolyObject pObj = (PolyObject) data.getScore().get(0);
        sLayer = pObj.newLayerAt(-1);
        String score = buffer.toString();
        NoteList notes;
        try {
            notes = ScoreUtilities.getNotes(score);
        } catch (NoteParseException e) {
            throw new RuntimeException(e);
        }
        notes.sort();
        double minStart = notes.get(0).getStartTime();
        ScoreUtilities.normalizeNoteList(notes);
        GenericScore genScore = createSizedGenericScore(notes.toString(), "Instrument " + iNum.toString());
        genScore.setStartTime(minStart + section.sectionStartTime);
        sLayer.add(genScore);
    }
}
Also used : Entry(java.util.Map.Entry) Entry(java.util.Map.Entry) SoundLayer(blue.SoundLayer)

Example 3 with SoundLayer

use of blue.SoundLayer in project blue by kunstmusik.

the class ImportSoundObjectAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    ScoreTimeCanvas sCanvas = (ScoreTimeCanvas) lGroupPanel;
    List<File> retVal = FileChooserManager.getDefault().showOpenDialog(IMPORT_DIALOG, WindowManager.getDefault().getMainWindow());
    if (!retVal.isEmpty()) {
        File f = retVal.get(0);
        Document doc;
        try {
            doc = new Document(f);
            Element root = doc.getRoot();
            if (root.getName().equals("soundObject")) {
                SoundObject tempSobj = (SoundObject) ObjectUtilities.loadFromXML(root, null);
                int start = p.x;
                Layer layer = scorePath.getGlobalLayerForY(p.y);
                if (timeState.isSnapEnabled()) {
                    int snapPixels = (int) (timeState.getSnapValue() * timeState.getPixelSecond());
                    start = start - (start % snapPixels);
                }
                float startTime = (float) start / timeState.getPixelSecond();
                tempSobj.setStartTime(startTime);
                ((SoundLayer) layer).add(tempSobj);
                AddScoreObjectEdit edit = new AddScoreObjectEdit((ScoreObjectLayer) layer, tempSobj);
                BlueUndoManager.setUndoManager("score");
                BlueUndoManager.addEdit(edit);
            } else {
                JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(), "Error: File did not contain Sound Object", "Error", JOptionPane.ERROR_MESSAGE);
            }
        } catch (Exception ex) {
            ex.printStackTrace();
            JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(), "Error: Could not read Sound Object from file", "Error", JOptionPane.ERROR_MESSAGE);
        }
    }
}
Also used : SoundObject(blue.soundObject.SoundObject) AddScoreObjectEdit(blue.ui.core.score.undo.AddScoreObjectEdit) SoundLayer(blue.SoundLayer) Element(electric.xml.Element) ScoreTimeCanvas(blue.ui.core.score.layers.soundObject.ScoreTimeCanvas) Document(electric.xml.Document) File(java.io.File) SoundLayer(blue.SoundLayer) ScoreObjectLayer(blue.score.layers.ScoreObjectLayer) Layer(blue.score.layers.Layer) Point(java.awt.Point)

Example 4 with SoundLayer

use of blue.SoundLayer in project blue by kunstmusik.

the class ScoreTimeCanvas method modifyLayerHeight.

public void modifyLayerHeight(int value, int y) {
    int index = getPolyObject().getLayerNumForY(y);
    if (index < 0 || index >= getPolyObject().size()) {
        return;
    }
    SoundLayer layer = getPolyObject().get(index);
    int hIndex = layer.getHeightIndex();
    if (value < 0 && hIndex < 1) {
        return;
    } else if (value > 0 && hIndex > SoundLayer.HEIGHT_MAX_INDEX - 1) {
        return;
    }
    layer.setHeightIndex(hIndex + value);
}
Also used : SoundLayer(blue.SoundLayer) Point(java.awt.Point)

Example 5 with SoundLayer

use of blue.SoundLayer in project blue by kunstmusik.

the class ScoreTimeCanvas method layerGroupChanged.

/* LAYER GROUP LISTENER */
@Override
public void layerGroupChanged(LayerGroupDataEvent event) {
    if (event.getType() == LayerGroupDataEvent.DATA_ADDED) {
        SoundLayer layer = getPolyObject().get(event.getStartIndex());
        layer.addPropertyChangeListener(heightListener);
        layer.addSoundLayerListener(this);
    }
    reset();
}
Also used : SoundLayer(blue.SoundLayer)

Aggregations

SoundLayer (blue.SoundLayer)27 SoundObject (blue.soundObject.SoundObject)10 PolyObject (blue.soundObject.PolyObject)9 Point (java.awt.Point)8 Layer (blue.score.layers.Layer)6 Instance (blue.soundObject.Instance)6 BlueData (blue.BlueData)5 ScoreObject (blue.score.ScoreObject)5 GenericScore (blue.soundObject.GenericScore)5 ArrayList (java.util.ArrayList)5 Score (blue.score.Score)3 AddScoreObjectEdit (blue.ui.core.score.undo.AddScoreObjectEdit)3 Test (org.junit.Test)3 SoundObjectLibrary (blue.SoundObjectLibrary)2 ScoreObjectLayer (blue.score.layers.ScoreObjectLayer)2 Parameter (blue.automation.Parameter)1 LinePoint (blue.components.lines.LinePoint)1 BlueSynthBuilder (blue.orchestra.BlueSynthBuilder)1 External (blue.soundObject.External)1 NoteList (blue.soundObject.NoteList)1