use of blue.soundObject.pianoRoll.PianoNote in project blue by kunstmusik.
the class PianoRoll method saveAsXML.
@Override
public Element saveAsXML(Map<Object, String> objRefMap) {
Element retVal = SoundObjectUtilities.getBasicXML(this);
retVal.addElement("noteTemplate").setText(getNoteTemplate());
retVal.addElement("instrumentId").setText(getInstrumentId());
retVal.addElement(scale.saveAsXML());
retVal.addElement("pixelSecond").setText(Integer.toString(this.getPixelSecond()));
retVal.addElement("noteHeight").setText(Integer.toString(this.getNoteHeight()));
retVal.addElement("snapEnabled").setText(Boolean.toString(this.isSnapEnabled()));
retVal.addElement("snapValue").setText(Double.toString(this.getSnapValue()));
retVal.addElement("timeDisplay").setText(Integer.toString(this.getTimeDisplay()));
retVal.addElement("timeUnit").setText(Integer.toString(this.getTimeUnit()));
retVal.addElement("pchGenerationMethod").setText(Integer.toString(this.getPchGenerationMethod()));
retVal.addElement("transposition").setText(Integer.toString(this.getTransposition()));
for (Iterator<PianoNote> iter = notes.iterator(); iter.hasNext(); ) {
PianoNote note = iter.next();
retVal.addElement(note.saveAsXML());
}
return retVal;
}
use of blue.soundObject.pianoRoll.PianoNote in project blue by kunstmusik.
the class PianoRollCanvas method editPianoRoll.
public void editPianoRoll(PianoRoll p) {
if (this.p != null && this.p != p) {
this.p.removePropertyChangeListener(this);
}
if (this.p != p) {
p.addPropertyChangeListener(this);
}
this.p = p;
noteBuffer.setPianoRoll(p);
this.removeAll();
this.add(marquee, JLayeredPane.DRAG_LAYER);
marquee.setVisible(false);
for (PianoNote note : p.getNotes()) {
addNoteView(note);
}
nMouse.fireSelectionEvent(new SelectionEvent<>(null, SelectionEvent.SELECTION_CLEAR));
recalculateSize();
revalidate();
repaint();
}
use of blue.soundObject.pianoRoll.PianoNote in project blue by kunstmusik.
the class NoteCanvasMouseListener method pasteNotes.
private void pasteNotes(int x, int y) {
double startTime = (double) x / canvas.p.getPixelSecond();
int[] pchBase = canvas.getOctaveScaleDegreeForY(y);
double timeAdjust = Double.MAX_VALUE;
int topPitchNum = Integer.MIN_VALUE;
int bottomPitchNum = Integer.MAX_VALUE;
int scaleDegrees = canvas.p.getScale().getNumScaleDegrees();
if (canvas.p.isSnapEnabled()) {
double snapValue = canvas.p.getSnapValue();
startTime = ScoreUtilities.getSnapValueStart(startTime, snapValue);
}
for (PianoNote note : PianoRollCanvas.NOTE_COPY_BUFFER) {
timeAdjust = Math.min(timeAdjust, note.getStart());
int pitchNum = note.getOctave() * scaleDegrees + note.getScaleDegree();
topPitchNum = Math.max(topPitchNum, pitchNum);
bottomPitchNum = Math.min(bottomPitchNum, pitchNum);
}
fireSelectionEvent(new SelectionEvent<>(null, SelectionEvent.SELECTION_CLEAR));
start = null;
int basePitchNum = pchBase[0] * scaleDegrees + pchBase[1];
int pitchNumAdjust = basePitchNum - topPitchNum;
for (PianoNote note : PianoRollCanvas.NOTE_COPY_BUFFER) {
PianoNote copy = new PianoNote(note);
copy.setStart(startTime + (copy.getStart() - timeAdjust));
int pitchNum = copy.getOctave() * scaleDegrees + copy.getScaleDegree();
pitchNum += pitchNumAdjust;
copy.setOctave(pitchNum / scaleDegrees);
copy.setScaleDegree(pitchNum % scaleDegrees);
canvas.addNote(copy);
}
}
use of blue.soundObject.pianoRoll.PianoNote in project blue by kunstmusik.
the class PianoRollCanvas method addNote.
/**
* @param x
* @param y
*/
public PianoNoteView addNote(double startTime, int y) {
PianoNote note = new PianoNote();
note.setNoteTemplate(p.getNoteTemplate());
note.setStart(startTime);
int[] pch = getOctaveScaleDegreeForY(y);
note.setOctave(pch[0]);
note.setScaleDegree(pch[1]);
return addNote(note);
}
use of blue.soundObject.pianoRoll.PianoNote in project blue by kunstmusik.
the class PianoRollPropertiesEditor method setSelectedNoteTemplates.
protected void setSelectedNoteTemplates() {
if (p == null || noteBuffer == null) {
return;
}
String noteTemplate = p.getNoteTemplate();
for (PianoNoteView pianoNoteView : noteBuffer) {
PianoNote note = pianoNoteView.getPianoNote();
note.setNoteTemplate(noteTemplate);
}
}
Aggregations