Package nu.xom

Examples of nu.xom.Element


  private static final int MUSICXMLDIVISIONS = 4//  4 divisions per quarter note
  private static final double WHOLE = 1024.0;
  private static final double QUARTER = 256.0;
   
    public MusicXmlRenderer()
    {  root = new Element("score-partwise");
   
      Element elID = new Element("identification");
      Element elCreator = new Element("creator");
      elCreator.addAttribute(new Attribute("type", "software"));
      elCreator.appendChild("JFugue MusicXMLRenderer");
      elID.appendChild(elCreator);
      root.appendChild(elID);
   
      //  add an empty score-part list here (before any parts are added)
      //  score-parts are added to this as they are generated
      elPartList = new Element("part-list");
      root.appendChild(elPartList);
    //  MusicXmlRenderer
View Full Code Here


    {   finishCurrentVoice();

      //  remove empty measures
    Elements elDocParts = root.getChildElements("part");
    for (int xP = 0; xP < elDocParts.size(); ++xP)
    {  Element elDocPart = elDocParts.get(xP);
      Elements elPartMeasures = elDocPart.getChildElements("measure");
      for (int xM = 0; xM < elPartMeasures.size(); ++xM)
        if (elPartMeasures.get(xM).getChildCount() < 1)
          elDocPart.removeChild(xM);
    }
    //  create the Document
    Document xomDoc = new Document(root);
    DocType docType = new DocType("score-partwise",
            "-//Recordare//DTD MusicXML 1.1 Partwise//EN",
View Full Code Here

    public void doFirstMeasure(boolean bAddDefaults)
    {
      if (elCurPart == null)
        newVoice(new Voice((byte)0));
      if (elCurMeasure == null)
      {  elCurMeasure = new Element("measure");
      elCurMeasure.addAttribute(new Attribute("number", Integer.toString(1)));
       
        //  assemble attributes element
        Element elAttributes = new Element("attributes");
        if (bAddDefaults)
        {  //  divisions - 4 per beat
          Element elDivisions = new Element("divisions");
          elDivisions.appendChild(Integer.toString(MUSICXMLDIVISIONS));
          elAttributes.appendChild(elDivisions);
          //  beats - 1 beat per measure
          Element elTime = new Element("time");
          Element elBeats = new Element("beats");
          elBeats.appendChild(Integer.toString(4));
          elTime.appendChild(elBeats);
          Element elBeatType = new Element("beat-type");
          elBeatType.appendChild(Integer.toString(4));
          elTime.appendChild(elBeatType);
          elAttributes.appendChild(elTime);
        }
        if (bAddDefaults)
        {  //  Clef - assumed to be treble clef
          Element elClef = new Element("clef");
          Element elSign = new Element("sign");
          elSign.appendChild("G");
          Element elLine = new Element("line");
          elLine.appendChild("2");
          elClef.appendChild(elSign);
          elClef.appendChild(elLine);
          elAttributes.appendChild(elClef);
        }
        //  add the attributes to the measure
View Full Code Here

          return;
     
      //  check if the requested voice already exists
      boolean bNewVoiceExists = false;
      Elements elParts = root.getChildElements("part");
      Element elExistingNewPart = null;
      for (int x = 0; x < elParts.size(); ++x)
      {  Element elP = elParts.get(x);
        String sPID = elP.getAttribute("id").getValue();
       
        if (sPID.compareTo(sReqVoice) == 0)
        {  bNewVoiceExists = true;
          elExistingNewPart = elP;
        }
View Full Code Here

      String sCurPartID = (elCurPart == null)
                ? null
                : elCurPart.getAttribute("id").getValue();
      boolean bCurVoiceExists = false;
      Elements elParts = root.getChildElements("part");
      Element elExistingCurPart = null;

      for (int x = 0; x < elParts.size(); ++x)
      {  Element elP = elParts.get(x);
        String sPID = elP.getAttribute("id").getValue();
       
        if (sPID.compareTo(sCurPartID) == 0)
        {  bCurVoiceExists = true;
          elExistingCurPart = elP;
        }
View Full Code Here

      }
    }  //  finishCurrentVoice

    private void newVoice(Voice voice)
    {//  add a part to the part list
      elCurScorePart = new Element("score-part");
      Attribute atPart = new Attribute("id", voice.getMusicString());
      elCurScorePart.addAttribute(atPart);
      //  empty part name - Finale ignores it and Sibelius gets it wrong
      elCurScorePart.appendChild(new Element("part-name"));
      Element elPL = root.getFirstChildElement("part-list");
      elPL.appendChild(elCurScorePart);
     
      //  start a new part - note that the score-part and the part have the
      //  same id attribute
      elCurPart = new Element("part");
      Attribute atPart2 = new Attribute(atPart);
      elCurPart.addAttribute(atPart2);
      elCurMeasure = null;
      doFirstMeasure(true);
    //  newVoice
View Full Code Here

      doFirstMeasure(true);
    //  newVoice
   
    public void instrumentEvent(Instrument instrument)
    {
      Element elInstrName = new Element("instrument-name");
      elInstrName.appendChild(instrument.getInstrumentName());

      Element elInstrument = new Element("score-instrument");
      elInstrument.addAttribute(new Attribute("id", Byte.toString(instrument.getInstrument())));
      elInstrument.appendChild(elInstrName);
    }
View Full Code Here

    public void tempoEvent(Tempo tempo)
    {  doTempo(tempo);
    }
   
    private void doTempo(Tempo tempo)
    {  Element elDirection = new Element("direction");
    elDirection.addAttribute(new Attribute("placement", "above"));
    Element elDirectionType = new Element("direction-type");
    Element elMetronome = new Element("metronome");
    Element elBeatUnit = new Element("beat-unit");
    //  assume quarter note beat unit
    elBeatUnit.appendChild("quarter");
    Element elPerMinute = new Element("per-minute");
    Integer iBPM = new Float(PPMtoBPM(tempo.getTempo())).intValue();
    elPerMinute.appendChild(iBPM.toString());
    //  assemble all the pieces
    elMetronome.appendChild(elBeatUnit);
    elMetronome.appendChild(elPerMinute);
    elDirectionType.appendChild(elMetronome);
    elDirection.appendChild(elDirectionType);
View Full Code Here

    public void keySignatureEvent(KeySignature keySig)
    {  doKeySig(keySig);
    }
   
    private void doKeySig(KeySignature keySig)
    {  Element elKey = new Element("key");
      //  build the key element
      Element elFifths = new Element("fifths");
      elFifths.appendChild(Byte.toString(keySig.getKeySig()));
      elKey.appendChild(elFifths);
      Element elMode = new Element("mode");
      elMode.appendChild((keySig.getScale() == 1 ? "minor" : "major"));
      elKey.appendChild(elMode);
      //  add the key to the attributes element of the current measure
    if (elCurMeasure == null)
      doFirstMeasure(true);
      Element elAttributes = elCurMeasure.getFirstChildElement("attributes");
      boolean bNewAttributes = (elAttributes == null);
      if (bNewAttributes == true)
        elAttributes = new Element("attributes");
      elAttributes.appendChild(elKey);
      if (bNewAttributes == true)
        elCurMeasure.appendChild(elAttributes);
    //  doKeySig
View Full Code Here

          elCurPart.appendChild(elCurMeasure);
        else
        int sCurMNum = Integer.parseInt(elCurMeasure.getAttributeValue("number"));
          Elements elMeasures = elCurPart.getChildElements("measure");
          for (int x = 0; x < elMeasures.size(); ++x)
          {  Element elM = elMeasures.get(x);
            int sMNum = Integer.parseInt(elM.getAttributeValue("number"));
            if (sMNum == sCurMNum)
              elCurPart.replaceChild(elM, elCurMeasure);
          }
        }
      }
View Full Code Here

TOP

Related Classes of nu.xom.Element

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.