use of blue.services.render.RenderTimeManager in project blue by kunstmusik.
the class AddMarkerAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
BlueProject project = BlueProjectManager.getInstance().getCurrentProject();
if (project == null) {
return;
}
BlueData data = project.getData();
if (data == null) {
return;
}
RenderTimeManager timeManager = Lookup.getDefault().lookup(RenderTimeManager.class);
ScorePath path = ScoreController.getInstance().getScorePath();
if (path.getLastLayerGroup() == null) {
double markerTime = MainToolBar.getInstance().isRendering() ? timeManager.getRenderTime() + timeManager.getRenderStartTime() : data.getRenderStartTime();
data.getMarkersList().addMarker(markerTime);
}
}
use of blue.services.render.RenderTimeManager in project blue by kunstmusik.
the class CommandlineRunner method render.
@Override
public void render() throws SoundObjectException {
if (this.data == null) {
return;
}
shouldStop = false;
String command;
try {
// String osName = System.getProperty("os.name");
command = ProjectPropertiesUtil.getRealtimeCommandLine(data.getProjectProperties());
// if (command.trim().length() == 0) {
// command = ProgramOptions.getDefaultCommandline();
// JOptionPane.showMessageDialog(null, BlueSystem
// .getString("message.noCommandLineSet")
// + " " + command);
//
// }
String globalSco = data.getGlobalOrcSco().getGlobalSco();
globalSco = TextUtilities.stripMultiLineComments(globalSco);
globalSco = TextUtilities.stripSingleLineComments(globalSco);
// System.out.println(tempoMapper);
// FIXME
// timeManager.setRootPolyObject(data.getPolyObject());
double startTime = data.getRenderStartTime();
double endTime = data.getRenderEndTime();
CsdRenderResult result = CSDRenderService.getDefault().generateCSD(data, startTime, endTime, true, false);
RenderTimeManager timeManager = Lookup.getDefault().lookup(RenderTimeManager.class);
timeManager.setTempoMapper(result.getTempoMapper());
String csd = result.getCsdText();
File temp = FileUtilities.createTempTextFile("tempCsd", ".csd", BlueSystem.getCurrentProjectDirectory(), csd);
// if (osName.indexOf("Windows") >= 0) {
command += " \"" + temp.getAbsolutePath() + "\"";
// } else {
// command += " " + temp.getAbsolutePath().replaceAll(" ", "\\\\ ");
// }
play(command, BlueSystem.getCurrentProjectDirectory(), data.getRenderStartTime());
} catch (SoundObjectException soe) {
throw soe;
} catch (ScoreGenerationException ex) {
NotificationDisplayer.getDefault().notify("Error", NotificationDisplayer.Priority.HIGH.getIcon(), BlueSystem.getString("message.generateScore.error") + "\n" + ex.getLocalizedMessage(), null);
System.err.println("[" + BlueSystem.getString("message.error") + "] " + ex.getLocalizedMessage());
}
}
use of blue.services.render.RenderTimeManager in project blue by kunstmusik.
the class CS6DiskRendererService method exec.
private void exec(String[] args, File currentWorkingDirectory, double startTime, TempoMapper mapper, ArrayList<Parameter> parameters) {
// csnd.csoundInitialize(null, null, csnd.CSOUNDINIT_NO_SIGNAL_HANDLER);
Csound csound = new Csound();
blueCallbackWrapper = new BlueCallbackWrapper(csound);
blueCallbackWrapper.SetMessageCallback();
final InputOutput ioProvider = IOProvider.getDefault().getIO("Csound", false);
try {
// this.io.closeInputOutput();
ioProvider.getOut().reset();
} catch (IOException ex) {
Exceptions.printStackTrace(ex);
}
IOColors.setColor(ioProvider, IOColors.OutputType.OUTPUT, Color.WHITE);
blueCallbackWrapper.setInputOutput(ioProvider);
notifyPlayModeListeners(PlayModeListener.PLAY_MODE_PLAY);
CsoundArgVList argsList = new CsoundArgVList();
ioProvider.getOut().append("Render Command (");
for (int i = 0; i < args.length; i++) {
if (args[i].startsWith("\"") && args[i].endsWith("\"")) {
args[i] = args[i].substring(1, args[i].length() - 1);
}
argsList.Append(args[i]);
ioProvider.getOut().append(" ").append(args[i]);
}
if (currentWorkingDirectory != null) {
String sfdir = "--env:SFDIR=" + currentWorkingDirectory.getAbsolutePath();
argsList.Append(sfdir);
ioProvider.getOut().append(" ").append(sfdir);
}
ioProvider.getOut().append(" )\n");
int retVal = csound.Compile(argsList.argc(), argsList.argv());
if (retVal != 0) {
notifyPlayModeListeners(PlayModeListener.PLAY_MODE_STOP);
csound.Stop();
csound.Cleanup();
csound.SetMessageCallback(null);
csound.Reset();
return;
}
int updateRate = (int) (csound.GetKr() / PlaybackSettings.getInstance().getPlaybackFPS());
int counter = 0;
RenderTimeManager manager = Lookup.getDefault().lookup(RenderTimeManager.class);
manager.initiateRender(startTime);
Parameter param;
do {
counter++;
double scoreTime = (double) csound.GetScoreTime();
if (counter > updateRate) {
manager.updateTimePointer(scoreTime);
counter = 0;
}
double currentTime = 0.0f;
if (startTime >= 0.0f) {
if (mapper != null) {
double renderStartSeconds = mapper.beatsToSeconds(startTime);
currentTime = mapper.secondsToBeats(scoreTime + renderStartSeconds);
currentTime -= startTime;
} else {
currentTime = startTime + scoreTime;
}
}
if (parameters != null) {
for (int i = 0; i < parameters.size(); i++) {
param = parameters.get(i);
String varName = param.getCompilationVarName();
double value = param.getValue(currentTime);
csound.SetChannel(varName, (double) value);
}
}
} while (csound.PerformKsmps() == 0 && keepRunning);
csound.Stop();
csound.Cleanup();
csound.SetMessageCallback(null);
csound.Reset();
manager.endRender();
keepRunning = false;
notifyPlayModeListeners(PlayModeListener.PLAY_MODE_STOP);
}
use of blue.services.render.RenderTimeManager in project blue by kunstmusik.
the class CS6RealtimeRenderService method render.
@Override
public void render() throws SoundObjectException {
if (this.data == null) {
return;
}
// csnd6.csoundInitialize(csnd6.CSOUNDINIT_NO_SIGNAL_HANDLER);
shouldStop = false;
String command;
try {
command = ProjectPropertiesUtil.getRealtimeCommandLine(data.getProjectProperties());
String globalSco = data.getGlobalOrcSco().getGlobalSco();
globalSco = TextUtilities.stripMultiLineComments(globalSco);
globalSco = TextUtilities.stripSingleLineComments(globalSco);
double startTime = data.getRenderStartTime();
double endTime = data.getRenderEndTime();
CsdRenderResult result = CSDRenderService.getDefault().generateCSD(data, startTime, endTime, true, true);
RenderTimeManager timeManager = Lookup.getDefault().lookup(RenderTimeManager.class);
timeManager.setTempoMapper(result.getTempoMapper());
String csd = result.getCsdText();
File temp = FileUtilities.createTempTextFile("tempCsd", ".csd", BlueSystem.getCurrentProjectDirectory(), csd);
String[] args = command.split("\\s+");
String[] args2 = new String[args.length + 1];
System.arraycopy(args, 0, args2, 0, args.length);
args2[args.length] = temp.getAbsolutePath();
play(null, result, args2, BlueSystem.getCurrentProjectDirectory(), startTime);
} catch (SoundObjectException soe) {
throw soe;
} catch (Exception ex) {
StatusDisplayer.getDefault().setStatusText("[" + BlueSystem.getString("message.error") + "] " + BlueSystem.getString("message.generateScore.error"));
ex.printStackTrace();
}
}
Aggregations