Ejemplo n.º 1
0
        /// <summary>
        /// Inserts a set of chunks into the collection at the specified index.
        /// </summary>
        /// <remarks>
        /// Note that header chunks cannot be inserted into the collection since it may cause inconsistence in the file structure.
        /// Header chunk with appropriate information will be written to a file automatically on
        /// <see cref="MidiFile.Write(string, bool, MidiFileFormat, WritingSettings)"/>.
        /// </remarks>
        /// <param name="index">The zero-based index at which the chunk should be inserted.</param>
        /// <param name="chunks">The chunk to insert.</param>
        /// <exception cref="ArgumentNullException"><paramref name="chunks"/> is null.</exception>
        /// <exception cref="ArgumentOutOfRangeException"><paramref name="index"/> is less than 0. -or-
        /// <paramref name="index"/> is greater than <see cref="Count"/>.</exception>
        public void InsertRange(int index, IEnumerable <MidiChunk> chunks)
        {
            ThrowIfArgument.IsNull(nameof(chunks), chunks);
            ThrowIfArgument.IsInvalidIndex(nameof(index), index, _chunks.Count);

            _chunks.InsertRange(index, chunks.Where(c => c != null));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Inserts a chunk into the collection at the specified index.
        /// </summary>
        /// <remarks>
        /// Note that header chunks cannot be inserted into the collection since it may cause inconsistence in the file structure.
        /// Header chunk with appropriate information will be written to a file automatically on
        /// <see cref="MidiFile.Write(string, bool, MidiFileFormat, WritingSettings)"/>.
        /// </remarks>
        /// <param name="index">The zero-based index at which the chunk should be inserted.</param>
        /// <param name="chunk">The chunk to insert.</param>
        /// <exception cref="ArgumentNullException"><paramref name="chunk"/> is null.</exception>
        /// <exception cref="ArgumentOutOfRangeException"><paramref name="index"/> is less than 0. -or-
        /// <paramref name="index"/> is greater than <see cref="Count"/>.</exception>
        public void Insert(int index, MidiChunk chunk)
        {
            ThrowIfArgument.IsNull(nameof(chunk), chunk);
            ThrowIfArgument.IsInvalidIndex(nameof(index), index, _chunks.Count);

            _chunks.Insert(index, chunk);
        }
        /// <summary>
        /// Inserts a set of events into the collection at the specified index.
        /// </summary>
        /// <remarks>
        /// Note that End Of Track events cannot be added into the collection since it may cause inconsistence in a
        /// track chunk structure. End Of Track event will be written to the track chunk automatically on
        /// a MIDI file writing.
        /// </remarks>
        /// <param name="index">The zero-based index at which the events should be inserted.</param>
        /// <param name="midiEvents">The events to insert.</param>
        /// <exception cref="ArgumentNullException"><paramref name="midiEvents"/> is null.</exception>
        /// <exception cref="ArgumentOutOfRangeException"><paramref name="index"/> is less than 0. -or-
        /// <paramref name="index"/> is greater than <see cref="Count"/>.</exception>
        public void InsertRange(int index, IEnumerable <MidiEvent> midiEvents)
        {
            ThrowIfArgument.IsNull(nameof(midiEvents), midiEvents);
            ThrowIfArgument.IsInvalidIndex(nameof(index), index, _events.Count);

            _events.InsertRange(index, midiEvents);
        }
        /// <summary>
        /// Inserts an event into the collection at the specified index.
        /// </summary>
        /// <remarks>
        /// Note that End Of Track events cannot be added into the collection since it may cause inconsistence in a
        /// track chunk structure. End Of Track event will be written to the track chunk automatically on
        /// a MIDI file writing.
        /// </remarks>
        /// <param name="index">The zero-based index at which the event should be inserted.</param>
        /// <param name="midiEvent">The event to insert.</param>
        /// <exception cref="ArgumentNullException"><paramref name="midiEvent"/> is null.</exception>
        /// <exception cref="ArgumentOutOfRangeException"><paramref name="index"/> is less than 0. -or-
        /// <paramref name="index"/> is greater than <see cref="Count"/>.</exception>
        public void Insert(int index, MidiEvent midiEvent)
        {
            ThrowIfArgument.IsNull(nameof(midiEvent), midiEvent);
            ThrowIfArgument.IsInvalidIndex(nameof(index), index, _events.Count);

            _events.Insert(index, midiEvent);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Gets or sets the chunk at the specified index.
        /// </summary>
        /// <param name="index">The zero-based index of the chunk to get or set.</param>
        /// <returns>The chunk at the specified index.</returns>
        /// <exception cref="ArgumentOutOfRangeException">
        /// <paramref name="index"/> is less than 0; or <paramref name="index"/> is equal to or greater than
        /// <see cref="Count"/>.
        /// </exception>
        /// <exception cref="ArgumentNullException">value is null</exception>
        public MidiChunk this[int index]
        {
            get
            {
                ThrowIfArgument.IsInvalidIndex(nameof(index), index, _chunks.Count);

                return(_chunks[index]);
            }
            set
            {
                ThrowIfArgument.IsNull(nameof(value), value);
                ThrowIfArgument.IsInvalidIndex(nameof(index), index, _chunks.Count);

                _chunks[index] = value;
            }
        }
        /// <summary>
        /// Gets or sets the event at the specified index.
        /// </summary>
        /// <param name="index">The zero-based index of the event to get or set.</param>
        /// <returns>The event at the specified index.</returns>
        /// <exception cref="ArgumentOutOfRangeException"> <paramref name="index"/> is less than 0;
        /// or <paramref name="index"/> is equal to or greater than <see cref="Count"/>.</exception>
        /// <exception cref="ArgumentNullException">value is null.</exception>
        public MidiEvent this[int index]
        {
            get
            {
                ThrowIfArgument.IsInvalidIndex(nameof(index), index, _events.Count);

                return(_events[index]);
            }
            set
            {
                ThrowIfArgument.IsNull(nameof(value), value);
                ThrowIfArgument.IsInvalidIndex(nameof(index), index, _events.Count);

                _events[index] = value;
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Removes the chunk at the specified index of the collection.
        /// </summary>
        /// <param name="index">The zero-based index of the chunk to remove.</param>
        /// <exception cref="ArgumentOutOfRangeException"><paramref name="index"/> is less than 0; or <paramref name="index"/>
        /// is equal to or greater than <see cref="Count"/>.</exception>
        public void RemoveAt(int index)
        {
            ThrowIfArgument.IsInvalidIndex(nameof(index), index, _chunks.Count);

            _chunks.RemoveAt(index);
        }