Exemplo n.º 1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Read the mdat chunk and save the data read to the SA document writer.
        /// </summary>
        /// <returns>true if success. Otherwise, false</returns>
        /// ------------------------------------------------------------------------------------
        public bool ReadMdatChunk()
        {
            try {
                //Start at the beginning of utt chunk plus advance four
                //positions to move past the chunk ID.
                m_stream.Position = GetChunkOffset(m_stream, kidMdatChunk) + 4;
                int chunkSize = (int)m_reader.ReadUInt32();
                if (chunkSize == 0)
                {
                    return(true);
                }

                //Read the SAMA string
                string samaString = new string(m_reader.ReadChars(chunkSize));
                char[] trimChars  = { '\0' };
                samaString = samaString.TrimEnd(trimChars);
                if (samaString.Length > 0)
                {
                    // adjust SAMA ver 2 to SAMA ver 3
                    string samaStringConverted = ConvertSAMA2To3(samaString);
                    m_writer.WriteAsMusicXML(samaStringConverted);
                }
            } catch {
                return(false);
            }

            return(true);
        }