use of blue.SoundLayer 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.SoundLayer in project blue by kunstmusik.
the class ScoreSection method setSoundObjectsPerInstrument.
// TODO - Possible problems with score processing here if SCO uses carry's,
// ramp's, etc.
private static void setSoundObjectsPerInstrument(BlueData data, ScoreSection section) {
TreeMap map = new TreeMap();
StringTokenizer st = new StringTokenizer(section.scoreText, "\n");
String line = "";
Note previousNote = null;
Note note;
Integer iNum;
StringBuffer buffer;
while (st.hasMoreTokens()) {
line = st.nextToken();
note = null;
try {
note = Note.createNote(line, previousNote);
} catch (NoteParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if (note == null) {
continue;
}
iNum = new Integer(Integer.parseInt(note.getPField(1)));
if (map.containsKey(iNum)) {
buffer = (StringBuffer) map.get(iNum);
buffer.append(line).append("\n");
} else {
buffer = new StringBuffer();
buffer.append(line).append("\n");
map.put(iNum, buffer);
}
previousNote = note;
}
SoundLayer sLayer;
for (Iterator iter = map.entrySet().iterator(); iter.hasNext(); ) {
Map.Entry entry = (Entry) iter.next();
iNum = (Integer) entry.getKey();
buffer = (StringBuffer) entry.getValue();
if (buffer == null) {
continue;
}
PolyObject pObj = (PolyObject) data.getScore().get(0);
sLayer = pObj.newLayerAt(-1);
String score = buffer.toString();
NoteList notes;
try {
notes = ScoreUtilities.getNotes(score);
} catch (NoteParseException e) {
throw new RuntimeException(e);
}
notes.sort();
double minStart = notes.get(0).getStartTime();
ScoreUtilities.normalizeNoteList(notes);
GenericScore genScore = createSizedGenericScore(notes.toString(), "Instrument " + iNum.toString());
genScore.setStartTime(minStart + section.sectionStartTime);
sLayer.add(genScore);
}
}
use of blue.SoundLayer in project blue by kunstmusik.
the class ImportSoundObjectAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
ScoreTimeCanvas sCanvas = (ScoreTimeCanvas) lGroupPanel;
List<File> retVal = FileChooserManager.getDefault().showOpenDialog(IMPORT_DIALOG, WindowManager.getDefault().getMainWindow());
if (!retVal.isEmpty()) {
File f = retVal.get(0);
Document doc;
try {
doc = new Document(f);
Element root = doc.getRoot();
if (root.getName().equals("soundObject")) {
SoundObject tempSobj = (SoundObject) ObjectUtilities.loadFromXML(root, null);
int start = p.x;
Layer layer = scorePath.getGlobalLayerForY(p.y);
if (timeState.isSnapEnabled()) {
int snapPixels = (int) (timeState.getSnapValue() * timeState.getPixelSecond());
start = start - (start % snapPixels);
}
float startTime = (float) start / timeState.getPixelSecond();
tempSobj.setStartTime(startTime);
((SoundLayer) layer).add(tempSobj);
AddScoreObjectEdit edit = new AddScoreObjectEdit((ScoreObjectLayer) layer, tempSobj);
BlueUndoManager.setUndoManager("score");
BlueUndoManager.addEdit(edit);
} else {
JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(), "Error: File did not contain Sound Object", "Error", JOptionPane.ERROR_MESSAGE);
}
} catch (Exception ex) {
ex.printStackTrace();
JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(), "Error: Could not read Sound Object from file", "Error", JOptionPane.ERROR_MESSAGE);
}
}
}
use of blue.SoundLayer in project blue by kunstmusik.
the class ScoreTimeCanvas method modifyLayerHeight.
public void modifyLayerHeight(int value, int y) {
int index = getPolyObject().getLayerNumForY(y);
if (index < 0 || index >= getPolyObject().size()) {
return;
}
SoundLayer layer = getPolyObject().get(index);
int hIndex = layer.getHeightIndex();
if (value < 0 && hIndex < 1) {
return;
} else if (value > 0 && hIndex > SoundLayer.HEIGHT_MAX_INDEX - 1) {
return;
}
layer.setHeightIndex(hIndex + value);
}
use of blue.SoundLayer in project blue by kunstmusik.
the class ScoreTimeCanvas method layerGroupChanged.
/* LAYER GROUP LISTENER */
@Override
public void layerGroupChanged(LayerGroupDataEvent event) {
if (event.getType() == LayerGroupDataEvent.DATA_ADDED) {
SoundLayer layer = getPolyObject().get(event.getStartIndex());
layer.addPropertyChangeListener(heightListener);
layer.addSoundLayerListener(this);
}
reset();
}
Aggregations