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;
}
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;
}
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;
}
Aggregations