Search in sources :

Example 11 with GenericScore

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

the class MoveScoreObjectsListenerTest method testGetMinYAdjust.

/**
 * Test of getMinYAdjust method, of class MoveScoreObjectsListener.
 */
@Test
public void testGetMinYAdjust() {
    System.out.println("getMinYAdjust");
    List<Layer> layers = new ArrayList<>();
    final SoundLayer soundLayer = new SoundLayer();
    ScoreObject scoreObj = new GenericScore();
    soundLayer.add((SoundObject) scoreObj);
    layers.add(new SoundLayer());
    layers.add(soundLayer);
    layers.add(new SoundLayer());
    int sObjLayerIndex = 1;
    int result = MoveScoreObjectsListener.getMinYAdjust(layers, scoreObj, sObjLayerIndex);
    assertEquals(-1, result);
    layers.add(0, new InvalidLayer());
    layers.add(1, new SoundLayer());
    layers.add(new InvalidLayer());
    sObjLayerIndex = 3;
    result = MoveScoreObjectsListener.getMinYAdjust(layers, scoreObj, sObjLayerIndex);
    assertEquals(-2, result);
}
Also used : SoundLayer(blue.SoundLayer) ArrayList(java.util.ArrayList) ScoreObject(blue.score.ScoreObject) GenericScore(blue.soundObject.GenericScore) SoundLayer(blue.SoundLayer) Layer(blue.score.layers.Layer) Test(org.junit.Test)

Example 12 with GenericScore

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

the class ScoreControllerTest method setUp.

@Before
public void setUp() {
    System.out.println("@Before setUp");
    this.scoreController = ScoreController.getInstance();
    scoreController.setScrollPane(new JScrollPane());
    InstanceContent content = new InstanceContent();
    Score score = new Score();
    scoreController.setScore(score);
    PolyObject pObj = (PolyObject) score.get(0);
    SoundLayer layer1 = new SoundLayer();
    SoundLayer layer2 = new SoundLayer();
    pObj.add(layer1);
    pObj.add(layer2);
    GenericScore score1 = new GenericScore();
    score1.setStartTime(2.0f);
    GenericScore score2 = new GenericScore();
    score2.setStartTime(4.0f);
    layer2.add(score1);
    layer2.add(score2);
    content.add(score);
    content.add(score1);
    content.add(score2);
    scoreController.setLookupAndContent(new AbstractLookup(content), content);
    this.buffer = scoreController.getScoreObjectBuffer();
}
Also used : JScrollPane(javax.swing.JScrollPane) Score(blue.score.Score) GenericScore(blue.soundObject.GenericScore) SoundLayer(blue.SoundLayer) InstanceContent(org.openide.util.lookup.InstanceContent) GenericScore(blue.soundObject.GenericScore) AbstractLookup(org.openide.util.lookup.AbstractLookup) PolyObject(blue.soundObject.PolyObject) Before(org.junit.Before)

Example 13 with GenericScore

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

the class LiveObjectBinsTest method testInsertRow.

/**
 * Test of insertRow method, of class LiveObjectBins.
 */
@Test
public void testInsertRow() {
    LiveObjectBins instance = new LiveObjectBins();
    LiveObject liveObject = new LiveObject(new GenericScore());
    instance.setLiveObject(0, 2, liveObject);
    instance.insertRow(1);
    assertEquals(9, instance.getRowCount());
    assertEquals(liveObject, instance.getLiveObject(0, 3));
    instance.insertRow(20);
    assertEquals(10, instance.getRowCount());
    assertEquals(liveObject, instance.getLiveObject(0, 3));
}
Also used : GenericScore(blue.soundObject.GenericScore)

Example 14 with GenericScore

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

the class LiveObjectBinsTest method testGetRow_Column_Index.

@Test
public void testGetRow_Column_Index() {
    LiveObjectBins instance = new LiveObjectBins();
    LiveObject liveObject = new LiveObject(new GenericScore());
    instance.setLiveObject(0, 2, liveObject);
    instance.insertColumn(0);
    instance.insertRow(0);
    assertEquals(1, instance.getColumnForObject(liveObject));
    assertEquals(3, instance.getRowForObject(liveObject));
}
Also used : GenericScore(blue.soundObject.GenericScore)

Example 15 with GenericScore

use of blue.soundObject.GenericScore 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)

Aggregations

GenericScore (blue.soundObject.GenericScore)15 SoundLayer (blue.SoundLayer)5 NoteList (blue.soundObject.NoteList)4 PolyObject (blue.soundObject.PolyObject)3 Test (org.junit.Test)3 CompileData (blue.CompileData)2 Score (blue.score.Score)2 ScoreObject (blue.score.ScoreObject)2 Layer (blue.score.layers.Layer)2 Element (electric.xml.Element)2 ArrayList (java.util.ArrayList)2 BlueData (blue.BlueData)1 SoundObjectLibrary (blue.SoundObjectLibrary)1 LiveObject (blue.blueLive.LiveObject)1 LiveObjectBins (blue.blueLive.LiveObjectBins)1 Instance (blue.soundObject.Instance)1 NoteParseException (blue.soundObject.NoteParseException)1 SoundObject (blue.soundObject.SoundObject)1 SoundObjectException (blue.soundObject.SoundObjectException)1 IOException (java.io.IOException)1