internal static FileChunkReader CreateReader(string filePath) { var context = Factory.CreateFileContextForReading(filePath); var reader = new FileChunkReader(context); return(reader); }
public MidiFileReader(string filePath) { file = filePath; reader = FileReaderFactory.CreateReader(file); data = new MidiFileData(); ReadMidiFile(); }
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); }
/// <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); }