use of blue.BlueData in project blue by kunstmusik.
the class ScoreSection method convertCSDtoBlue.
private static BlueData convertCSDtoBlue(String CSD, int importMode) {
BlueData data = new BlueData();
// String csOptions = TextUtilities.getTextBetweenTags("CsOptions",
// CSD);
// if (csOptions != null && csOptions.trim().length() > 0) {
// data.getProjectProperties().CsOptions = csOptions.trim();
// }
String orc = TextUtilities.getTextBetweenTags("CsInstruments", CSD);
String sco = TextUtilities.getTextBetweenTags("CsScore", CSD);
if (orc != null) {
parseCsOrc(data, orc);
}
if (sco != null) {
parseCsScore(data, sco, importMode);
}
if (data.getScore().get(0).isEmpty()) {
PolyObject pObj = (PolyObject) data.getScore().get(0);
pObj.add(new SoundLayer());
}
return data;
}
use of blue.BlueData in project blue by kunstmusik.
the class BlueProjectManager method createNewProject.
public static BlueProject createNewProject() {
final BlueData blueData = new BlueData();
BlueProject project = new BlueProject(blueData, null);
for (LayerGroup<?> layerGroup : blueData.getScore()) {
if (layerGroup instanceof PolyObject) {
PolyObject pObj = (PolyObject) layerGroup;
pObj.setDefaultHeightIndex(ProjectDefaultsSettings.getInstance().layerHeightDefault);
if (pObj.size() == 0) {
pObj.newLayerAt(-1);
}
}
}
blueData.getMixer().setEnabled(ProjectDefaultsSettings.getInstance().mixerEnabled);
ProjectProperties proj = blueData.getProjectProperties();
proj.author = ProjectDefaultsSettings.getInstance().defaultAuthor;
RealtimeRenderSettings rtSettings = RealtimeRenderSettings.getInstance();
proj.sampleRate = rtSettings.defaultSr;
proj.ksmps = rtSettings.defaultKsmps;
proj.channels = rtSettings.defaultNchnls;
proj.useZeroDbFS = rtSettings.useZeroDbFS;
proj.zeroDbFS = rtSettings.zeroDbFS;
proj.useAudioOut = rtSettings.audioOutEnabled;
proj.useAudioIn = rtSettings.audioInEnabled;
proj.useMidiIn = rtSettings.midiInEnabled;
proj.useMidiOut = rtSettings.midiOutEnabled;
proj.noteAmpsEnabled = rtSettings.noteAmpsEnabled;
proj.outOfRangeEnabled = rtSettings.outOfRangeEnabled;
proj.warningsEnabled = rtSettings.warningsEnabled;
proj.benchmarkEnabled = rtSettings.benchmarkEnabled;
proj.advancedSettings = rtSettings.advancedSettings;
// proj.commandLine = ProgramOptions.getDefaultCommandline();
DiskRenderSettings diskSettings = DiskRenderSettings.getInstance();
proj.diskSampleRate = diskSettings.defaultSr;
proj.diskKsmps = diskSettings.defaultKsmps;
proj.diskChannels = diskSettings.defaultNchnls;
proj.diskUseZeroDbFS = diskSettings.useZeroDbFS;
proj.diskZeroDbFS = diskSettings.zeroDbFS;
proj.diskNoteAmpsEnabled = diskSettings.noteAmpsEnabled;
proj.diskOutOfRangeEnabled = diskSettings.outOfRangeEnabled;
proj.diskWarningsEnabled = diskSettings.warningsEnabled;
proj.diskBenchmarkEnabled = diskSettings.benchmarkEnabled;
proj.diskAdvancedSettings = diskSettings.advancedSettings;
return project;
}
use of blue.BlueData in project blue by kunstmusik.
the class ImportOrcScoAction method importOrcSco.
public void importOrcSco() {
final Frame mainWindow = WindowManager.getDefault().getMainWindow();
List<File> rValue = FileChooserManager.getDefault().showOpenDialog(orcFilter, mainWindow);
if (rValue.isEmpty()) {
StatusDisplayer.getDefault().setStatusText(BlueSystem.getString("message.actionCancelled"));
return;
}
File orcFile = rValue.get(0);
rValue = FileChooserManager.getDefault().showOpenDialog(scoFilter, mainWindow);
if (rValue.isEmpty()) {
StatusDisplayer.getDefault().setStatusText(BlueSystem.getString("message.actionCancelled"));
return;
}
File scoFile = rValue.get(0);
final Object[] values = { BlueSystem.getString("csd.import1"), BlueSystem.getString("csd.import2"), BlueSystem.getString("csd.import3") };
Object selectedValue = JOptionPane.showInputDialog(mainWindow, BlueSystem.getString("csd.importMethod.message"), BlueSystem.getString("csd.importMethod.title"), JOptionPane.INFORMATION_MESSAGE, null, values, values[0]);
if (selectedValue == null) {
return;
}
int modeType = 0;
for (int i = 0; i < values.length; i++) {
if (selectedValue == values[i]) {
modeType = i;
break;
}
}
BlueData tempData = CSDUtility.convertOrcScoToBlue(orcFile, scoFile, modeType);
if (tempData != null) {
BlueProject project = new BlueProject(tempData, null);
BlueProjectManager.getInstance().setCurrentProject(project);
} else {
JOptionPane.showMessageDialog(mainWindow, BlueSystem.getString("message.file.couldNotImport"), BlueSystem.getString("message.error"), JOptionPane.ERROR_MESSAGE);
}
}
use of blue.BlueData in project blue by kunstmusik.
the class ImportMidiAction method importMidiFile.
public void importMidiFile() {
final Frame mainWindow = WindowManager.getDefault().getMainWindow();
List<File> rValue = FileChooserManager.getDefault().showOpenDialog(this.getClass(), mainWindow);
if (rValue.size() == 0) {
StatusDisplayer.getDefault().setStatusText(BlueSystem.getString("message.actionCancelled"));
return;
}
File midiFile = rValue.get(0);
BlueData tempData = new BlueData();
try {
PolyObject pObj = MidiImportUtilities.convertMidiFile(mainWindow, midiFile);
if (pObj == null) {
JOptionPane.showMessageDialog(mainWindow, BlueSystem.getString("message.file.couldNotImport"), BlueSystem.getString("message.error"), JOptionPane.ERROR_MESSAGE);
return;
}
tempData.getScore().clear();
tempData.getScore().add(pObj);
} catch (NoteParseException e) {
JOptionPane.showMessageDialog(mainWindow, BlueSystem.getString("message.file.couldNotImport"), BlueSystem.getString("message.error"), JOptionPane.ERROR_MESSAGE);
return;
}
BlueProject project = new BlueProject(tempData, null);
BlueProjectManager.getInstance().setCurrentProject(project);
}
use of blue.BlueData in project blue by kunstmusik.
the class OpenProjectAction method open.
public static void open(File selected) {
File absoluteSelected = selected.getAbsoluteFile();
File temp = absoluteSelected;
File backup = new File(absoluteSelected.getAbsolutePath() + "~");
boolean wasTempFile = false;
if (backup.exists() && backup.lastModified() > temp.lastModified()) {
String message = "A backup work file was found. This should only " + "occur if blue did not close successfully.\n\n" + "Would you like to open the backup file?\n\n" + "If you open the backup file, it will be required to " + "\"Save as\" the file to overwrite your old work.)";
NotifyDescriptor descriptor = new NotifyDescriptor.Confirmation(message, NotifyDescriptor.YES_NO_CANCEL_OPTION);
Object retVal = DialogDisplayer.getDefault().notify(descriptor);
if (retVal == NotifyDescriptor.YES_OPTION) {
temp = backup;
wasTempFile = true;
} else if (retVal == NotifyDescriptor.CANCEL_OPTION) {
return;
}
}
try {
String text = TextUtilities.getTextFromFile(temp);
BlueData tempData;
if (text.startsWith("<blueData")) {
Document d = new Document(text);
tempData = BlueData.loadFromXML(d.getElement("blueData"));
} else {
return;
// JOptionPane.showMessageDialog(this, BlueSystem.getString(
// "blue.pre94"));
//
// XMLSerializer xmlSer = new XMLSerializer();
// BufferedReader xmlIn = new BufferedReader(
// new StringReader(text));
//
// tempData = (BlueData) xmlSer.read(xmlIn);
//
// xmlIn.close();
// tempData.upgradeData();
}
// InstrumentLibrary iLibrary = tempData.getInstrumentLibrary();
//
// if (iLibrary != null) {
// tempData.normalizeArrangement();
// tempData.setInstrumentLibrary(null);
//
// // TODO - TRANSLATE
// String message = "This project contains an InstrumentLibrary \n" + "which is no longer being used in blue. The project's\n " + "orchestra will be updated to have individual copies of\n " + "each instrument from the library. \n\n" + "Upon saving, the InstrumentLibrary in this project will\n" + "no longer be accessible.\n\n" + "Would you like to import a copy of your library into " + "your user InstrumentLibrary?";
//
// int retVal = JOptionPane.showConfirmDialog(this, message);
//
// if (retVal == JOptionPane.YES_OPTION) {
// BlueSystem.getUserInstrumentLibrary().importLibrary(
// iLibrary);
// }
// }
BlueProject project;
if (wasTempFile) {
project = new BlueProject(tempData, null);
project.setTempFile(temp);
project.setOpenedFromTempFile(true);
} else {
project = new BlueProject(tempData, temp);
}
BlueProjectManager projectManager = BlueProjectManager.getInstance();
projectManager.setCurrentProject(project);
if (!temp.getAbsolutePath().endsWith("~")) {
RecentProjectsList.getInstance().addFile(temp.getAbsolutePath());
}
// this.blueDataFileArray.add(bdf);
temp = null;
// StatusBar.updateStatus(selected.getName() + " opened.");
checkDependencies(tempData);
} catch (FileNotFoundException fe) {
String message = "Error: Could not open " + temp.toString();
StatusDisplayer.getDefault().setStatusText(message);
NotifyDescriptor descriptor = new NotifyDescriptor.Message(message, NotifyDescriptor.ERROR_MESSAGE);
DialogDisplayer.getDefault().notify(descriptor);
} catch (Exception e) {
Exceptions.printStackTrace(e);
StatusDisplayer.getDefault().setStatusText("Error: Could not open " + temp.toString());
}
}
Aggregations