Esempio n. 1
0
        static public MidiMessageCollection FromFile(string smfFilePath)
        {
            MidiMessageCollection collection = null;

            using (Reader reader = new Reader()
            {
                GenerateMessageList = true
            })
            {
                reader.FileHandle = new chunk.MThd(smfFilePath);

                reader.MidiMessages.Division   = reader.Division;
                reader.MidiMessages.MidiFormat = reader.FileHandle.Format;

                reader.ParseTempoMap(0);

                reader.MessageHandler = reader.OnMidiMessage;

                reader.ParseAll();
                reader.TempoMap.Finalize(reader);

                collection = new MidiMessageCollection(reader.MidiMessages);
                collection.CopyReaderTempoMap(reader);
                collection.RecalculateDeltas();
                reader.ResetTempoMap();
            }
            return(collection);
        }
Esempio n. 2
0
 /// <summary>
 /// Allows you to clone the messages and properties from another MidiMessageCollection.
 /// </summary>
 /// <param name="collection"></param>
 public MidiMessageCollection(MidiMessageCollection collection)
     : base((System.Collections.Generic.IDictionary <int, System.Collections.Generic.List <MidiMessage> >)collection)
 {
     MidiFormat = collection.MidiFormat;
     Division   = collection.Division;
     //
     if (collection.TempoMap != null)
     {
         TempoMap = collection.TempoMap.Copy();
     }
     if (collection.KeySignature != null)
     {
         KeySignature = collection.KeySignature.Copy();
     }
     if (collection.TimeSignature != null)
     {
         TimeSignature = collection.TimeSignature.Copy();
     }
     if (collection.SMPTE != null)
     {
         SMPTE = collection.SMPTE.Copy();
     }
 }