Package jm.music.data

Examples of jm.music.data.Score


     * @param exit Hold program open for the duration of playback, then close ready to exit? true or false.
     */
    public static void midi(Phrase phr, boolean exit) {
        double tempo = 60;
        if (phr.getTempo() != Phrase.DEFAULT_TEMPO) tempo = phr.getTempo();
        Score s = new Score(phr.getTitle() + " score", tempo);
        if (phr.getTempo() != Phrase.DEFAULT_TEMPO) s.setTempo(phr.getTempo());
        s.addPart(new Part(phr));
        midi(s, exit);
    }
View Full Code Here


     * @param exit Hold program open for the duration of playback, then close ready to exit? true or false.
     */
    public static void midi(Part p, boolean exit) {
        double tempo = 60;
        if (p.getTempo() != Part.DEFAULT_TEMPO) tempo = p.getTempo();
        Score s = new Score(p.getTitle() + " score", tempo);
        if (p.getTempo() != Part.DEFAULT_TEMPO) s.setTempo(p.getTempo());
        s.addPart(p);
        midi(s, exit);
    }
View Full Code Here

     *
     * @param n     The note to be played. See midiCycle(Score s)
     * @param index The midiCycle id to be used - default is 0.
     */
    public static void midiCycle(Note n, int index) {
        Score s = new Score("One note score");
        s.addPart(new Part(new Phrase(n)));
        midiCycle(s, index);
    }
View Full Code Here

     *
     * @param phr   The Phrase to be played. See midiCycle(Score s)
     * @param index The midiCycle id to be used - default is 0.
     */
    public static void midiCycle(Phrase phr, int index) {
        Score s = new Score(phr.getTitle() + " score");
        s.addPart(new Part(phr));
        midiCycle(s, index);
    }
View Full Code Here

     *
     * @param part  The Part to be played. See midiCycle(Score s)
     * @param index The midiCycle id to be used - default is 0.
     */
    public static void midiCycle(Part part, int index) {
        Score s = new Score(part.getTitle() + " score");
        s.addPart(part);
        midiCycle(s, index);
    }
View Full Code Here

     *
     * @param phrase The phrase to be played.
     * @param insts  An array of instruments to play the phrase with
     */
    public static void audio(Phrase phrase, Instrument[] insts) {
        audio(new Score(new Part(phrase)), insts);
    }
View Full Code Here

     *
     * @param part  The part to be played.
     * @param insts An array of instruments to play the part with
     */
    public static void audio(Part part, Instrument[] insts) {
        Score score = new Score(part);
        if (part.getTempo() != Part.DEFAULT_TEMPO) score.setTempo(part.getTempo());
        audio(score, insts);
    }
View Full Code Here

        }
        Element element = elements[0];
        if (XMLStyles.isValidScoreTag(elements[0].getName())) {          
                return elementToScore(elements[0]);
        } else if (XMLStyles.isValidPartTag(elements[0].getName())) {
                return new Score(elementToPart(elements[0]));
        } else if (XMLStyles.isValidPhraseTag(elements[0].getName())) {
                return new Score(new Part(elementToPhrase(elements[0])));
        } else if (XMLStyles.isValidNoteTag(elements[0].getName())) {
                return new Score(new Part(
                                new Phrase(elementToNote(elements[0]))));
        }
        throw new ConversionException("Unrecognised root element: "
                                      + elements[0].getName());
    }
View Full Code Here

           throw new ConversionException(
                    "The root element must have the name '"
                    + xmlStyle.getScoreTagName() + "'.  The invalid name used "
                    + "was '" + element.getName() + "'.");
        }
        Score returnScore = new Score();
        String attributeValue;
                                        
        attributeValue = XMLStyles.getTitleAttributeValue(element);
        if (! attributeValue.equals("")) {
            returnScore.setTitle(attributeValue);
        }
        attributeValue = XMLStyles.getTempoAttributeValue(element);
        if (! attributeValue.equals("")) {
            try {
                returnScore.setTempo(
                        Double.valueOf(attributeValue).doubleValue());
            } catch (NumberFormatException e) {
                throw new ConversionException(
                        "Invalid attribute value: " + attributeValue + ".  The "
                        + "attribute '" + xmlStyle.getTempoAttributeName() + "' of element '"
                        + xmlStyle.getScoreTagName() + "' must represent a Java double.");
            }
        }
        attributeValue = XMLStyles.getKeySignatureAttributeValue(element);
        if (! attributeValue.equals("")) {
            try {
                returnScore.setKeySignature(Integer.parseInt(attributeValue));
            } catch (NumberFormatException e) {
                throw new ConversionException(
                        "Invalid attribute value: " + attributeValue + ".  The "
                        + "attribute '" + xmlStyle.getKeySignatureAttributeName() + "' of element '"
                        + xmlStyle.getScoreTagName() + "' must represent a Java integer.");
            }
        }
        attributeValue = XMLStyles.getKeyQualityAttributeValue(element);
        if (! attributeValue.equals("")) {
            try {
                returnScore.setKeyQuality(Integer.parseInt(attributeValue));
            } catch (NumberFormatException e) {
                throw new ConversionException(
                        "Invalid attribute value: " + attributeValue + ".  The "
                        + "attribute '" + xmlStyle.getKeyQualityAttributeName() + "' of element '"
                        + xmlStyle.getScoreTagName() + "' must represent a Java integer.");
            }
        }
        attributeValue = XMLStyles.getNumeratorAttributeValue(element);
        if (! attributeValue.equals("")) {
            try {
                returnScore.setNumerator(Integer.parseInt(attributeValue));
            } catch (NumberFormatException e) {
                throw new ConversionException(
                        "Invalid attribute value: " + attributeValue + ".  The "
                        + "attribute '" + xmlStyle.getNumeratorAttributeName() + "' of element '"
                        + xmlStyle.getScoreTagName() + "' must represent a Java integer.");
            }
        }
        attributeValue = XMLStyles.getDenominatorAttributeValue(element);
        if (! attributeValue.equals("")) {
            try {
                returnScore.setDenominator(Integer.parseInt(attributeValue));
            } catch (NumberFormatException e) {
                throw new ConversionException(
                        "Invalid attribute value: " + attributeValue + ".  The "
                        + "attribute '" + xmlStyle.getDenominatorAttributeName() + "' of element '"
                        + xmlStyle.getScoreTagName() + "' must represent a Java integer.");
            }
        }
        Element[] children = element.getChildren();
        for (int i = 0; i < children.length; i++) {
            if (XMLStyles.isValidPartTag(children[i].getName())) {
                returnScore.addPart(elementToPart(children[i]));
            }
        }
        return returnScore;
    }
View Full Code Here

        addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                load.show();

                Score score = Read.midiOrJmWithAWTMessaging(load.getDirectory(),
                                                            load.getFile(),
                                                            owner);
                if (score == null) {
                    return;
                }
View Full Code Here

TOP

Related Classes of jm.music.data.Score

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.