コード例 #1
0
        internal static FileChunkReader CreateReader(string filePath)
        {
            var context = Factory.CreateFileContextForReading(filePath);
            var reader  = new FileChunkReader(context);

            return(reader);
        }
コード例 #2
0
ファイル: MidiFileReader.cs プロジェクト: yakivyusin/Badadoom
        public MidiFileReader(string filePath)
        {
            file   = filePath;
            reader = FileReaderFactory.CreateReader(file);
            data   = new MidiFileData();

            ReadMidiFile();
        }
コード例 #3
0
        internal static FileChunkReader CreateReader(string filePath, Endianness endianness)
        {
            var context = new ChunkFileContextBuilder()
                          .Endianness(endianness)
                          .ByteAllign(2)
                          .ForReading(filePath)
                          .Discover(typeof(FileChunkReaderTests).Assembly)
                          .Build();

            var reader = new FileChunkReader(context);

            return(reader);
        }
コード例 #4
0
        /// <summary>
        /// Read event data of a Midi file prepared chunk-file context.
        /// </summary>
        /// <param name="context">Must not be null.</param>
        /// <returns>Never returns null.</returns>
        /// <remarks>May throw exceptions.</remarks>
        public static MidiFile Read(ChunkFileContext context)
        {
            Check.IfArgumentNull(context, nameof(context));

            var reader = new FileChunkReader(context);
            var file   = new MidiFile
            {
                Header = reader.ReadNextChunk() as MThdChunk
            };

            var tracks = new List <MTrkChunk>();

            for (int i = 0; i < file.Header.NumberOfTracks; i++)
            {
                var track = reader.ReadNextChunk() as MTrkChunk;
                tracks.Add(track);
            }

            file.Tracks = tracks;
            return(file);
        }