private boolean buildNoteSequence() { noteSequence = new NoteSequence(); double quantizeBeatFactor = quantizeBeatSetting * 1000.0 * 60.0 / (double) getBPM(); double quantizeDurationFactor = quantizeDurationSetting * 1000.0 * 60.0 / (double) getBPM(); for (int i = 0; i < noteList.size(); i++) { noteListElement = noteList.get(i); if (noteListElement.underTone == true) { continue; } note = noteListElement.note; if (note < getLowPitch()) continue; if (note > getHighPitch()) continue; double startTime = (double) (noteListElement.startTime); if (quantizeBeatFactor != 0.0) startTime = Math.floor(startTime / quantizeBeatFactor) * quantizeBeatFactor; long startTick = 1 + (long) (startTime * getTickRate() / 1000.0); double endTime = (double) (noteListElement.endTime); if (quantizeBeatFactor != 0.0) endTime = Math.ceil(endTime / quantizeBeatFactor) * quantizeBeatFactor; if (quantizeDurationFactor != 0) endTime = startTime + (Math.ceil((endTime - startTime) / quantizeDurationFactor) * quantizeDurationFactor); long endTick = 1 + (long) (endTime * getTickRate() / 1000.0); if ((endTick - startTick) < 1) endTick = startTick + 1; System.out.println( "times: " + startTime + ", " + endTime + ", " + getStartTime() + ", " + getEndTime()); if (endTime < getStartTime()) continue; if (startTime > getEndTime()) continue; velocity = 64; noteSequence.add(new NoteSequenceElement(note, ON, startTick, velocity)); noteSequence.add(new NoteSequenceElement(note, OFF, endTick, velocity)); } if (noteSequence.size() == 0) { return false; } else { noteSequence.sort(); return true; } }
public NoteList generateNotes(Integer[] instrLineArray, float renderStart, float renderEnd) throws SoundObjectException { NoteList notes = new NoteList(); float newDur = subjectiveDuration; if (renderEnd > 0 && renderEnd < subjectiveDuration) { newDur = renderEnd; } newDur = newDur - renderStart; StringBuilder buffer = new StringBuilder(); for (int i = 0; i < instrLineArray.length; i += 2) { Integer instrNum = instrLineArray[i]; Integer lineNum = instrLineArray[i + 1]; buffer.append("i").append(instrNum).append(" "); buffer.append(renderStart).append(" ").append(newDur).append(" "); buffer.append(renderStart / subjectiveDuration).append(" "); if (renderEnd > 0) { buffer.append(renderEnd / subjectiveDuration).append(" "); } else { buffer.append(" 1 "); } buffer.append(lineNum); try { notes.addNote(Note.createNote(buffer.toString())); } catch (NoteParseException e) { throw new SoundObjectException(this, e); } buffer.delete(0, buffer.length()); } ScoreUtilities.setScoreStart(notes, startTime); return notes; }