Ejemplo n.º 1
0
        //Read the attribute
        public static AttributeProperties ReadAttributes(ScorePartwise.Part.Measure measure)
        {
            /* get the attributes Initialization properties */
            for (int i = 0; i < measure.getNoteOrBackupOrForward().size(); i++)
            {
                if (measure.getNoteOrBackupOrForward().get(i) is Attributes)
                {
                    Attributes          attribute = (Attributes)measure.getNoteOrBackupOrForward().get(i);
                    AttributeProperties attprop   = new AttributeProperties();
                    if (attribute.getKey().size() > 0)
                    {
                        Key key = (Key)attribute.getKey().get(0);

                        attprop.fifths = key.getFifths().toString();
                        attprop.mode   = key.getMode();
                    }
                    if (attribute.getClef().size() > 0)
                    {
                        Clef clef = (Clef)attribute.getClef().get(0);
                        attprop.ClefSign = clef.getSign().name();
                        attprop.ClefLine = clef.getLine().toString();
                    }
                    if (attribute.getTime().size() > 0)
                    {
                        Time time = (Time)attribute.getTime().get(0);
                        javax.xml.bind.JAXBElement x = (javax.xml.bind.JAXBElement)time.getTimeSignature().get(0);
                        attprop.BeatsPerMeasure = (string)x.getValue();
                        x = (javax.xml.bind.JAXBElement)time.getTimeSignature().get(1);
                        attprop.BeatType = (string)x.getValue();
                    }
                    if (attribute.getDivisions() is BigDecimal)
                    {
                        attprop.divisions = attribute.getDivisions().intValue();
                    }
                    attprop.staves = attribute.getStaves() is BigInteger?attribute.getStaves().intValue() : 1;

                    return(attprop);
                }
            }
            return(null);
        }
Ejemplo n.º 2
0
        //Reads the top level score
        static public ScoreProperties ReadScore(ScorePartwise scorePartwise)
        {
            //get the top level properties of the score
            ScoreProperties i = new ScoreProperties();

            if (scorePartwise.getWork() != null)
            {
                i.WorkTitle = scorePartwise.getWork().getWorkTitle();
            }
            if (scorePartwise.getMovementTitle() != null)
            {
                i.MovementTitle = scorePartwise.getMovementTitle();
            }

            if (scorePartwise.getIdentification().getEncoding().getEncodingDateOrEncoderOrSoftware().get(0) != null)
            {
                javax.xml.bind.JAXBElement x = (javax.xml.bind.JAXBElement)scorePartwise.getIdentification().getEncoding().getEncodingDateOrEncoderOrSoftware().get(0);
                i.EncodingSoftware = x.getValue().ToString();
            }
            if (scorePartwise.getCredit().size() > 0)
            {
                Credit credit = (Credit)scorePartwise.getCredit().get(0);
                if (credit.getCreditTypeOrLinkOrBookmark().get(0) is FormattedText)
                {
                    FormattedText ft = (FormattedText)credit.getCreditTypeOrLinkOrBookmark().get(0);
                    i.CreditWords = ft.getValue();
                }
            }
            PartList partlist = scorePartwise.getPartList();

            if (partlist.getPartGroupOrScorePart().get(0) is ScorePart)
            {
                ScorePart scorepart = (ScorePart)partlist.getPartGroupOrScorePart().get(0);
                i.ScorePartID      = scorepart.getId();
                i.PartDisplayName  = scorepart.getPartName().getValue();
                i.PartAbbreviation = scorepart.getPartAbbreviation() is PartName?scorepart.getPartAbbreviation().getValue() : "";

                ScoreInstrument scoreinstrument = (ScoreInstrument)scorepart.getScoreInstrument().get(0);
                i.InstrumentID   = scoreinstrument.getId();
                i.InstrumentName = scoreinstrument.getInstrumentName();
                if (scorepart.getMidiDeviceAndMidiInstrument().get(0) is MidiInstrument)
                {
                    MidiInstrument midiinstrument = (MidiInstrument)scorepart.getMidiDeviceAndMidiInstrument().get(0);
                    i.MidiChannel = midiinstrument.getMidiChannel();
                    i.MidiProgram = midiinstrument.getMidiProgram();
                }
            }
            if (scorePartwise.getPart().size() > 0)
            {
                i.Part = (ScorePartwise.Part)scorePartwise.getPart().get(0);
            }
            return(i);
        }