Search in sources :

Example 46 with Parameter

use of blue.automation.Parameter 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 47 with Parameter

use of blue.automation.Parameter in project blue by kunstmusik.

the class PasteBSBAsSoundAction method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    double start = (double) p.x / timeState.getPixelSecond();
    if (timeState.isSnapEnabled()) {
        start = ScoreUtilities.getSnapValueStart(start, timeState.getSnapValue());
    }
    Object obj = CopyBuffer.getBufferedObject(CopyBuffer.INSTRUMENT);
    Sound sound = new Sound();
    sound.setStartTime(start);
    BlueSynthBuilder bsbCopy = ((BlueSynthBuilder) obj).deepCopy();
    // clear out any existing automations
    for (Parameter param : bsbCopy.getParameterList()) {
        param.setAutomationEnabled(false);
        param.getLine().clear();
        param.getLine().addLinePoint(new LinePoint(0.0, param.getValue(0.0)));
        param.getLine().addLinePoint(new LinePoint(1.0, param.getValue(0.0)));
    }
    sound.setBlueSynthBuilder(bsbCopy);
    Layer layer = scorePath.getGlobalLayerForY(p.y);
    if (!layer.accepts(sound)) {
        JOptionPane.showMessageDialog(null, "Unable to paste due to target layers not " + "accepting types of objects within the copy buffer (i.e. trying to " + "paste a SoundObject into an AudioLayer");
        return;
    }
    SoundLayer sLayer = (SoundLayer) layer;
    sLayer.add(sound);
    BlueData data = BlueProjectManager.getInstance().getCurrentBlueData();
    AddScoreObjectEdit undoEdit = new AddScoreObjectEdit(sLayer, sound);
    BlueUndoManager.setUndoManager("score");
    BlueUndoManager.addEdit(undoEdit);
}
Also used : BlueData(blue.BlueData) LinePoint(blue.components.lines.LinePoint) AddScoreObjectEdit(blue.ui.core.score.undo.AddScoreObjectEdit) SoundLayer(blue.SoundLayer) Parameter(blue.automation.Parameter) ScoreObject(blue.score.ScoreObject) Sound(blue.soundObject.Sound) BlueSynthBuilder(blue.orchestra.BlueSynthBuilder) SoundLayer(blue.SoundLayer) Layer(blue.score.layers.Layer)

Aggregations

Parameter (blue.automation.Parameter)47 LinePoint (blue.components.lines.LinePoint)6 ParameterList (blue.automation.ParameterList)5 BigDecimal (java.math.BigDecimal)5 ArrayList (java.util.ArrayList)5 Automatable (blue.automation.Automatable)4 StringChannel (blue.orchestra.blueSynthBuilder.StringChannel)4 Instrument (blue.orchestra.Instrument)3 StrBuilder (org.apache.commons.lang3.text.StrBuilder)3 InstrumentAssignment (blue.InstrumentAssignment)2 Channel (blue.mixer.Channel)2 ChannelList (blue.mixer.ChannelList)2 GenericInstrument (blue.orchestra.GenericInstrument)2 NoteParseException (blue.soundObject.NoteParseException)2 Sound (blue.soundObject.Sound)2 Arrangement (blue.Arrangement)1 BlueData (blue.BlueData)1 CompileData (blue.CompileData)1 GlobalOrcSco (blue.GlobalOrcSco)1 SoundLayer (blue.SoundLayer)1