Search in sources :

Example 6 with NoteProcessorException

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

the class Score method generateForCSD.

public NoteList generateForCSD(CompileData compileData, double startTime, double endTime) throws ScoreGenerationException {
    NoteList noteList = new NoteList();
    boolean soloFound = false;
    for (LayerGroup layerGroup : this) {
        soloFound = layerGroup.hasSoloLayers();
        if (soloFound) {
            break;
        }
    }
    for (LayerGroup layerGroup : this) {
        NoteList nl = layerGroup.generateForCSD(compileData, startTime, endTime, soloFound);
        noteList.merge(nl);
    }
    try {
        ScoreUtilities.applyNoteProcessorChain(noteList, this.npc);
    } catch (NoteProcessorException e) {
        throw new ScoreGenerationException(e);
    }
    return noteList;
}
Also used : NoteProcessorException(blue.noteProcessor.NoteProcessorException) NoteList(blue.soundObject.NoteList) LayerGroup(blue.score.layers.LayerGroup)

Example 7 with NoteProcessorException

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

the class ClojureObject method generateNotes.

protected final NoteList generateNotes(double renderStart, double renderEnd) throws SoundObjectException {
    String tempScore = null;
    File currentDirFile = BlueSystem.getCurrentProjectDirectory();
    HashMap<String, Object> initObjects = new HashMap<>();
    initObjects.put("score", "");
    initObjects.put("blueDuration", getSubjectiveDuration());
    initObjects.put("blueProjectDir", currentDirFile);
    try {
        tempScore = BlueClojureEngine.getInstance().processScript(clojureCode, initObjects, "score");
    } catch (ScriptException scriptEx) {
        String msg = "Clojure Error:\n" + getRootCauseException(scriptEx).toString();
        throw new SoundObjectException(this, msg);
    }
    NoteList nl;
    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) NoteList(blue.soundObject.NoteList) HashMap(java.util.HashMap) NoteParseException(blue.soundObject.NoteParseException) SoundObject(blue.soundObject.SoundObject) AbstractSoundObject(blue.soundObject.AbstractSoundObject) SoundObjectException(blue.soundObject.SoundObjectException) File(java.io.File)

Example 8 with NoteProcessorException

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

the class PianoRoll method generateNotes.

public NoteList generateNotes(double renderStart, double renderEnd) throws SoundObjectException {
    NoteList nl = new NoteList();
    String instrId = instrumentId;
    if (instrId != null) {
        instrId = instrId.trim();
    }
    try {
        Integer.parseInt(instrumentId);
    } catch (NumberFormatException nfe) {
        instrId = "\"" + instrId + "\"";
    }
    for (Iterator<PianoNote> iter = notes.iterator(); iter.hasNext(); ) {
        PianoNote n = iter.next();
        String freq = "";
        int octave = n.getOctave();
        int scaleDegree = n.getScaleDegree() + getTransposition();
        int numScaleDegrees;
        if (getPchGenerationMethod() == GENERATE_MIDI) {
            numScaleDegrees = 12;
        } else {
            numScaleDegrees = scale.getNumScaleDegrees();
        }
        if (scaleDegree >= numScaleDegrees) {
            octave += scaleDegree / numScaleDegrees;
            scaleDegree = scaleDegree % numScaleDegrees;
        }
        if (scaleDegree < 0) {
            int octaveDiff = (scaleDegree * -1) / numScaleDegrees;
            octaveDiff += 1;
            scaleDegree = scaleDegree % numScaleDegrees;
            octave -= octaveDiff;
            scaleDegree = numScaleDegrees + scaleDegree;
        }
        if (this.pchGenerationMethod == GENERATE_FREQUENCY) {
            double f = scale.getFrequency(octave, scaleDegree);
            freq = Double.toString(f);
        } else if (this.pchGenerationMethod == GENERATE_PCH) {
            freq = octave + "." + scaleDegree;
        } else if (this.pchGenerationMethod == GENERATE_MIDI) {
            freq = Integer.toString((octave * 12) + scaleDegree);
        }
        String template = n.getNoteTemplate();
        template = TextUtilities.replaceAll(template, "<INSTR_ID>", instrId);
        template = TextUtilities.replaceAll(template, "<INSTR_NAME>", instrumentId);
        template = TextUtilities.replaceAll(template, "<START>", Double.toString(n.getStart()));
        template = TextUtilities.replaceAll(template, "<DUR>", Double.toString(n.getDuration()));
        template = TextUtilities.replaceAll(template, "<FREQ>", freq);
        Note note = null;
        try {
            note = Note.createNote(template);
        } catch (NoteParseException e) {
            throw new SoundObjectException(this, e);
        }
        nl.add(note);
    }
    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 : NoteProcessorException(blue.noteProcessor.NoteProcessorException) PianoNote(blue.soundObject.pianoRoll.PianoNote) PianoNote(blue.soundObject.pianoRoll.PianoNote)

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