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);
}
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();
}
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));
}
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));
}
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;
}
Aggregations