Package jm.music.data

Examples of jm.music.data.Phrase


        // get all the phrases in a vector
        java.util.Vector v = new java.util.Vector();
        for (int i = 0; i < score.size(); i++) {
            Part p = score.getPart(i);
            for (int j = 0; j < p.size(); j++) {
                Phrase phr = p.getPhrase(j);
                if (phr.getInstrument() == Phrase.DEFAULT_INSTRUMENT)
                    phr.setInstrument(p.getInstrument());
                if (phr.getTempo() == Phrase.DEFAULT_TEMPO)
                    phr.setTempo(p.getTempo());
                v.addElement(phr);
            }
        }
        // create RTPhrases for each phrase
        jm.music.rt.RTLine[] lines = new jm.music.rt.RTLine[v.size()];
        for (int i = 0; i < v.size(); i++) {
            Phrase phr = (Phrase) (v.elementAt(i));
            lines[i] = new jm.music.rt.RTPhrase(phr, insts[phr.getInstrument()]);
        }
        // create mixer and wait for the end then pause the mixer
        //RTMixer mixer = new RTMixer(lines);
        if (mixer == null) {
            mixer = new RTMixer(lines);
View Full Code Here


      for(int i=0;i<numOfNotes;i++){
        noteList[i].setDynamic(retDynamic[i]);
      }
    }

    Phrase phrase = new Phrase();
    phrase.addNoteList(noteList);
    return phrase;
  }
View Full Code Here

                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

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

                                "This XML string represents a Part, use the "
                                + "xmlStringToPart(String) method instead.");
        } else if (XMLStyles.isValidPhraseTag(elements[0].getName())) {
                return elementToPhrase(elements[0]);
        } else if (XMLStyles.isValidNoteTag(elements[0].getName())) {
                return new Phrase(elementToNote(elements[0]));
        }
        throw new ConversionException("Unrecognised root element: "
                                      + elements[0].getName());
    }
View Full Code Here

        if (! XMLStyles.isValidPhraseTag(element.getName())) {
            throw new ConversionException(
                    "Invalid element: " + element.getName() + ".  The only "
                    + "accepted tag name is '" + xmlStyle.getPhraseTagName() + "'.");
        }
        Phrase returnPhrase = new Phrase();
        String attributeValue;

        attributeValue = XMLStyles.getTitleAttributeValue(element);
        if (! attributeValue.equals("")) {
            try {
                returnPhrase.setTitle(attributeValue);
            } catch (NumberFormatException e) {
                throw new ConversionException(
                        "Invalid attribute value: " + attributeValue + ".  The "
                        + "attribute '" + xmlStyle.getTitleAttributeName() + "' of element '"
                        + xmlStyle.getPhraseTagName() + "' must represent a Java integer.");
            }
        }
        attributeValue = XMLStyles.getStartTimeAttributeValue(element);
        if (! attributeValue.equals("")) {
            try {
                returnPhrase.setStartTime(
                        Double.valueOf(attributeValue).doubleValue());
            } catch (NumberFormatException e) {
                throw new ConversionException(
                        "Invalid attribute value: " + attributeValue + ".  The "
                        + "attribute '" + xmlStyle.getStartTimeAttributeName() + "' of element '"
                        + xmlStyle.getPhraseTagName() + "' must represent a Java double.");
            }
        }
        attributeValue = XMLStyles.getInstrumentAttributeValue(element);
        if (! attributeValue.equals("")) {
            try {
                returnPhrase.setInstrument(Integer.parseInt(attributeValue));
            } catch (NumberFormatException e) {
                throw new ConversionException(
                        "Invalid attribute value: " + attributeValue + ".  The "
                        + "attribute '" + xmlStyle.getInstrumentAttributeName() + "' of element '"
                        + xmlStyle.getPhraseTagName() + "' must represent a Java integer.");
            }
        }
        attributeValue = XMLStyles.getTempoAttributeValue(element);
        if (! attributeValue.equals("")) {
            try {
                returnPhrase.setTempo(
                        Double.valueOf(attributeValue).doubleValue());
            } catch (NumberFormatException e) {
                throw new ConversionException(
                        "Invalid attribute value: " + attributeValue + ".  The "
                        + "attribute '" + xmlStyle.getTempoAttributeName() + "' of element '"
                        + xmlStyle.getPhraseTagName() + "' must represent a Java double.");
            }
        }
        attributeValue = XMLStyles.getAppendAttributeValue(element);
        if (! attributeValue.equals("")) {
            returnPhrase.setAppend(new Boolean(attributeValue).booleanValue());
        }
        attributeValue = XMLStyles.getPanAttributeValue(element);
        if (! attributeValue.equals("")) {
            try {
                returnPhrase.setPan(
                        Double.valueOf(attributeValue).doubleValue());
            } catch (NumberFormatException e) {
                throw new ConversionException(
                        "Invalid attribute value: " + attributeValue + ".  The "
                        + "attribute '" + xmlStyle.getPanAttributeName() + "' of element '"
                        + xmlStyle.getPhraseTagName() + "' must represent a Java double.");
            }
        }
        Element[] elements = element.getChildren();
        for (int i = 0; i < elements.length; i++) {
            if (XMLStyles.isValidNoteTag(elements[i].getName())) {
                returnPhrase.addNote(elementToNote(elements[i]));
            }
        }
        return returnPhrase;
    }
View Full Code Here

     * @param string    String of value separated by commas
     * @return          Phrase described by the String.
     */
    public static Phrase pitchAndRhythmStringToPhrase(final String string) {
        StringProcessor processor = new StringProcessor(string);
        Phrase phrase = new Phrase();
        try {
            while (true) {
                phrase.addNote(new Note(
                        (int) processor.getNextRhythm(), processor.getNextRhythm()));
            }
        } catch (EOSException e) {
            /* This is okay.  Continue. */
        }
View Full Code Here

     * @param string    String of value separated by commas
     * @return          Phrase described by the String.
     */
    public static Phrase pitchRhythmAndDynamicStringToPhrase(final String string) {
        StringProcessor processor = new StringProcessor(string);
        Phrase phrase = new Phrase();
        try {
            while (true) {
                phrase.addNote(new Note(
                        (int) processor.getNextRhythm(),
                        processor.getNextRhythm(),
                        (int) processor.getNextRhythm()));
            }
        } catch (EOSException e) {
View Full Code Here

        return champion;
    }

    private Phrase crossover(int crossoverBar, Phrase mother, Phrase father,
                             boolean isFatherFirst, int beatsPerBar) {
        Phrase returnPhrase = new Phrase();

        Phrase currentPhrase = isFatherFirst ? father : mother;
        int currentNote = 0;

        while (returnPhrase.getEndTime()
               + currentPhrase.getNote(currentNote).getRhythmValue()
               < crossoverBar * beatsPerBar) {
            returnPhrase.addNote(currentPhrase.getNote(currentNote++).copy());
        }
        double rhythmValue = crossoverBar * beatsPerBar
                             - returnPhrase.getEndTime();
        returnPhrase.addNote(new Note(
                currentPhrase.getNote(currentNote).getPitch(),
                crossoverBar * beatsPerBar - returnPhrase.getEndTime()));
        currentNote = -1;
        currentPhrase = isFatherFirst ? mother : father;
        double currentRhythmValue = 0;
        while (currentRhythmValue <= crossoverBar * beatsPerBar) {
            currentNote++;
            currentRhythmValue +=
                    currentPhrase.getNote(currentNote).getRhythmValue();
        }
        returnPhrase.addNote(new Note(
                currentPhrase.getNote(currentNote++).getPitch(),
                currentRhythmValue - crossoverBar * beatsPerBar));
        while (currentNote < currentPhrase.size()) {
            returnPhrase.addNote(currentPhrase.getNote(currentNote++));
        }
        return returnPhrase;           
    }
View Full Code Here

                /////////////////////////////////////////////////
                // Each phrase represents a new Track element
    // Err no
    // There is a 65? track limit
    // ////////////////////////////
                Phrase phrase = (Phrase) phrases.nextElement();

                //Track currTrack = sequence.createTrack();

                currentTime = phrase.getStartTime();
                long phraseTick = (long)(currentTime * m_ppqn * trackTempoRatio);
                MidiEvent evt;

                if (phrase.getInstrument() != NO_INSTRUMENT) instrument = phrase.getInstrument();
                evt = createProgramChangeEvent(currChannel, instrument, phraseTick);
                currTrack.add(evt);

                m_tempoHistory.push(new Float(m_currentTempo));

                tempo = new Float(phrase.getTempo()).floatValue();
                if (tempo != Phrase.DEFAULT_TEMPO) {
                    m_currentTempo = tempo;
                    //System.out.println("jMusic MidiSynth notification: Phrase TempoEvent (BPM) = " + tempo);
                }

                elementTempoRatio = m_masterTempo/m_currentTempo;

                double lastPanPosition = -1.0
                int offSetTime = 0;         
                /// Each note
                Enumeration notes = phrase.getNoteList().elements();
                while(notes.hasMoreElements()) {
                    Note note = (Note) notes.nextElement();
                    // deal with offset
                    offSetTime = (int)(note.getOffset() * m_ppqn * elementTempoRatio);

 
View Full Code Here

TOP

Related Classes of jm.music.data.Phrase

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.