use of blue.mixer.Channel in project blue by kunstmusik.
the class Arrangement method convertBlueMixerOut.
// TODO - Make this more efficient (made this way in case blueMixerOut is in
// comments
private String convertBlueMixerOut(CompileData data, Mixer mixer, String arrangementId, String input, int nchnls) {
if (!input.contains("blueMixerOut") && !input.contains("blueMixerIn")) {
return input;
}
StrBuilder buffer = new StrBuilder();
String[] lines = NEW_LINES.split(input);
boolean blueMixerInFound = false;
for (String line : lines) {
int mixerInIndex = line.indexOf("blueMixerIn");
if (mixerInIndex > 0) {
String noCommentLine = TextUtilities.stripSingleLineComments(line);
if (!noCommentLine.contains("blueMixerIn")) {
buffer.append(line).append("\n");
continue;
}
if (mixer == null || !mixer.isEnabled()) {
throw new RuntimeException("Error: Instrument uses blueMixerIn but mixer is not enabled");
}
blueMixerInFound = true;
String argText = noCommentLine.substring(0, mixerInIndex).trim();
String[] args = argText.split(",");
Channel c = getChannelForArrangementId(mixer, arrangementId);
for (int i = 0; i < nchnls && i < args.length; i++) {
String arg = args[i];
String var;
if (c == null) {
var = Mixer.getSubChannelVar(Channel.MASTER, i);
} else {
var = Mixer.getChannelVar(data.getChannelIdAssignments().get(c), i);
}
buffer.append(arg).append(" = ");
buffer.append(var).append("\n");
}
} else if (line.trim().startsWith("blueMixerOut")) {
String argText = line.trim().substring(12);
String[] args = argText.split(",");
if (args[0].trim().matches("\".*\"")) {
if (mixer == null || !mixer.isEnabled()) {
buffer.append("outc ");
for (int i = 1; i < args.length; i++) {
if (i > 1) {
buffer.append(",");
}
buffer.append(args[i]);
}
buffer.append("\n");
} else {
String subChanBase = args[0].trim();
final String subChannelName = subChanBase.substring(1, subChanBase.length() - 1);
Optional<Channel> found = mixer.getSubChannels().stream().filter(chn -> subChannelName.equals(chn.getName())).findFirst();
if (!found.isPresent()) {
throw new RuntimeException("Unable to find subchannel with name: " + subChannelName);
}
mixer.addSubChannelDependency(subChannelName);
for (int i = 1; i < nchnls + 1 && i < args.length; i++) {
String arg = args[i];
String var = Mixer.getSubChannelVar(subChannelName, i - 1);
buffer.append(var);
if (!blueMixerInFound) {
buffer.append(" += ");
} else {
buffer.append(" = ");
}
buffer.append(arg).append("\n");
}
}
} else if (mixer == null || !mixer.isEnabled()) {
buffer.append(line.replaceAll("blueMixerOut", "outc"));
buffer.append("\n");
} else {
Channel c = getChannelForArrangementId(mixer, arrangementId);
for (int i = 0; i < nchnls && i < args.length; i++) {
String arg = args[i];
String var;
if (c == null) {
var = Mixer.getSubChannelVar(Channel.MASTER, i);
} else {
var = Mixer.getChannelVar(data.getChannelIdAssignments().get(c), i);
}
buffer.append(var);
if (!blueMixerInFound) {
buffer.append(" += ");
} else {
buffer.append(" = ");
}
buffer.append(arg).append("\n");
}
}
} else {
buffer.append(line).append("\n");
}
}
return buffer.toString();
}
use of blue.mixer.Channel in project blue by kunstmusik.
the class AutomationManager method getAutomationMenu.
public JPopupMenu getAutomationMenu(ParameterIdList paramIdList) {
this.selectedParamIdList = paramIdList;
// if (menu == null || dirty) {
JPopupMenu menu = new JPopupMenu();
// Build Instrument Menu
JMenu instrRoot = new JMenu("Instrument");
MenuScroller.setScrollerFor(instrRoot);
Arrangement arrangement = data.getArrangement();
for (int i = 0; i < arrangement.size(); i++) {
InstrumentAssignment ia = arrangement.getInstrumentAssignment(i);
if (ia.enabled && ia.instr instanceof Automatable) {
ParameterList params = ((Automatable) ia.instr).getParameterList();
if (params.size() <= 0) {
continue;
}
final JMenu instrMenu = new JMenu();
MenuScroller.setScrollerFor(instrMenu);
instrMenu.setText(ia.arrangementId + ") " + ia.instr.getName());
for (Parameter param : params.sorted()) {
JMenuItem paramItem = new JMenuItem();
paramItem.setText(param.getName());
paramItem.addActionListener(parameterActionListener);
if (param.isAutomationEnabled()) {
if (paramIdList.contains(param.getUniqueId())) {
paramItem.setForeground(Color.GREEN);
} else {
paramItem.setForeground(Color.ORANGE);
}
}
paramItem.putClientProperty("instr", ia.instr);
paramItem.putClientProperty("param", param);
instrMenu.add(paramItem);
}
instrRoot.add(instrMenu);
}
}
menu.add(instrRoot);
// Build Mixer Menu
Mixer mixer = data.getMixer();
if (mixer.isEnabled()) {
JMenu mixerRoot = new JMenu("Mixer");
MenuScroller.setScrollerFor(mixerRoot);
// add channels
ChannelList channels = mixer.getChannels();
if (channels.size() > 0) {
JMenu channelsMenu = new JMenu("Channels");
for (int i = 0; i < channels.size(); i++) {
channelsMenu.add(buildChannelMenu(channels.get(i), paramIdList));
}
mixerRoot.add(channelsMenu);
}
// add subchannels
ChannelList subChannels = mixer.getSubChannels();
if (subChannels.size() > 0) {
JMenu subChannelsMenu = new JMenu("Sub-Channels");
for (int i = 0; i < subChannels.size(); i++) {
subChannelsMenu.add(buildChannelMenu(subChannels.get(i), paramIdList));
}
mixerRoot.add(subChannelsMenu);
}
// add master channel
Channel master = mixer.getMaster();
mixerRoot.add(buildChannelMenu(master, paramIdList));
menu.add(mixerRoot);
}
menu.addSeparator();
JMenuItem clearAll = new JMenuItem("Clear All");
clearAll.addActionListener((ActionEvent e) -> {
Object retVal = DialogDisplayer.getDefault().notify(new NotifyDescriptor.Confirmation("Please Confirm Clearing All Parameter Data for this SoundLayer"));
if (retVal == NotifyDescriptor.YES_OPTION) {
ParameterIdList idList = selectedParamIdList;
for (String paramId : idList.getParameters()) {
Parameter param = getParameter(paramId);
param.setAutomationEnabled(false);
idList.removeParameterId(paramId);
}
}
});
menu.add(clearAll);
clearAll.setEnabled(selectedParamIdList.size() > 0);
// System.err.println(parameterMap);
return menu;
}
use of blue.mixer.Channel in project blue by kunstmusik.
the class AudioHeaderListPanel method layersAdded.
public void layersAdded(LayerGroupDataEvent e) {
final int index = e.getStartIndex();
final AudioLayer sLayer = layerGroup.get(index);
SwingUtilities.invokeLater(() -> {
Channel c = mixer.findChannelById(sLayer.getUniqueId());
AudioHeaderLayerPanel panel = new AudioHeaderLayerPanel(sLayer, c);
add(panel, index);
checkSize();
});
}
use of blue.mixer.Channel in project blue by kunstmusik.
the class AudioLayer method generateInstrumentForAudioLayer.
protected int generateInstrumentForAudioLayer(CompileData compileData) {
if (compileData.getCompilationVariable(this.uniqueId) != null) {
return (Integer) compileData.getCompilationVariable(this.uniqueId);
}
Map<Channel, Integer> assignments = compileData.getChannelIdAssignments();
Channel c = null;
for (Channel channel : assignments.keySet()) {
if (uniqueId.equals(channel.getAssociation())) {
c = channel;
}
}
GenericInstrument instr = new GenericInstrument();
StringBuilder str = new StringBuilder();
try {
try (BufferedReader br = new BufferedReader(new InputStreamReader(this.getClass().getResourceAsStream("playback_instrument.orc")))) {
String line;
while ((line = br.readLine()) != null) {
str.append(line).append("\n");
}
}
} catch (IOException ioe) {
throw new RuntimeException("[error] AudioLayer could not load instr text");
}
if (c != null) {
int channelId = assignments.get(c);
String var1 = Mixer.getChannelVar(channelId, 0);
String var2 = Mixer.getChannelVar(channelId, 1);
instr.setText(getInstrumentText(var1, var2));
// System.out.println("Instr Text: " + instr.getText());
} else {
throw new RuntimeException("Error: could not find Mixer Channels for Audio layer");
// instr.setText(getInstrumentText("a1", "a2") + "\noutc a1, a2\n");
}
int instrId = compileData.addInstrument(instr);
compileData.setCompilationVariable(this.uniqueId, instrId);
return instrId;
}
use of blue.mixer.Channel in project blue by kunstmusik.
the class CSDRender method assignChannelIds.
private void assignChannelIds(CompileData compileData, Mixer mixer) {
Map<Channel, Integer> assignments = compileData.getChannelIdAssignments();
int i = 0;
for (Channel channel : mixer.getAllSourceChannels()) {
assignments.put(channel, i++);
}
for (Channel channel : mixer.getSubChannels()) {
assignments.put(channel, i++);
}
assignments.put(mixer.getMaster(), i);
}
Aggregations