Package com.music.xmlmodel

Examples of com.music.xmlmodel.Measure


            for (Phrase phrase : part.getPhraseArray()) {
                partNotes.addAll(phrase.getNoteList());
            }
            Iterator<Note> noteIterator = partNotes.iterator();
            int measureNumber = 1;
            Measure currentMeasure = createMeasure(score, measureNumber++);
            while (noteIterator.hasNext()) {
                Note note = noteIterator.next();
                NoteElement xmlNote = new NoteElement();
                int length = (int) (getClosestLength(note.getRhythmValue()) * 10000);
                switch(length) {
                case (int) (THIRTYSECOND_NOTE * 10000): xmlNote.setType("32nd"); break;
                case (int) (SIXTEENTH_NOTE * 10000): xmlNote.setType("16th"); break;
                case (int) (EIGHTH_NOTE * 10000): xmlNote.setType("eighth"); break;
                case (int) (QUARTER_NOTE * 10000): xmlNote.setType("quarter"); break;
                case (int) (DOTTED_QUARTER_NOTE * 10000): xmlNote.setType("quarter"); xmlNote.setDot(""); break;
                case (int) (HALF_NOTE * 10000): xmlNote.setType("half"); break;
                case (int) (WHOLE_NOTE * 10000): xmlNote.setType("whole"); break;
                default: xmlNote.setType("/" + (length / 10000d));
                }
                xmlNote.setDuration((int) (note.getRhythmValue() * 2));
                xmlNote.setVoice(idx);
                if (!note.isRest()) {
                    xmlNote.setPitch(new Pitch());
                    int pitch = note.getPitch() % 12;
                    String sPitch = NOTES[pitch];
                    int octave = note.getPitch() / 12 - 1;
                    xmlNote.getPitch().setOctave(octave);
                    if (sPitch.length() > 1) {
                        xmlNote.getPitch().setAlter((byte) (sPitch.contains("#") ? 1 : -1));
                        sPitch = sPitch.substring(0, 1);
                    }
                    xmlNote.getPitch().setStep(sPitch);
                } else {
                    xmlNote.setRest(new RestElement());
                }

                currentMeasure.getNotes().add(xmlNote);
                currentMeasureSize += note.getRhythmValue();
                if (currentMeasureSize >= normalizedMeasureSize) {
                    currentMeasureSize = 0;
                    xmlPart.getMeasures().add(currentMeasure);
                    currentMeasure = createMeasure(score, measureNumber++);
View Full Code Here


            throw new IllegalStateException(e);
        }
    }

    private static Measure createMeasure(Score score, int number) {
        Measure measure = new Measure();
        measure.setNumber(number);
        measure.getAttributes().getTime().setBeats(score.getNumerator());
        measure.getAttributes().getTime().setBeatType(score.getDenominator());
        return measure;
    }
View Full Code Here

TOP

Related Classes of com.music.xmlmodel.Measure

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.