Пример #1
0
        /** Creates new Rest 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 Rest newInstance(Riff parentInput)
        {
            Riff riffInput = new Riff(parentInput, RIFF_ID);

            return(new Rest
                       (convertShape(riffInput.readBYTE()),
                       riffInput.readSIGNEDBYTE(),
                       new Rational(riffInput.readSHORT(), riffInput.readSHORT()),
                       RiffTags.newInstance(riffInput)));
        }
Пример #2
0
        /** Creates new Notehead 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 Notehead newInstance(Riff parentInput)
        {
            Riff riffInput = new Riff(parentInput, RIFF_ID);

              return new Notehead
            (convertShape(riffInput.readBYTE()),
             riffInput.readSIGNEDBYTE(),
             new Rational(riffInput.readSHORT(), riffInput.readSHORT()),
             RiffTags.newInstance(riffInput));
        }
Пример #3
0
        /** Creates new MeasureStartTimeSlice from the parentInput's input stream.
         * The next object in the input stream must be a time slice with type MEASURE_START.
         * After creating the MeasureStartTimeSlice, you can call addTimeSlices()
         * to store the event time slices for this measure start time slice.
         *
         * @param parentInput    the parent RIFF object being used to read the input stream
         * @see #addTimeSlices
         */
        static public MeasureStartTimeSlice newInstance(Riff parentInput)
        {
            Riff riffInput = new Riff(parentInput, RIFF_ID);

            int type = riffInput.readBYTE();

            if (type != MEASURE_START)
            {
                throw new RiffFormatException
                          ("Expected MEASURE_START for time slice type. Got " + type + ".");
            }

            return(new MeasureStartTimeSlice
                       (new Rational(riffInput.readSHORT(), riffInput.readSHORT()),
                       RiffTags.newInstance(riffInput)));
        }
Пример #4
0
        /** Creates a new Barline 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 Barline newInstance(Riff parentInput)
        {
            Riff riffInput = new Riff(parentInput, RIFF_ID);

              return new Barline
            (convertType(riffInput.readBYTE()),
             convertExtendsTo(riffInput.readBYTE()),
             riffInput.readSHORT(),
             RiffTags.newInstance(riffInput));
        }
Пример #5
0
        /** Creates a new Barline 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 Barline newInstance(Riff parentInput)
        {
            Riff riffInput = new Riff(parentInput, RIFF_ID);

            return(new Barline
                       (convertType(riffInput.readBYTE()),
                       convertExtendsTo(riffInput.readBYTE()),
                       riffInput.readSHORT(),
                       RiffTags.newInstance(riffInput)));
        }
Пример #6
0
        /** Creates new TimeSlice from the parentInput's input stream.
         * The next object in the input stream must be a time slice with
         * a type any other than MEASURE_START (which means the type should
         * be EVENT).
         * After creating the TimeSlice, you can call addMusicSymbols()
         * to store the music symbols for this time slice.
         *
         * @param parentInput    the parent RIFF object being used to read the input stream
         * @see #addMusicSymbols
         */
        static public TimeSlice newInstance(Riff parentInput)
        {
            Riff riffInput = new Riff(parentInput, RIFF_ID);

            int type = riffInput.readBYTE();

            if (type == MEASURE_START)
            {
                throw new RiffFormatException
                          ("Did not expect a time slice with type MEASURE_START.");
            }
            else if (type != EVENT)
            {
                throw new RiffFormatException
                          ("Expected EVENT for time slice type. Got " + type + ".");
            }

            return(new TimeSlice
                       (new Rational(riffInput.readSHORT(), riffInput.readSHORT()),
                       RiffTags.newInstance(riffInput)));
        }
Пример #7
0
        /** Creates new NIFFInfo 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 NiffInfo newInstance(Riff parentInput)
        {
            Riff riffInput = new Riff(parentInput, RIFF_ID);

            // Read 8 bytes and convert to string
            byte[] buffer = new byte[8];
            buffer[0] = (byte)riffInput.readBYTE();
            buffer[1] = (byte)riffInput.readBYTE();
            buffer[2] = (byte)riffInput.readBYTE();
            buffer[3] = (byte)riffInput.readBYTE();
            buffer[4] = (byte)riffInput.readBYTE();
            buffer[5] = (byte)riffInput.readBYTE();
            buffer[6] = (byte)riffInput.readBYTE();
            buffer[7] = (byte)riffInput.readBYTE();

            return(new NiffInfo
                       (Encoding.UTF8.GetString(buffer, 0, buffer.Length),
                       riffInput.readSIGNEDBYTE(),
                       riffInput.readSIGNEDBYTE(),
                       riffInput.readSHORT(),
                       riffInput.readSHORT()));
        }
Пример #8
0
        /** Creates new NIFFInfo 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 NiffInfo newInstance(Riff parentInput)
        {
            Riff riffInput = new Riff (parentInput, RIFF_ID);

            // Read 8 bytes and convert to string
            byte[] buffer = new byte[8];
            buffer[0] = (byte)riffInput.readBYTE();
            buffer[1] = (byte)riffInput.readBYTE();
            buffer[2] = (byte)riffInput.readBYTE();
            buffer[3] = (byte)riffInput.readBYTE();
            buffer[4] = (byte)riffInput.readBYTE();
            buffer[5] = (byte)riffInput.readBYTE();
            buffer[6] = (byte)riffInput.readBYTE();
            buffer[7] = (byte)riffInput.readBYTE();

            return new NiffInfo
              (Encoding.UTF8.GetString(buffer, 0, buffer.Length),
               riffInput.readSIGNEDBYTE(),
               riffInput.readSIGNEDBYTE(),
               riffInput.readSHORT(),
               riffInput.readSHORT());
        }
Пример #9
0
        /** Creates new MeasureStartTimeSlice from the parentInput's input stream.
         * The next object in the input stream must be a time slice with type MEASURE_START.
         * After creating the MeasureStartTimeSlice, you can call addTimeSlices()
         * to store the event time slices for this measure start time slice.
         *
         * @param parentInput    the parent RIFF object being used to read the input stream
         * @see #addTimeSlices
         */
        public static MeasureStartTimeSlice newInstance(Riff parentInput)
        {
            Riff riffInput = new Riff(parentInput, RIFF_ID);

              int type = riffInput.readBYTE();
              if (type != MEASURE_START)
            throw new RiffFormatException
            ("Expected MEASURE_START for time slice type. Got " + type + ".");

              return new MeasureStartTimeSlice
            (new Rational(riffInput.readSHORT(), riffInput.readSHORT()),
             RiffTags.newInstance(riffInput));
        }
Пример #10
0
        /** Creates new TimeSlice from the parentInput's input stream.
         * The next object in the input stream must be a time slice with
         * a type any other than MEASURE_START (which means the type should
         * be EVENT).
         * After creating the TimeSlice, you can call addMusicSymbols()
         * to store the music symbols for this time slice.
         *
         * @param parentInput    the parent RIFF object being used to read the input stream
         * @see #addMusicSymbols
         */
        public static TimeSlice newInstance(Riff parentInput)
        {
            Riff riffInput = new Riff(parentInput, RIFF_ID);

              int type = riffInput.readBYTE();
              if (type == MEASURE_START)
            throw new RiffFormatException
            ("Did not expect a time slice with type MEASURE_START.");
              else if (type != EVENT)
            throw new RiffFormatException
            ("Expected EVENT for time slice type. Got " + type + ".");

              return new TimeSlice
            (new Rational(riffInput.readSHORT(), riffInput.readSHORT()),
             RiffTags.newInstance(riffInput));
        }