コード例 #1
0
ファイル: RiffBeam.cs プロジェクト: svejdo1/niffty
        /** Creates new Beam 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 Beam newInstance(Riff parentInput)
        {
            Riff riffInput = new Riff(parentInput, RIFF_ID);

              return new Beam
            (riffInput.readBYTE(), riffInput.readBYTE(),
             RiffTags.newInstance(riffInput));
        }
コード例 #2
0
ファイル: RiffBeam.cs プロジェクト: svejdo1/niffty
        /** Creates new Beam 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 Beam newInstance(Riff parentInput)
        {
            Riff riffInput = new Riff(parentInput, RIFF_ID);

            return(new Beam
                       (riffInput.readBYTE(), riffInput.readBYTE(),
                       RiffTags.newInstance(riffInput)));
        }
コード例 #3
0
ファイル: RiffBarline.cs プロジェクト: svejdo1/niffty
        /** 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)));
        }
コード例 #4
0
ファイル: RiffBarline.cs プロジェクト: svejdo1/niffty
        /** 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
ファイル: RiffClef.cs プロジェクト: svejdo1/niffty
        /** Creates new Clef 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 Clef newInstance(Riff parentInput)
        {
            Riff riffInput = new Riff(parentInput, RIFF_ID);

            return(new Clef
                       (convertShape(riffInput.readBYTE()),
                       riffInput.readSIGNEDBYTE(),
                       convertOctaveNumber(riffInput.readBYTE()),
                       RiffTags.newInstance(riffInput)));
        }
コード例 #6
0
ファイル: RiffClef.cs プロジェクト: svejdo1/niffty
        /** Creates new Clef 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 Clef newInstance(Riff parentInput)
        {
            Riff riffInput = new Riff(parentInput, RIFF_ID);

              return new Clef
             (convertShape(riffInput.readBYTE()),
              riffInput.readSIGNEDBYTE(),
              convertOctaveNumber(riffInput.readBYTE()),
              RiffTags.newInstance(riffInput));
        }
コード例 #7
0
ファイル: RiffStringTable.cs プロジェクト: svejdo1/niffty
        /** Peek into the parentInput's input stream and if the next item
         * is a NIFF String Table, then decode it and store it in the
         * root RIFFForNIFF object.
         * If the next item is not a NIFF String Table, do nothing
         * and leave the input stream unchanged.
         *
         * @param parentInput    the parent RIFF object being used to read the input stream.
         *        If parentInput.getParent() is not of type RIFFForNIFF, then this
         *        moves the input past the String Table but does not store it.
         * @return true if the String Table was processed, false if this is
         *         not a String Table.
         */
        static public bool maybeDecode(Riff parentInput)
        {
            if (!parentInput.peekFOURCC().Equals(RIFF_ID))
            {
                return(false);
            }

            Riff riffInput = new Riff(parentInput, RIFF_ID);

            if (!(parentInput.getParent() is RiffForNiff))
            {
                // There is no place to store the data
                riffInput.skipRemaining();
                return(true);
            }
            RiffForNiff riffForNiff = (RiffForNiff)parentInput.getParent();

            // Read the entire string table into a byte array
            byte[] stringTable = new byte[riffInput.getBytesRemaining()];
            for (int i = 0; i < stringTable.Length; ++i)
            {
                stringTable[i] = (byte)riffInput.readBYTE();
            }
            riffForNiff.setStringTable(stringTable);

            // This skips possible pad byte
            riffInput.skipRemaining();

            return(true);
        }
コード例 #8
0
ファイル: RiffAccidental.cs プロジェクト: svejdo1/niffty
        /** Creates new Accidental 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 Accidental newInstance(Riff parentInput)
        {
            Riff riffInput = new Riff(parentInput, RIFF_ID);

              return new Accidental
            (convertShape(riffInput.readBYTE()),
             RiffTags.newInstance(riffInput));
        }
コード例 #9
0
ファイル: RiffAccidental.cs プロジェクト: svejdo1/niffty
        /** Creates new Accidental 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 Accidental newInstance(Riff parentInput)
        {
            Riff riffInput = new Riff(parentInput, RIFF_ID);

            return(new Accidental
                       (convertShape(riffInput.readBYTE()),
                       RiffTags.newInstance(riffInput)));
        }
コード例 #10
0
ファイル: RiffLyric.cs プロジェクト: svejdo1/niffty
        /** Creates a new Lyric 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 Lyric newInstance(Riff parentInput)
        {
            Riff riffInput = new Riff(parentInput, RIFF_ID);

              String text = RiffStringTable.decodeString
            (RiffForNiff.getStringTable(parentInput), riffInput.readLONG());
              return new Lyric
            (text, riffInput.readBYTE(), RiffTags.newInstance(riffInput));
        }
コード例 #11
0
ファイル: RiffNotehead.cs プロジェクト: svejdo1/niffty
        /** 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));
        }
コード例 #12
0
ファイル: RiffLyric.cs プロジェクト: svejdo1/niffty
        /** Creates a new Lyric 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 Lyric newInstance(Riff parentInput)
        {
            Riff riffInput = new Riff(parentInput, RIFF_ID);

            String text = RiffStringTable.decodeString
                              (RiffForNiff.getStringTable(parentInput), riffInput.readLONG());

            return(new Lyric
                       (text, riffInput.readBYTE(), RiffTags.newInstance(riffInput)));
        }
コード例 #13
0
ファイル: RiffRest.cs プロジェクト: svejdo1/niffty
        /** 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)));
        }
コード例 #14
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)));
        }
コード例 #15
0
ファイル: RiffNiffInfo.cs プロジェクト: svejdo1/niffty
        /** 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()));
        }
コード例 #16
0
ファイル: RiffNiffInfo.cs プロジェクト: svejdo1/niffty
        /** 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());
        }
コード例 #17
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)));
        }
コード例 #18
0
ファイル: RiffTimeSlice.cs プロジェクト: svejdo1/niffty
        /** 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));
        }
コード例 #19
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));
        }
コード例 #20
0
ファイル: RiffStringTable.cs プロジェクト: svejdo1/niffty
        /** Peek into the parentInput's input stream and if the next item
         * is a NIFF String Table, then decode it and store it in the
         * root RIFFForNIFF object.
         * If the next item is not a NIFF String Table, do nothing
         * and leave the input stream unchanged.
         *
         * @param parentInput    the parent RIFF object being used to read the input stream.
         *        If parentInput.getParent() is not of type RIFFForNIFF, then this
         *        moves the input past the String Table but does not store it.
         * @return true if the String Table was processed, false if this is
         *         not a String Table.
         */
        public static bool maybeDecode(Riff parentInput)
        {
            if (!parentInput.peekFOURCC().Equals(RIFF_ID))
            return false;

              Riff riffInput = new Riff(parentInput, RIFF_ID);

              if (!(parentInput.getParent() is RiffForNiff)) {
            // There is no place to store the data
            riffInput.skipRemaining();
            return true;
              }
              RiffForNiff riffForNiff = (RiffForNiff)parentInput.getParent();

              // Read the entire string table into a byte array
              byte[] stringTable = new byte[riffInput.getBytesRemaining()];
              for (int i = 0; i < stringTable.Length; ++i)
            stringTable[i] = (byte)riffInput.readBYTE();
              riffForNiff.setStringTable(stringTable);

              // This skips possible pad byte
              riffInput.skipRemaining();

              return true;
        }