示例#1
0
        /// <summary>
        /// This is for the most part a stand-alone parser.
        ///
        /// <seealso cref="ParseTempoMap(int)"/>
        /// </summary>
        void GetVSTMessageList(string smfFilePath)
        {
            FileHandle = new chunk.MThd(smfFilePath);
            ParseTempoMap(0);

            // override default message handler.
            MidiEventDelegate backup = MessageHandler;

            MessageHandler = VSTMessageListHandler;

            ParseAll();
            TempoMap.Finalize(this);

            // put back the message handler.
            MessageHandler = backup;
        }
示例#2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="smfFilePath"></param>
        /// <param name="overwrite"></param>
        /// <returns>True on error.</returns>
        public bool ToFile(string smfFilePath, bool overwrite = false)
        {
            if (System.IO.File.Exists(smfFilePath) && !overwrite)
            {
                return(true);
            }

            var mthd = new chunk.MThd(
                NTracks,
                Division,
                MidiFormat
                );

            using (var buffer = new System.IO.FileStream(smfFilePath, System.IO.FileMode.OpenOrCreate))
                using (var writer = new System.IO.BinaryWriter(buffer))
                {
                    mthd.Write(this, writer);
                }

            return(false);
        }