use of blue.CompileData in project blue by kunstmusik.
the class PolyObjectEditor method testSoundObject.
public final void testSoundObject() {
if (this.pObj == null) {
return;
}
BlueData data = BlueProjectManager.getInstance().getCurrentBlueData();
if (data == null) {
System.err.println("PolyObjectEditor::testSoundObject() - " + "Could not get reference to current BlueData object");
return;
}
Tables tables = new Tables(data.getTableSet());
Arrangement arrangement = new Arrangement(data.getArrangement());
PolyObject tempPObj = new PolyObject(this.pObj);
OpcodeList opcodeList = new OpcodeList(data.getOpcodeList());
GlobalOrcSco globalOrcSco = new GlobalOrcSco(data.getGlobalOrcSco());
// adding all compile-time instruments from soundObjects to arrangement
arrangement.generateFTables(tables);
CompileData compileData = new CompileData(arrangement, tables);
// grabbing all notes from soundObjects
NoteList generatedNotes = null;
try {
generatedNotes = tempPObj.generateForCSD(compileData, 0.0f, -1.0f);
} catch (Exception e) {
Exceptions.printStackTrace(e);
return;
}
if (generatedNotes != null) {
InfoDialog.showInformationDialog(SwingUtilities.getRoot(this), generatedNotes.toString(), BlueSystem.getString("soundObject.generatedScore"));
}
}
use of blue.CompileData in project blue by kunstmusik.
the class CSDRender method generateCSDForBlueLiveImpl.
@Override
protected synchronized CsdRenderResult generateCSDForBlueLiveImpl(BlueData data, boolean usingAPI) {
ProjectPluginManager.getInstance().preRender(data);
StringChannelNameManager scnm = new StringChannelNameManager();
ArrayList<StringChannel> stringChannels = getStringChannels(data.getArrangement(), scnm);
ParameterHelper.clearCompilationVarNames(data);
double totalDur = 36000f;
// making copies to use for adding compileTime tables and instruments
Tables tables = new Tables(data.getTableSet());
ArrayList<Parameter> originalParameters = null;
if (usingAPI) {
originalParameters = ParameterHelper.getAllParameters(data.getArrangement(), data.getMixer());
assignParameterNames(originalParameters, new ParameterNameManager());
}
Arrangement arrangement = new Arrangement(data.getArrangement());
arrangement.clearUnusedInstrAssignments();
String[] instrIds = arrangement.getInstrumentIds();
// PolyObject tempPObj = (PolyObject) data.getPolyObject().clone();
boolean hasInstruments = arrangement.size() > 0;
GlobalOrcSco globalOrcSco = new GlobalOrcSco(data.getGlobalOrcSco());
OpcodeList udos = new OpcodeList(data.getOpcodeList());
// add all UDO's from instruments and effects
arrangement.generateUserDefinedOpcodes(udos);
appendFtgenTableNumbers(globalOrcSco.getGlobalOrc(), tables);
arrangement.generateFTables(tables);
CompileData compileData = new CompileData(arrangement, tables);
// SKIPPING ANYTHING RELATED TO SCORE
boolean mixerEnabled = data.getMixer().isEnabled();
Mixer mixer = null;
if (mixerEnabled) {
mixer = new Mixer(data.getMixer());
assignChannelIds(compileData, mixer);
}
boolean generateMixer = mixerEnabled && (hasInstruments || mixer.hasSubChannelDependencies());
int nchnls = getNchnls(data, true);
ArrayList<Instrument> alwaysOnInstruments = new ArrayList<>();
arrangement.preGenerateOrchestra(compileData, mixer, nchnls, alwaysOnInstruments);
String globalSco = globalOrcSco.getGlobalSco() + "\n";
globalSco += arrangement.generateGlobalSco(compileData) + "\n";
globalSco = preprocessSco(globalSco, totalDur, 0, 0, null);
NoteList generatedNotes = null;
for (Instrument instrument : alwaysOnInstruments) {
String sourceId = compileData.getInstrSourceId(instrument);
if (StringUtils.isNumeric(sourceId)) {
int instrId = arrangement.addInstrumentAtEnd(instrument);
globalSco += "i" + instrId + " 0 " + totalDur + "\n";
} else {
String instrId = sourceId + "_alwaysOn";
arrangement.addInstrumentWithId(instrument, instrId, false);
globalSco += "i \"" + instrId + "\" 0 " + totalDur + "\n";
}
}
if (usingAPI) {
// ArrayList parameters = ParameterHelper.getAllParameters(
// arrangement, mixer);
generatedNotes = new NoteList();
handleParametersForBlueLive(originalParameters, stringChannels, globalOrcSco, generatedNotes, arrangement, usingAPI);
}
if (generateMixer) {
final String mixerId = "BlueMixer";
clearUnusedMixerChannels(mixer, arrangement);
globalOrcSco.appendGlobalOrc(mixer.getInitStatements(compileData, nchnls));
arrangement.addInstrumentWithId(mixer.getMixerInstrument(compileData, udos, nchnls), mixerId, false);
globalSco += "i \"BlueMixer\" 0 " + totalDur;
}
arrangement.addInstrument("blueAllNotesOff", createAllNotesOffInstrument(instrIds));
String ftables = tables.getTables();
StrBuilder score = new StrBuilder();
score.append("<CsoundSynthesizer>\n\n");
appendCsInstruments(compileData, data, udos, arrangement, globalOrcSco, score, mixer, true);
appendCsScore(globalSco, ftables, generatedNotes, totalDur, score);
score.append("</CsoundSynthesizer>");
// Tempo tempo = data.getScore().getTempo();
TempoMapper tempoMapper = null;
// if (tempo.isEnabled()) {
// tempoMapper = CSDRender.getTempoMapper(tempo);
// } else {
// tempoMapper = CSDRender.getTempoMapper(globalSco);
// }
CsdRenderResult renderResult = new CsdRenderResult(score.toString(), tempoMapper, originalParameters, stringChannels);
return renderResult;
}
Aggregations