/// <summary>
        /// Saves the Sequence as a MIDI file.
        /// </summary>
        /// <param name="fileName">
        /// The name to use for saving the MIDI file.
        /// </param>
        public void Save(string fileName)
        {
            #region Require

            if (disposed)
            {
                throw new ObjectDisposedException("Sequence");
            }
            else if (fileName == null)
            {
                throw new ArgumentNullException("fileName");
            }

            #endregion

            FileStream stream = new FileStream(fileName, FileMode.Create,
                                               FileAccess.Write, FileShare.None);

            using (stream)
            {
                properties.Write(stream);

                TrackWriter writer = new TrackWriter();

                foreach (Track trk in tracks)
                {
                    writer.Track = trk;
                    writer.Write(stream);
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Saves the Sequence as a Stream.
        /// </summary>
        /// <param name="stream">
        /// The stream to use for saving the sequence.
        /// </param>
        public void Save(Stream stream)
        {
            properties.Write(stream);

            TrackWriter writer = new TrackWriter();

            foreach (Track trk in tracks)
            {
                writer.Track = trk;
                writer.Write(stream);
            }
        }
        public MemoryStream Save()
        {
            var ms = new MemoryStream();

            properties.Write(ms);

            var writer = new TrackWriter();

            foreach (Track trk in tracks)
            {
                writer.Track = trk;
                writer.Write(ms);
            }
            ms.Seek(0, SeekOrigin.Begin);
            return(ms);
        }