Exemplo n.º 1
0
        /** Creates new StaffSystem from the parentInput's input stream.
         * The next object in the input stream must be of this type.
         *
         * @param parentInput    the parent RIFF object being used to read the input stream
         */
        static public StaffSystem newInstance(Riff parentInput)
        {
            Riff riffInput = new Riff(parentInput, "LIST");

            riffInput.requireFOURCC(RIFF_ID);

            StaffSystem staffSystem = new StaffSystem
                                          (RiffStaffSystemHeader.newInstance(riffInput));

            // debug: check for NIFFStaffGrouping

            while (riffInput.getBytesRemaining() > 0)
            {
                Staff staff;
                if ((staff = RiffStaff.maybeNew(riffInput)) != null)
                {
                    // Call addChild() which will set the child's parent to this.
                    staffSystem.addStaff(staff);
                }
                // debug: must check for NIFFFontSymbol, etc.
                else
                {
                    // Did not recognize the chunk type, so skip
                    riffInput.skipChunk();
                }
            }

            return(staffSystem);
        }
Exemplo n.º 2
0
        /** Creates new Page from the parentInput's input stream.
         * The next object in the input stream must be of this type.
         *
         * @param parentInput    the parent RIFF object being used to read the input stream
         */
        static public Page newInstance(Riff parentInput)
        {
            Riff riffInput = new Riff(parentInput, "LIST");

            riffInput.requireFOURCC(RIFF_ID);

            Page page = new Page(RiffPageHeader.newInstance(riffInput));

            while (riffInput.getBytesRemaining() > 0)
            {
                StaffSystem staffSystem;
                if ((staffSystem = RiffStaffSystem.maybeNew(riffInput)) != null)
                {
                    page.addSystem(staffSystem);
                }
                // debug: must check for NIFFFontSymbol, etc.
                else
                {
                    // Did not recognize the chunk type, so skip
                    riffInput.skipChunk();
                }
            }

            return(page);
        }
Exemplo n.º 3
0
        /** Creates new PartsList from the parentInput's input stream.
         * The next object in the input stream must be of this type.
         *
         * @param parentInput    the parent RIFF object being used to read the input stream
         */
        public static PartsList newInstance(Riff parentInput)
        {
            Riff riffInput = new Riff(parentInput, "LIST");
              riffInput.requireFOURCC(RIFF_ID);

              // Debug. Just skip remaining for now.
              riffInput.skipRemaining();
              return new PartsList();
        }
Exemplo n.º 4
0
        /** Creates new PartsList from the parentInput's input stream.
         * The next object in the input stream must be of this type.
         *
         * @param parentInput    the parent RIFF object being used to read the input stream
         */
        static public PartsList newInstance(Riff parentInput)
        {
            Riff riffInput = new Riff(parentInput, "LIST");

            riffInput.requireFOURCC(RIFF_ID);

            // Debug. Just skip remaining for now.
            riffInput.skipRemaining();
            return(new PartsList());
        }
Exemplo n.º 5
0
        /** Creates new ScoreSetup from the parentInput's input stream.
         * The next object in the input stream must be of this type.
         *
         * @param parentInput    the parent RIFF object being used to read the input stream
         */
        static public ScoreSetup newInstance(Riff parentInput)
        {
            Riff riffInput = new Riff(parentInput, "LIST");

            riffInput.requireFOURCC(RIFF_ID);

            NiffInfo         niffInfo         = null;
            ChunkLengthTable chunkLengthTable = null;
            PartsList        partsList        = null;

            while (riffInput.getBytesRemaining() > 0)
            {
                Object obj;
                if ((obj = RiffChunkLengthTable.maybeNew(riffInput)) != null)
                {
                    chunkLengthTable = (ChunkLengthTable)obj;
                }
                else if ((obj = RiffNiffInfo.maybeNew(riffInput)) != null)
                {
                    niffInfo = (NiffInfo)obj;
                }
                else if ((obj = RiffPartsList.maybeNew(riffInput)) != null)
                {
                    partsList = (PartsList)obj;
                }
                else if (RiffStringTable.maybeDecode(riffInput))
                {
                    // Do nothing.  The String Table was stored for later use.
                }
                // debug: check for other optional chunks
                else
                {
                    // Did not recognize the chunk type, so skip
                    riffInput.skipChunk();
                }
            }

            // Make sure required chunks are present.
            if (niffInfo == null)
            {
                throw new RiffFormatException("Can't find NIFF info chunk in Setup section.");
            }
            if (chunkLengthTable == null)
            {
                throw new RiffFormatException("Can't find chunk length table in Setup section.");
            }
            if (partsList == null)
            {
                throw new RiffFormatException("Can't find parts list chunk in Setup section.");
            }

            return(new ScoreSetup(niffInfo, chunkLengthTable, partsList));
        }
Exemplo n.º 6
0
        /** Creates new Staff from the parentInput's input stream.
         * The next object in the input stream must be of this type.
         * This also reads all the enclosed MeasureStartTimeSlice objects
         * which themselves contain the event TimeSlice and MusicSymbol objects.
         *
         * @param parentInput    the parent RIFF object being used to read the input stream
         */
        public static Staff newInstance(Riff parentInput)
        {
            Riff riffInput = new Riff(parentInput, "LIST");
              riffInput.requireFOURCC(RIFF_ID);

              Staff staff = new Staff(RiffStaffHeader.newInstance(riffInput));

              if (riffInput.getBytesRemaining() <= 0)
            // the staff is empty
            return staff;

              MeasureStartTimeSlice measureStart =
             RiffMeasureStartTimeSlice.maybeNew(riffInput);
              if (measureStart == null) {
            // For some reason, the first chunk in this staff is not a
            //   measure start time slice.  Create a fake one based
            //   on the previous staff system's end time
            // DEBUG: must implement this!  For now use start time of 0/1
            measureStart = new MeasureStartTimeSlice(new Rational(0, 1), null);
              }

              while (true) {
            if (staff.getMeasureStartCount() > 0 &&
            staff.getMeasureStart
              (staff.getMeasureStartCount() - 1).getStartTime().Equals
            (measureStart.getStartTime()))
              // This new measure start time is the same as the last one,
              // so just continue using the last one.
              // DEBUG: this still doesn't ensure increasing order
              // DEBUG: This discards the tags in the newly read measure start
              measureStart =
            staff.getMeasureStart(staff.getMeasureStartCount() - 1);
            else
              staff.addMeasureStart(measureStart);

            // Read event time slices until the next measure start time slice or
            //    end of the staff
            RiffMeasureStartTimeSlice.addTimeSlices(riffInput, measureStart);
            if (riffInput.getBytesRemaining() <= 0)
              // reached the end of the staff
              break;

            // The previous call to readTimeSlices has already
            //   ensured that the next chunk is a measure start time slice.
            measureStart = RiffMeasureStartTimeSlice.newInstance(riffInput);
              }

              return staff;
        }
Exemplo n.º 7
0
        /** Creates new ScoreData from the parentInput's input stream.
         * The next object in the input stream must be of this type.
         *
         * @param parentInput    the parent RIFF object being used to read the input stream
         */
        public static ScoreData newInstance(Riff parentInput)
        {
            Riff riffInput = new Riff(parentInput, "LIST");
              riffInput.requireFOURCC(RIFF_ID);

              ScoreData scoreData = new ScoreData();

              while (riffInput.getBytesRemaining() > 0) {
            // Create the child and call addChild() which will set the child's parent
            //   to this.
            scoreData.addPage(RiffPage.newInstance(riffInput));
              }

              return scoreData;
        }
Exemplo n.º 8
0
        /** Creates new ScoreData from the parentInput's input stream.
         * The next object in the input stream must be of this type.
         *
         * @param parentInput    the parent RIFF object being used to read the input stream
         */
        static public ScoreData newInstance(Riff parentInput)
        {
            Riff riffInput = new Riff(parentInput, "LIST");

            riffInput.requireFOURCC(RIFF_ID);

            ScoreData scoreData = new ScoreData();

            while (riffInput.getBytesRemaining() > 0)
            {
                // Create the child and call addChild() which will set the child's parent
                //   to this.
                scoreData.addPage(RiffPage.newInstance(riffInput));
            }

            return(scoreData);
        }
Exemplo n.º 9
0
        /** Creates new Page from the parentInput's input stream.
         * The next object in the input stream must be of this type.
         *
         * @param parentInput    the parent RIFF object being used to read the input stream
         */
        public static Page newInstance(Riff parentInput)
        {
            Riff riffInput = new Riff(parentInput, "LIST");
              riffInput.requireFOURCC(RIFF_ID);

              Page page = new Page(RiffPageHeader.newInstance(riffInput));

              while (riffInput.getBytesRemaining() > 0) {
            StaffSystem staffSystem;
            if ((staffSystem = RiffStaffSystem.maybeNew(riffInput)) != null)
              page.addSystem(staffSystem);
            // debug: must check for NIFFFontSymbol, etc.
            else
              // Did not recognize the chunk type, so skip
              riffInput.skipChunk();
              }

              return page;
        }
Exemplo n.º 10
0
        /** Creates new StaffSystem from the parentInput's input stream.
         * The next object in the input stream must be of this type.
         *
         * @param parentInput    the parent RIFF object being used to read the input stream
         */
        public static StaffSystem newInstance(Riff parentInput)
        {
            Riff riffInput = new Riff(parentInput, "LIST");
              riffInput.requireFOURCC(RIFF_ID);

              StaffSystem staffSystem = new StaffSystem
             (RiffStaffSystemHeader.newInstance(riffInput));
              // debug: check for NIFFStaffGrouping

              while (riffInput.getBytesRemaining() > 0) {
            Staff staff;
            if ((staff = RiffStaff.maybeNew(riffInput)) != null)
              // Call addChild() which will set the child's parent to this.
              staffSystem.addStaff(staff);
            // debug: must check for NIFFFontSymbol, etc.
            else
              // Did not recognize the chunk type, so skip
              riffInput.skipChunk();
              }

              return staffSystem;
        }
Exemplo n.º 11
0
        /** Creates new ScoreSetup from the parentInput's input stream.
         * The next object in the input stream must be of this type.
         *
         * @param parentInput    the parent RIFF object being used to read the input stream
         */
        public static ScoreSetup newInstance(Riff parentInput)
        {
            Riff riffInput = new Riff(parentInput, "LIST");
              riffInput.requireFOURCC(RIFF_ID);

              NiffInfo niffInfo = null;
              ChunkLengthTable chunkLengthTable = null;
              PartsList partsList = null;

              while (riffInput.getBytesRemaining() > 0) {
            Object obj;
            if ((obj = RiffChunkLengthTable.maybeNew(riffInput)) != null)
              chunkLengthTable = (ChunkLengthTable)obj;
            else if ((obj = RiffNiffInfo.maybeNew(riffInput)) != null)
              niffInfo = (NiffInfo)obj;
            else if ((obj = RiffPartsList.maybeNew(riffInput)) != null)
              partsList = (PartsList)obj;
            else if (RiffStringTable.maybeDecode(riffInput)) {
              // Do nothing.  The String Table was stored for later use.
            }
              // debug: check for other optional chunks
            else
              // Did not recognize the chunk type, so skip
              riffInput.skipChunk();
              }

              // Make sure required chunks are present.
              if (niffInfo == null)
            throw new RiffFormatException("Can't find NIFF info chunk in Setup section.");
              if (chunkLengthTable == null)
            throw new RiffFormatException("Can't find chunk length table in Setup section.");
              if (partsList == null)
            throw new RiffFormatException("Can't find parts list chunk in Setup section.");

              return new ScoreSetup(niffInfo, chunkLengthTable, partsList);
        }
Exemplo n.º 12
0
        /** Creates new Staff from the parentInput's input stream.
         * The next object in the input stream must be of this type.
         * This also reads all the enclosed MeasureStartTimeSlice objects
         * which themselves contain the event TimeSlice and MusicSymbol objects.
         *
         * @param parentInput    the parent RIFF object being used to read the input stream
         */
        static public Staff newInstance(Riff parentInput)
        {
            Riff riffInput = new Riff(parentInput, "LIST");

            riffInput.requireFOURCC(RIFF_ID);

            Staff staff = new Staff(RiffStaffHeader.newInstance(riffInput));

            if (riffInput.getBytesRemaining() <= 0)
            {
                // the staff is empty
                return(staff);
            }

            MeasureStartTimeSlice measureStart =
                RiffMeasureStartTimeSlice.maybeNew(riffInput);

            if (measureStart == null)
            {
                // For some reason, the first chunk in this staff is not a
                //   measure start time slice.  Create a fake one based
                //   on the previous staff system's end time
                // DEBUG: must implement this!  For now use start time of 0/1
                measureStart = new MeasureStartTimeSlice(new Rational(0, 1), null);
            }

            while (true)
            {
                if (staff.getMeasureStartCount() > 0 &&
                    staff.getMeasureStart
                        (staff.getMeasureStartCount() - 1).getStartTime().Equals
                        (measureStart.getStartTime()))
                {
                    // This new measure start time is the same as the last one,
                    // so just continue using the last one.
                    // DEBUG: this still doesn't ensure increasing order
                    // DEBUG: This discards the tags in the newly read measure start
                    measureStart =
                        staff.getMeasureStart(staff.getMeasureStartCount() - 1);
                }
                else
                {
                    staff.addMeasureStart(measureStart);
                }

                // Read event time slices until the next measure start time slice or
                //    end of the staff
                RiffMeasureStartTimeSlice.addTimeSlices(riffInput, measureStart);
                if (riffInput.getBytesRemaining() <= 0)
                {
                    // reached the end of the staff
                    break;
                }

                // The previous call to readTimeSlices has already
                //   ensured that the next chunk is a measure start time slice.
                measureStart = RiffMeasureStartTimeSlice.newInstance(riffInput);
            }

            return(staff);
        }