Exemple #1
0
    /// <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);
            }
        }
    }