Esempio n. 1
0
        public MIDIFile(double BPM)
        {
            Header      = new MIDIHeader();
            TrackChunks = new List <MIDITrackChunk>();
            var FirstTrack = new MIDITrackChunk(0, "");

            FirstTrack.MTrkEvents.Add(new MTrkEvent(0)
            {
                Event = new TimeSignatureMetaEvent()
            });

            FirstTrack.MTrkEvents.Add(new MTrkEvent(0)
            {
                Event = new KeySignatureMetaEvent()
            });

            FirstTrack.MTrkEvents.Add(new MTrkEvent(0)
            {
                Event = new SMPTEOffsetMetaEvent()
            });

            FirstTrack.MTrkEvents.Add(new MTrkEvent(0)
            {
                Event = new SetTempoMetaEvent(BPM)
            });


            TrackChunks.Add(FirstTrack);
        }
Esempio n. 2
0
        public MIDIFile(string fileName)
        {
            var arr = File.ReadAllBytes(fileName);

            Header = new MIDIHeader(arr);

            var counter = 0;

            while (counter + 14 < arr.Length)
            {
                var tc = new MIDITrackChunk(arr.Skip(14 + counter).ToArray());
                TrackChunks.Add(tc);
                counter += (int)tc.Size + 8;
            }
        }