/// <summary> /// Initializes a new instance of the <see cref="TimedEventsManager"/> with the specified events /// collection and comparison delegate for events that have same time. /// </summary> /// <param name="eventsCollection"><see cref="EventsCollection"/> that holds events to manage.</param> /// <param name="sameTimeEventsComparison">Delegate to compare events with the same absolute time.</param> /// <remarks> /// If the <paramref name="sameTimeEventsComparison"/> is not specified events with the same time /// will be placed into the underlying events collection in order of adding them through the manager. /// If you want to specify custom order of such events you need to specify appropriate comparison delegate. /// </remarks> /// <exception cref="ArgumentNullException"><paramref name="eventsCollection"/> is null.</exception> public TimedEventsManager(EventsCollection eventsCollection, Comparison <MidiEvent> sameTimeEventsComparison = null) { ThrowIfArgument.IsNull(nameof(eventsCollection), eventsCollection); _eventsCollection = eventsCollection; Events = new TimedEventsCollection(CreateTimedEvents(eventsCollection), sameTimeEventsComparison); }
/// <summary> /// Adds a <see cref="MidiEvent"/> into a <see cref="TimedEventsCollection"/> with the specified /// absolute time. /// </summary> /// <param name="eventsCollection"><see cref="TimedEventsCollection"/> to add an event into.</param> /// <param name="midiEvent">Event to add into the <paramref name="eventsCollection"/>.</param> /// <param name="time">Absolute time that will be assigned to the <paramref name="midiEvent"/> /// when it will be placed into the <paramref name="eventsCollection"/>.</param> /// <exception cref="ArgumentNullException"> /// <para>One of the following errors occured:</para> /// <list type="bullet"> /// <item> /// <description><paramref name="eventsCollection"/> is <c>null</c>.</description> /// </item> /// <item> /// <description><paramref name="midiEvent"/> is <c>null</c>.</description> /// </item> /// </list> /// </exception> /// <exception cref="ArgumentOutOfRangeException"><paramref name="time"/> is negative.</exception> public static void AddEvent(this TimedEventsCollection eventsCollection, MidiEvent midiEvent, long time) { ThrowIfArgument.IsNull(nameof(eventsCollection), eventsCollection); ThrowIfArgument.IsNull(nameof(midiEvent), midiEvent); ThrowIfTimeArgument.IsNegative(nameof(time), time); eventsCollection.Add(new TimedEvent(midiEvent, time)); }
/// <summary> /// Adds a <see cref="MidiEvent"/> into a <see cref="TimedEventsCollection"/> with the specified /// absolute time. /// </summary> /// <param name="eventsCollection"><see cref="TimedEventsCollection"/> to add an event into.</param> /// <param name="midiEvent">Event to add into the <paramref name="eventsCollection"/>.</param> /// <param name="time">Absolute time that will be assigned to the <paramref name="midiEvent"/> /// when it will be placed into the <paramref name="eventsCollection"/>.</param> /// <param name="tempoMap">Tempo map used to place <paramref name="midiEvent"/> into the /// <paramref name="eventsCollection"/> with the specified time.</param> /// <exception cref="ArgumentNullException"> /// <para>One of the following errors occured:</para> /// <list type="bullet"> /// <item> /// <description><paramref name="eventsCollection"/> is <c>null</c>.</description> /// </item> /// <item> /// <description><paramref name="midiEvent"/> is <c>null</c>.</description> /// </item> /// <item> /// <description><paramref name="time"/> is <c>null</c>.</description> /// </item> /// <item> /// <description><paramref name="tempoMap"/> is <c>null</c>.</description> /// </item> /// </list> /// </exception> public static void AddEvent(this TimedEventsCollection eventsCollection, MidiEvent midiEvent, ITimeSpan time, TempoMap tempoMap) { ThrowIfArgument.IsNull(nameof(eventsCollection), eventsCollection); ThrowIfArgument.IsNull(nameof(midiEvent), midiEvent); ThrowIfArgument.IsNull(nameof(time), time); ThrowIfArgument.IsNull(nameof(tempoMap), tempoMap); eventsCollection.AddEvent(midiEvent, TimeConverter.ConvertFrom(time, tempoMap)); }
/// <summary> /// Adds a <see cref="MidiEvent"/> into a <see cref="TimedEventsCollection"/> with the specified /// absolute time. /// </summary> /// <param name="eventsCollection"><see cref="TimedEventsCollection"/> to add an event into.</param> /// <param name="midiEvent">Event to add into the <paramref name="eventsCollection"/>.</param> /// <param name="time">Absolute time that will be assigned to the <paramref name="midiEvent"/> /// when it will be placed into the <paramref name="eventsCollection"/>.</param> /// <exception cref="ArgumentNullException"> /// <para>One of the following errors occured:</para> /// <list type="bullet"> /// <item> /// <description><paramref name="eventsCollection"/> is <c>null</c>.</description> /// </item> /// <item> /// <description><paramref name="midiEvent"/> is <c>null</c>.</description> /// </item> /// </list> /// </exception> /// <exception cref="ArgumentOutOfRangeException"><paramref name="time"/> is negative.</exception> /// <exception cref="ArgumentException"><paramref name="midiEvent"/> is either system real-time or /// system common one.</exception> public static void AddEvent(this TimedEventsCollection eventsCollection, MidiEvent midiEvent, long time) { ThrowIfArgument.IsNull(nameof(eventsCollection), eventsCollection); ThrowIfArgument.IsNull(nameof(midiEvent), midiEvent); ThrowIfArgument.IsOfInvalidType <SystemRealTimeEvent, SystemCommonEvent>(nameof(midiEvent), midiEvent, "Event is either system real-time or system common one."); ThrowIfTimeArgument.IsNegative(nameof(time), time); eventsCollection.Add(new TimedEvent(midiEvent, time)); }
/// <summary> /// Adds a <see cref="MidiEvent"/> into a <see cref="TimedEventsCollection"/> with the specified /// absolute time. /// </summary> /// <param name="eventsCollection"><see cref="TimedEventsCollection"/> to add an event into.</param> /// <param name="midiEvent">Event to add into the <paramref name="eventsCollection"/>.</param> /// <param name="time">Absolute time that will be assigned to the <paramref name="midiEvent"/> /// when it will be placed into the <paramref name="eventsCollection"/>.</param> /// <param name="tempoMap">Tempo map used to place <paramref name="midiEvent"/> into the /// <paramref name="eventsCollection"/> with the specified time.</param> /// <exception cref="ArgumentNullException"> /// <para>One of the following errors occured:</para> /// <list type="bullet"> /// <item> /// <description><paramref name="eventsCollection"/> is <c>null</c>.</description> /// </item> /// <item> /// <description><paramref name="midiEvent"/> is <c>null</c>.</description> /// </item> /// <item> /// <description><paramref name="time"/> is <c>null</c>.</description> /// </item> /// <item> /// <description><paramref name="tempoMap"/> is <c>null</c>.</description> /// </item> /// </list> /// </exception> /// <exception cref="ArgumentException"><paramref name="midiEvent"/> is either system real-time or /// system common one.</exception> public static void AddEvent(this TimedEventsCollection eventsCollection, MidiEvent midiEvent, ITimeSpan time, TempoMap tempoMap) { ThrowIfArgument.IsNull(nameof(eventsCollection), eventsCollection); ThrowIfArgument.IsNull(nameof(midiEvent), midiEvent); ThrowIfArgument.IsOfInvalidType <SystemRealTimeEvent, SystemCommonEvent>(nameof(midiEvent), midiEvent, "Event is either system real-time or system common one."); ThrowIfArgument.IsNull(nameof(time), time); ThrowIfArgument.IsNull(nameof(tempoMap), tempoMap); eventsCollection.AddEvent(midiEvent, TimeConverter.ConvertFrom(time, tempoMap)); }