Search in sources :

Example 11 with PolyObject

use of blue.soundObject.PolyObject in project blue by kunstmusik.

the class AutomationManager method layerGroupChanged.

@Override
public void layerGroupChanged(LayerGroupDataEvent event) {
    if (event.getType() != LayerGroupDataEvent.DATA_REMOVED || !(event.getSource() instanceof PolyObject)) {
        return;
    }
    final ArrayList<Layer> layers = event.getLayers();
    if (layers == null) {
        return;
    }
    for (Layer layer : layers) {
        SoundLayer sLayer = (SoundLayer) layer;
        ParameterIdList idList = sLayer.getAutomationParameters();
        for (int i = 0; i < idList.size(); i++) {
            String paramId = idList.getParameterId(i);
            Parameter param = getParameter(paramId);
            if (param != null) {
                param.setAutomationEnabled(false);
            }
        }
    }
}
Also used : SoundLayer(blue.SoundLayer) SoundLayer(blue.SoundLayer) Layer(blue.score.layers.Layer) PolyObject(blue.soundObject.PolyObject)

Example 12 with PolyObject

use of blue.soundObject.PolyObject in project blue by kunstmusik.

the class AutomationManager method parameterRemoved.

public void parameterRemoved(Parameter param) {
    allParameters.remove(param);
    for (LayerGroup<? extends Layer> layerGroup : score) {
        if (layerGroup instanceof PolyObject) {
            PolyObject pObj = (PolyObject) layerGroup;
            for (SoundLayer layer : pObj) {
                ParameterIdList automationParameters = layer.getAutomationParameters();
                String paramId = param.getUniqueId();
                if (automationParameters.contains(paramId)) {
                    automationParameters.removeParameterId(paramId);
                }
            }
        }
    }
// dirty = true;
}
Also used : SoundLayer(blue.SoundLayer) PolyObject(blue.soundObject.PolyObject)

Example 13 with PolyObject

use of blue.soundObject.PolyObject in project blue by kunstmusik.

the class AutomationManager method parameterSelected.

/**
 * When parameter is selected, check if this parameter is in use and if by
 * this soundLayer, turn it off, otherwise move it to this soundLayer.
 *
 * @param soundLayer
 * @param param
 */
private void parameterSelected(ParameterIdList paramIdList, Parameter param) {
    String uniqueId = param.getUniqueId();
    if (param.isAutomationEnabled()) {
        if (paramIdList.contains(uniqueId)) {
            param.setAutomationEnabled(false);
            paramIdList.removeParameterId(uniqueId);
        } else {
            // TODO - This class needs further updating for generic
            // LayerGroup Design
            Score score = data.getScore();
            for (LayerGroup<? extends Layer> layerGroup : score) {
                if (!(layerGroup instanceof PolyObject)) {
                    continue;
                }
                PolyObject pObj = (PolyObject) layerGroup;
                for (SoundLayer layer : pObj) {
                    if (layer.getAutomationParameters() == paramIdList) {
                        continue;
                    }
                    ParameterIdList automationParameters = layer.getAutomationParameters();
                    if (automationParameters.contains(uniqueId)) {
                        automationParameters.removeParameterId(uniqueId);
                    }
                }
            }
            paramIdList.addParameterId(uniqueId);
        }
    } else {
        param.setAutomationEnabled(true);
        param.getLine().setColor(LineColors.getColor(paramIdList.size()));
        paramIdList.addParameterId(uniqueId);
        param.fireUpdateFromTimeChange();
    }
}
Also used : Score(blue.score.Score) SoundLayer(blue.SoundLayer) PolyObject(blue.soundObject.PolyObject)

Example 14 with PolyObject

use of blue.soundObject.PolyObject in project blue by kunstmusik.

the class MidiImportUtilities method convertMidiFile.

/**
 * Converts a MIDI file to a blue polyObject. Will return null if unable to
 * open or process the file.
 *
 * @param midiFile
 * @return
 * @throws NoteParseException
 */
public static PolyObject convertMidiFile(Frame root, File midiFile) throws NoteParseException {
    if (midiFile == null || !midiFile.exists()) {
        return null;
    }
    Sequence sequence = null;
    try {
        sequence = MidiSystem.getSequence(midiFile);
    } catch (InvalidMidiDataException imde) {
        imde.printStackTrace();
    } catch (IOException ioe) {
        ioe.printStackTrace();
    }
    if (sequence == null) {
        return null;
    }
    PolyObject pObj = new PolyObject(true);
    Track[] tracks = sequence.getTracks();
    double divType = sequence.getDivisionType();
    if (divType == Sequence.PPQ) {
        divType = 1.0f;
    }
    double ticksLength = (double) sequence.getResolution();
    MidiImportSettings settings = getMidiImportSettings(tracks);
    if (settings.getRowCount() == 0) {
        return null;
    }
    boolean retVal = MidiImportSettingsDialog.ask(root, settings);
    if (!retVal) {
        return null;
    }
    for (int i = 0; i < tracks.length; i++) {
        TrackImportSettings trSettings = settings.getTrackSettingsForTrackNum(i);
        if (trSettings == null) {
            continue;
        }
        Track track = tracks[i];
        NoteList nl = getNoteListForTrack(track, divType, ticksLength, trSettings.getNoteTemplate(), trSettings.getInstrId());
        if (nl == null || nl.size() == 0) {
            continue;
        }
        GenericScore genSco = new GenericScore();
        if (trSettings.isTrim()) {
            // Assumes NoteList is already sorted
            double start = nl.get(0).getStartTime();
            genSco.setStartTime(start);
            ScoreUtilities.normalizeNoteList(nl);
        } else {
            genSco.setStartTime(0.0f);
        }
        genSco.setSubjectiveDuration(ScoreUtilities.getTotalDuration(nl));
        genSco.setText(nl.toString());
        genSco.setName("Track " + i);
        SoundLayer sLayer = pObj.newLayerAt(-1);
        sLayer.add(genSco);
    }
    return pObj;
}
Also used : InvalidMidiDataException(javax.sound.midi.InvalidMidiDataException) NoteList(blue.soundObject.NoteList) GenericScore(blue.soundObject.GenericScore) Sequence(javax.sound.midi.Sequence) IOException(java.io.IOException) SoundLayer(blue.SoundLayer) PolyObject(blue.soundObject.PolyObject) Track(javax.sound.midi.Track)

Example 15 with PolyObject

use of blue.soundObject.PolyObject in project blue by kunstmusik.

the class OpenProjectAction method reconcileAudioFiles.

private static void reconcileAudioFiles(PolyObject pObj, Map<String, String> map) {
    for (SoundObject sObj : pObj.getSoundObjects(true)) {
        if (sObj instanceof AudioFile) {
            AudioFile af = (AudioFile) sObj;
            String soundFileName = af.getSoundFileName();
            if (map.containsKey(soundFileName)) {
                af.setSoundFileName(map.get(soundFileName));
            }
        } else if (sObj instanceof PolyObject) {
            reconcileAudioFiles((PolyObject) sObj, map);
        }
    }
}
Also used : AudioFile(blue.soundObject.AudioFile) SoundObject(blue.soundObject.SoundObject) PolyObject(blue.soundObject.PolyObject)

Aggregations

PolyObject (blue.soundObject.PolyObject)29 SoundLayer (blue.SoundLayer)10 SoundObject (blue.soundObject.SoundObject)10 BlueData (blue.BlueData)8 Score (blue.score.Score)8 Instance (blue.soundObject.Instance)6 ScoreObject (blue.score.ScoreObject)5 GenericScore (blue.soundObject.GenericScore)5 Point (java.awt.Point)4 ArrayList (java.util.ArrayList)4 SoundObjectLibrary (blue.SoundObjectLibrary)3 Layer (blue.score.layers.Layer)3 LayerGroup (blue.score.layers.LayerGroup)3 AudioFile (blue.soundObject.AudioFile)3 File (java.io.File)3 IOException (java.io.IOException)3 Test (org.junit.Test)3 AbstractLookup (org.openide.util.lookup.AbstractLookup)3 Mixer (blue.mixer.Mixer)2 TimeState (blue.score.TimeState)2