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);
}
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);
}
Aggregations