Search in sources :

Example 1 with ScoreScriptEngine

use of blue.scripting.ScoreScriptEngine 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 2 with ScoreScriptEngine

use of blue.scripting.ScoreScriptEngine 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)

Aggregations

NoteProcessorException (blue.noteProcessor.NoteProcessorException)2 ScoreScriptEngine (blue.scripting.ScoreScriptEngine)2 HashMap (java.util.HashMap)2 File (java.io.File)1 ScriptException (javax.script.ScriptException)1