Search in sources :

Example 1 with NoteProcessorException

use of blue.noteProcessor.NoteProcessorException in project blue by kunstmusik.

the class JMask method generateNotes.

public NoteList generateNotes(double renderStart, double renderEnd) throws SoundObjectException {
    Field temp = new Field(field);
    Random rnd = seedUsed ? new Random(seed) : new Random();
    NoteList nl = temp.generateNotes(this.getSubjectiveDuration(), rnd);
    try {
        ScoreUtilities.applyNoteProcessorChain(nl, this.npc);
    } catch (NoteProcessorException e) {
        throw new SoundObjectException(this, e);
    }
    ScoreUtilities.applyTimeBehavior(nl, this.getTimeBehavior(), this.getSubjectiveDuration(), this.getRepeatPoint());
    ScoreUtilities.setScoreStart(nl, startTime);
    return nl;
}
Also used : Field(blue.soundObject.jmask.Field) NoteProcessorException(blue.noteProcessor.NoteProcessorException) Random(java.util.Random)

Example 2 with NoteProcessorException

use of blue.noteProcessor.NoteProcessorException in project blue by kunstmusik.

the class ObjectBuilder method generateNotes.

// GENERATION METHODS
public NoteList generateNotes(BSBCompilationUnit bsbCompilationUnit, double renderStart, double renderEnd) throws SoundObjectException {
    String codeToRun = bsbCompilationUnit.replaceBSBValues(code);
    String tempScore = null;
    NoteList nl;
    Map<String, Object> initVals = new HashMap<>();
    File currentDirFile = BlueSystem.getCurrentProjectDirectory();
    initVals.put("score", "");
    initVals.put("blueDuration", getSubjectiveDuration());
    initVals.put("commandline", this.commandLine);
    initVals.put("blueProjectDir", currentDirFile);
    ScoreScriptEngine engine = ScoreScriptEngineManager.getInstance().getEngine(getLanguageType().toString());
    try {
        tempScore = engine.evalCode(codeToRun, initVals);
    } catch (ScriptException ex) {
        if (getLanguageType() == LanguageType.EXTERNAL) {
            throw new SoundObjectException(this, getIOExceptionMessage(), ex);
        } else {
            throw new SoundObjectException(this, ex);
        }
    }
    try {
        nl = ScoreUtilities.getNotes(tempScore);
    } catch (NoteParseException e) {
        throw new SoundObjectException(this, e);
    }
    try {
        ScoreUtilities.applyNoteProcessorChain(nl, this.npc);
    } catch (NoteProcessorException e) {
        throw new SoundObjectException(this, e);
    }
    ScoreUtilities.applyTimeBehavior(nl, this.getTimeBehavior(), this.getSubjectiveDuration(), this.getRepeatPoint());
    ScoreUtilities.setScoreStart(nl, startTime);
    return nl;
}
Also used : ScriptException(javax.script.ScriptException) NoteProcessorException(blue.noteProcessor.NoteProcessorException) HashMap(java.util.HashMap) ScoreScriptEngine(blue.scripting.ScoreScriptEngine) File(java.io.File)

Example 3 with NoteProcessorException

use of blue.noteProcessor.NoteProcessorException 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 4 with NoteProcessorException

use of blue.noteProcessor.NoteProcessorException in project blue by kunstmusik.

the class External method generateNotes.

public final NoteList generateNotes(double renderStart, double renderEnd) throws SoundObjectException {
    if (commandLine.trim().length() == 0 && getText().trim().length() == 0) {
        return null;
    }
    NoteList nl = new NoteList();
    ScoreScriptEngine engine = ScoreScriptEngineManager.getInstance().getEngine("External");
    Map<String, Object> initVals = new HashMap<>();
    initVals.put("commandline", this.commandLine);
    try {
        String temp = engine.evalCode(this.text, initVals);
        nl = blue.utility.ScoreUtilities.getNotes(temp);
    } catch (Exception ex) {
        throw new SoundObjectException(this, getIOExceptionMessage(), ex);
    }
    try {
        ScoreUtilities.applyNoteProcessorChain(nl, this.npc);
    } catch (NoteProcessorException npe) {
        throw new SoundObjectException(this, npe);
    }
    ScoreUtilities.applyTimeBehavior(nl, this.getTimeBehavior(), this.getSubjectiveDuration(), this.getRepeatPoint());
    ScoreUtilities.setScoreStart(nl, this.getStartTime());
    return nl;
}
Also used : NoteProcessorException(blue.noteProcessor.NoteProcessorException) HashMap(java.util.HashMap) ScoreScriptEngine(blue.scripting.ScoreScriptEngine) NoteProcessorException(blue.noteProcessor.NoteProcessorException)

Example 5 with NoteProcessorException

use of blue.noteProcessor.NoteProcessorException in project blue by kunstmusik.

the class PatternObject method generateNotes.

/* COMPILATION METHODS */
public NoteList generateNotes(double renderStart, double renderEnd) throws SoundObjectException {
    NoteList tempNoteList = new NoteList();
    // check if solo is selected, if so, return only that layer's notes if
    // not muted
    boolean soloFound = false;
    double timeIncrement = 1.0f / this.subDivisions;
    for (int i = 0; i < this.size(); i++) {
        Pattern p = this.getPattern(i);
        if (p.isSolo() && !p.isMuted()) {
            soloFound = true;
            boolean[] tempPatternArray = p.values;
            for (int j = 0; j < tempPatternArray.length; j++) {
                if (tempPatternArray[j]) {
                    NoteList tempPattern;
                    try {
                        tempPattern = ScoreUtilities.getNotes(p.getPatternScore());
                    } catch (NoteParseException e) {
                        throw new SoundObjectException(this, e);
                    }
                    double start = (j * timeIncrement);
                    ScoreUtilities.setScoreStart(tempPattern, start);
                    tempNoteList.merge(tempPattern);
                }
            }
        }
    }
    if (!soloFound) {
        for (int i = 0; i < this.size(); i++) {
            Pattern p = this.getPattern(i);
            if (!p.isMuted()) {
                boolean[] tempPatternArray = p.values;
                for (int j = 0; j < tempPatternArray.length; j++) {
                    if (tempPatternArray[j]) {
                        NoteList tempPattern;
                        try {
                            tempPattern = ScoreUtilities.getNotes(p.getPatternScore());
                        } catch (NoteParseException e) {
                            throw new SoundObjectException(this, e);
                        }
                        double start = (j * timeIncrement);
                        ScoreUtilities.setScoreStart(tempPattern, start);
                        tempNoteList.merge(tempPattern);
                    }
                }
            }
        }
    }
    try {
        ScoreUtilities.applyNoteProcessorChain(tempNoteList, this.npc);
    } catch (NoteProcessorException e) {
        throw new SoundObjectException(this, e);
    }
    ScoreUtilities.applyTimeBehavior(tempNoteList, this.getTimeBehavior(), this.getSubjectiveDuration(), this.getRepeatPoint(), beats);
    ScoreUtilities.setScoreStart(tempNoteList, startTime);
    return tempNoteList;
}
Also used : Pattern(blue.soundObject.pattern.Pattern) NoteProcessorException(blue.noteProcessor.NoteProcessorException)

Aggregations

NoteProcessorException (blue.noteProcessor.NoteProcessorException)8 NoteList (blue.soundObject.NoteList)3 HashMap (java.util.HashMap)3 ScoreScriptEngine (blue.scripting.ScoreScriptEngine)2 SoundObject (blue.soundObject.SoundObject)2 File (java.io.File)2 ScriptException (javax.script.ScriptException)2 LayerGroup (blue.score.layers.LayerGroup)1 AbstractSoundObject (blue.soundObject.AbstractSoundObject)1 NoteParseException (blue.soundObject.NoteParseException)1 SoundObjectException (blue.soundObject.SoundObjectException)1 Field (blue.soundObject.jmask.Field)1 Pattern (blue.soundObject.pattern.Pattern)1 PianoNote (blue.soundObject.pianoRoll.PianoNote)1 Random (java.util.Random)1