Search in sources :

Example 1 with BlueData

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;
}
Also used : BlueData(blue.BlueData) SoundLayer(blue.SoundLayer)

Example 2 with BlueData

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;
}
Also used : BlueData(blue.BlueData) RealtimeRenderSettings(blue.settings.RealtimeRenderSettings) DiskRenderSettings(blue.settings.DiskRenderSettings) ProjectProperties(blue.ProjectProperties) PolyObject(blue.soundObject.PolyObject)

Example 3 with BlueData

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);
    }
}
Also used : BlueData(blue.BlueData) Frame(java.awt.Frame) BlueProject(blue.projects.BlueProject) File(java.io.File)

Example 4 with BlueData

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);
}
Also used : BlueData(blue.BlueData) Frame(java.awt.Frame) NoteParseException(blue.soundObject.NoteParseException) BlueProject(blue.projects.BlueProject) File(java.io.File) PolyObject(blue.soundObject.PolyObject)

Example 5 with BlueData

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());
    }
}
Also used : BlueData(blue.BlueData) FileNotFoundException(java.io.FileNotFoundException) Document(electric.xml.Document) FileNotFoundException(java.io.FileNotFoundException) NotifyDescriptor(org.openide.NotifyDescriptor) PolyObject(blue.soundObject.PolyObject) SoundObject(blue.soundObject.SoundObject) AudioFile(blue.soundObject.AudioFile) File(java.io.File)

Aggregations

BlueData (blue.BlueData)46 BlueProject (blue.projects.BlueProject)18 PolyObject (blue.soundObject.PolyObject)9 File (java.io.File)9 SoundLayer (blue.SoundLayer)7 ScoreObject (blue.score.ScoreObject)7 Instance (blue.soundObject.Instance)6 CsdRenderResult (blue.services.render.CsdRenderResult)5 SoundObject (blue.soundObject.SoundObject)5 SoundObjectLibrary (blue.SoundObjectLibrary)4 Arrangement (blue.Arrangement)3 BlueSynthBuilder (blue.orchestra.BlueSynthBuilder)3 Layer (blue.score.layers.Layer)3 ScoreObjectLayer (blue.score.layers.ScoreObjectLayer)3 DiskRenderSettings (blue.settings.DiskRenderSettings)3 ScoreController (blue.ui.core.score.ScoreController)3 AddScoreObjectEdit (blue.ui.core.score.undo.AddScoreObjectEdit)3 Frame (java.awt.Frame)3 Point (java.awt.Point)3 IOException (java.io.IOException)3