use of org.openide.windows.InputOutput 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 org.openide.windows.InputOutput in project blue by kunstmusik.
the class CS6DiskRendererService method renderToDisk.
@Override
@SuppressWarnings("empty-statement")
public void renderToDisk(DiskRenderJob job) {
String csdPath = generateCsd(job.getData());
if (csdPath == null) {
return;
}
initialize();
Csound csound = new Csound();
blueCallbackWrapper = new BlueCallbackWrapper(csound);
blueCallbackWrapper.SetMessageCallback();
final InputOutput ioProvider = IOProvider.getDefault().getIO("Csound (Disk)", false);
try {
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 (");
String[] args = job.getArgs();
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 (job.getCurrentWorkingDirectory() != null) {
String sfdir = "--env:SFDIR=" + job.getCurrentWorkingDirectory().getAbsolutePath();
argsList.Append(sfdir);
ioProvider.getOut().append(" ").append(sfdir);
}
argsList.Append(csdPath);
ioProvider.getOut().append(" " + csdPath + " )\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;
}
while (csound.PerformKsmps() == 0 && keepRunning) {
}
;
csound.Stop();
csound.Cleanup();
csound.SetMessageCallback(null);
csound.Reset();
keepRunning = false;
notifyPlayModeListeners(PlayModeListener.PLAY_MODE_STOP);
}
Aggregations