Search in sources :

Example 1 with RenderTimeManager

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);
    }
}
Also used : BlueData(blue.BlueData) ScorePath(blue.ui.core.score.ScorePath) BlueProject(blue.projects.BlueProject) RenderTimeManager(blue.services.render.RenderTimeManager)

Example 2 with RenderTimeManager

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());
    }
}
Also used : ScoreGenerationException(blue.score.ScoreGenerationException) RenderTimeManager(blue.services.render.RenderTimeManager) SoundObjectException(blue.soundObject.SoundObjectException) File(java.io.File) CsdRenderResult(blue.services.render.CsdRenderResult)

Example 3 with RenderTimeManager

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);
}
Also used : Csound(csnd6.Csound) InputOutput(org.openide.windows.InputOutput) RenderTimeManager(blue.services.render.RenderTimeManager) Parameter(blue.automation.Parameter) IOException(java.io.IOException) CsoundArgVList(csnd6.CsoundArgVList)

Example 4 with RenderTimeManager

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();
    }
}
Also used : RenderTimeManager(blue.services.render.RenderTimeManager) SoundObjectException(blue.soundObject.SoundObjectException) File(java.io.File) NoteParseException(blue.soundObject.NoteParseException) IOException(java.io.IOException) SoundObjectException(blue.soundObject.SoundObjectException) CsdRenderResult(blue.services.render.CsdRenderResult)

Aggregations

RenderTimeManager (blue.services.render.RenderTimeManager)4 CsdRenderResult (blue.services.render.CsdRenderResult)2 SoundObjectException (blue.soundObject.SoundObjectException)2 File (java.io.File)2 IOException (java.io.IOException)2 BlueData (blue.BlueData)1 Parameter (blue.automation.Parameter)1 BlueProject (blue.projects.BlueProject)1 ScoreGenerationException (blue.score.ScoreGenerationException)1 NoteParseException (blue.soundObject.NoteParseException)1 ScorePath (blue.ui.core.score.ScorePath)1 Csound (csnd6.Csound)1 CsoundArgVList (csnd6.CsoundArgVList)1 InputOutput (org.openide.windows.InputOutput)1