use of blue.soundObject.SoundObject in project blue by kunstmusik.
the class SoundObjectImportPane method importSoundObject.
private void importSoundObject() {
SoundObjectOption iOption = iTableModel.getSoundObjectOption(instrumentTable.getSelectedRow());
if (iOption == null) {
return;
}
try {
SoundObject soundObject = BlueShareRemoteCaller.getSoundObject(iOption);
if (soundObject == null) {
String error = "Error: Could not import this SoundObject.";
JOptionPane.showMessageDialog(null, error, BlueSystem.getString("message.error"), JOptionPane.ERROR_MESSAGE);
return;
}
// data.getOrchestra().addSoundObject(instrument);
// instrumentTreeModel.reload();
Library<SoundObject> instrLib = BlueSystem.getSoundObjectLibrary();
importSoundObjectToLibrary(instrLib, soundObject);
String message = BlueSystem.getString("blueShare.importSuccess");
JOptionPane.showMessageDialog(null, message, BlueSystem.getString("common.success"), JOptionPane.PLAIN_MESSAGE);
} catch (ParseException pe) {
String error = BlueSystem.getString("blueShare.selectServer.couldNotReadResponse");
JOptionPane.showMessageDialog(null, error, BlueSystem.getString("message.error"), JOptionPane.ERROR_MESSAGE);
return;
} catch (XmlRpcException xre) {
String error = "Error: " + xre.getLocalizedMessage();
JOptionPane.showMessageDialog(null, error, BlueSystem.getString("message.error"), JOptionPane.ERROR_MESSAGE);
return;
} catch (IOException ioe) {
String error = "Error: " + ioe.getLocalizedMessage();
JOptionPane.showMessageDialog(null, error, BlueSystem.getString("message.error"), JOptionPane.ERROR_MESSAGE);
return;
}
}
use of blue.soundObject.SoundObject in project blue by kunstmusik.
the class InstanceEditor method editScoreObject.
@Override
public void editScoreObject(ScoreObject sObj) {
if (sObj == null) {
instance = null;
return;
}
if (!sObj.getClass().getName().equals("blue.soundObject.Instance")) {
instance = null;
return;
}
this.instance = (Instance) sObj;
editorLabel.setText(BlueSystem.getString("instanceObject.instanceOf") + " " + instance.getSoundObject().getName());
String generatedNoteText = null;
try {
SoundObject clone = instance.getSoundObject().deepCopy();
generatedNoteText = clone.generateForCSD(CompileData.createEmptyCompileData(), 0.0f, -1.0f).toString();
} catch (Exception e) {
Exceptions.printStackTrace(e);
// TODO - TRANSLATE
generatedNoteText = "Could not generate notes";
}
scoreEditPane.setText(BlueSystem.getString("instanceObject.scoreGenMessage") + "\n\n" + generatedNoteText);
}
use of blue.soundObject.SoundObject in project blue by kunstmusik.
the class BlueSystem method saveSoundObjectLibrary.
public static void saveSoundObjectLibrary() {
if (soundObjectLibrary == null) {
return;
}
String userSObjFileName = BlueSystem.getUserConfigurationDirectory() + File.separator + "soundObjectLibrary.xml";
String tmpFileName = userSObjFileName + ".tmp";
PrintWriter out = null;
try {
out = new PrintWriter(new FileWriter(tmpFileName));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if (out != null) {
Map<Object, String> dummyRefMap = new HashMap<>();
String lib = soundObjectLibrary.saveAsXML(sObj -> sObj.getValue().saveAsXML(dummyRefMap)).toString();
out.print(lib);
out.flush();
out.close();
System.out.println("Saved SoundObject Library: " + userSObjFileName);
} else {
System.err.println("Unable to Save SoundObject Library: " + userSObjFileName);
return;
}
File f = new File(userSObjFileName);
if (f.exists()) {
File backup = new File(userSObjFileName + "~");
if (backup.exists()) {
backup.delete();
}
f.renameTo(backup);
}
f = new File(tmpFileName);
f.renameTo(new File(userSObjFileName));
}
use of blue.soundObject.SoundObject in project blue by kunstmusik.
the class BlueSystem method getSoundObjectLibrary.
public static Library<SoundObject> getSoundObjectLibrary() {
if (soundObjectLibrary == null) {
String userInstrFileName = BlueSystem.getUserConfigurationDirectory() + File.separator + "soundObjectLibrary.xml";
File f = new File(userInstrFileName);
if (f.exists()) {
boolean error = false;
try {
Document doc = new Document(f);
Map<String, Object> objRefMap = new HashMap<>();
soundObjectLibrary = Library.loadLibrary(doc.getRoot(), elem -> {
try {
return (SoundObject) ObjectUtilities.loadFromXML(elem, objRefMap);
} catch (Exception ex) {
throw new RuntimeException(ex);
}
});
} catch (ParseException e1) {
e1.printStackTrace();
error = true;
} catch (Exception e) {
e.printStackTrace();
error = true;
}
if (error) {
JOptionPane.showMessageDialog(null, "There was an error loading " + f.getAbsolutePath() + "\nPlease fix this file or remove it and restart blue.", "Error", JOptionPane.ERROR_MESSAGE);
System.exit(0);
}
} else {
soundObjectLibrary = Library.createLibrary("SoundObjects");
}
}
return soundObjectLibrary;
}
use of blue.soundObject.SoundObject in project blue by kunstmusik.
the class SoundLayer method loadFromXML.
public static SoundLayer loadFromXML(Element data, Map<String, Object> objRefMap) throws Exception {
SoundLayer sLayer = new SoundLayer();
sLayer.setName(data.getAttributeValue("name"));
sLayer.setMuted(Boolean.valueOf(data.getAttributeValue("muted")).booleanValue());
sLayer.setSolo(Boolean.valueOf(data.getAttributeValue("solo")).booleanValue());
String heightIndexStr = data.getAttributeValue("heightIndex");
if (heightIndexStr != null) {
sLayer.setHeightIndex(Integer.parseInt(heightIndexStr));
}
Element npcNode = data.getElement("noteProcessorChain");
if (npcNode != null) {
sLayer.setNoteProcessorChain(NoteProcessorChain.loadFromXML(npcNode));
}
Elements sObjects = data.getElements("soundObject");
while (sObjects.hasMoreElements()) {
Object obj = ObjectUtilities.loadFromXML(sObjects.next(), objRefMap);
sLayer.add((SoundObject) obj);
}
Elements parameters = data.getElements("parameterId");
while (parameters.hasMoreElements()) {
String id = parameters.next().getTextString();
sLayer.automationParameters.addParameterId(id);
}
return sLayer;
}
Aggregations