Search Results for

    Show / Hide Table of Contents

    Class TimedEventsManagingUtilities

    Extension methods for managing MIDI events by their absolute time.
    Inheritance
    Object
    TimedEventsManagingUtilities
    Inherited Members
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Object.ReferenceEquals(Object, Object)
    Object.ToString()
    Namespace: Melanchall.DryWetMidi.Interaction
    Assembly: Melanchall.DryWetMidi.dll
    Syntax
    public static class TimedEventsManagingUtilities

    Methods

    AddEvent(TimedObjectsCollection<TimedEvent>, MidiEvent, ITimeSpan, TempoMap)

    Adds a MidiEvent into a TimedObjectsCollection<TObject> with the specified absolute time.
    Declaration
    [Obsolete("OBS16: Use TimedEvent constructor and add an object manually. More info: https://melanchall.github.io/drywetmidi/obsolete/obsolete.html#obs16.")]
    public static void AddEvent(this TimedObjectsCollection<TimedEvent> eventsCollection, MidiEvent midiEvent, ITimeSpan time, TempoMap tempoMap)
    Parameters
    Type Name Description
    TimedObjectsCollection<TimedEvent> eventsCollection TimedObjectsCollection<TObject> to add an event into.
    MidiEvent midiEvent Event to add into the eventsCollection.
    ITimeSpan time Absolute time that will be assigned to the midiEvent when it will be placed into the eventsCollection.
    TempoMap tempoMap Tempo map used to place midiEvent into the eventsCollection with the specified time.
    Exceptions
    Type Condition
    ArgumentNullException

    One of the following errors occured:

    • eventsCollection is null.
    • midiEvent is null.
    • time is null.
    • tempoMap is null.
    ArgumentException midiEvent is either system real-time or system common one.

    AddEvent(TimedObjectsCollection<TimedEvent>, MidiEvent, Int64)

    Adds a MidiEvent into a TimedObjectsCollection<TObject> with the specified absolute time.
    Declaration
    [Obsolete("OBS16: Use TimedEvent constructor and add an object manually. More info: https://melanchall.github.io/drywetmidi/obsolete/obsolete.html#obs16.")]
    public static void AddEvent(this TimedObjectsCollection<TimedEvent> eventsCollection, MidiEvent midiEvent, long time)
    Parameters
    Type Name Description
    TimedObjectsCollection<TimedEvent> eventsCollection TimedObjectsCollection<TObject> to add an event into.
    MidiEvent midiEvent Event to add into the eventsCollection.
    Int64 time Absolute time that will be assigned to the midiEvent when it will be placed into the eventsCollection.
    Exceptions
    Type Condition
    ArgumentNullException

    One of the following errors occured:

    • eventsCollection is null.
    • midiEvent is null.
    ArgumentOutOfRangeException time is negative.
    ArgumentException midiEvent is either system real-time or system common one.

    GetTimedEvents(EventsCollection, TimedEventDetectionSettings)

    Gets timed events contained in the specified EventsCollection. More info in the Getting objects: GetTimedEvents article.
    Declaration
    public static ICollection<TimedEvent> GetTimedEvents(this EventsCollection eventsCollection, TimedEventDetectionSettings settings = null)
    Parameters
    Type Name Description
    EventsCollection eventsCollection EventsCollection to search for events.
    TimedEventDetectionSettings settings Settings accoridng to which timed events should be detected and built.
    Returns
    Type Description
    ICollection<TimedEvent> Collection of timed events contained in eventsCollection ordered by time.
    Exceptions
    Type Condition
    ArgumentNullException eventsCollection is null.
    See Also
    ProcessTimedEvents(EventsCollection, Action<TimedEvent>, Predicate<TimedEvent>, TimedEventDetectionSettings)
    ProcessTimedEvents(EventsCollection, Action<TimedEvent>, TimedEventDetectionSettings)
    RemoveTimedEvents(EventsCollection)
    RemoveTimedEvents(EventsCollection, Predicate<TimedEvent>, TimedEventDetectionSettings)
    GetObjectsUtilities

    GetTimedEvents(MidiFile, TimedEventDetectionSettings)

    Gets timed events contained in the specified MidiFile. More info in the Getting objects: GetTimedEvents article.
    Declaration
    public static ICollection<TimedEvent> GetTimedEvents(this MidiFile file, TimedEventDetectionSettings settings = null)
    Parameters
    Type Name Description
    MidiFile file MidiFile to search for events.
    TimedEventDetectionSettings settings Settings accoridng to which timed events should be detected and built.
    Returns
    Type Description
    ICollection<TimedEvent> Collection of timed events contained in file ordered by time.
    Exceptions
    Type Condition
    ArgumentNullException file is null.
    See Also
    ProcessTimedEvents(MidiFile, Action<TimedEvent>, Predicate<TimedEvent>, TimedEventDetectionSettings)
    ProcessTimedEvents(MidiFile, Action<TimedEvent>, TimedEventDetectionSettings)
    RemoveTimedEvents(MidiFile)
    RemoveTimedEvents(MidiFile, Predicate<TimedEvent>, TimedEventDetectionSettings)
    GetObjectsUtilities

    GetTimedEvents(TrackChunk, TimedEventDetectionSettings)

    Gets timed events contained in the specified TrackChunk. More info in the Getting objects: GetTimedEvents article.
    Declaration
    public static ICollection<TimedEvent> GetTimedEvents(this TrackChunk trackChunk, TimedEventDetectionSettings settings = null)
    Parameters
    Type Name Description
    TrackChunk trackChunk TrackChunk to search for events.
    TimedEventDetectionSettings settings Settings accoridng to which timed events should be detected and built.
    Returns
    Type Description
    ICollection<TimedEvent> Collection of timed events contained in trackChunk ordered by time.
    Exceptions
    Type Condition
    ArgumentNullException trackChunk is null.
    See Also
    ProcessTimedEvents(TrackChunk, Action<TimedEvent>, Predicate<TimedEvent>, TimedEventDetectionSettings)
    ProcessTimedEvents(TrackChunk, Action<TimedEvent>, TimedEventDetectionSettings)
    RemoveTimedEvents(TrackChunk)
    RemoveTimedEvents(TrackChunk, Predicate<TimedEvent>, TimedEventDetectionSettings)
    GetObjectsUtilities

    GetTimedEvents(IEnumerable<TrackChunk>, TimedEventDetectionSettings)

    Gets timed events contained in the specified collection of TrackChunk. More info in the Getting objects: GetTimedEvents article.
    Declaration
    public static ICollection<TimedEvent> GetTimedEvents(this IEnumerable<TrackChunk> trackChunks, TimedEventDetectionSettings settings = null)
    Parameters
    Type Name Description
    IEnumerable<TrackChunk> trackChunks Track chunks to search for events.
    TimedEventDetectionSettings settings Settings accoridng to which timed events should be detected and built.
    Returns
    Type Description
    ICollection<TimedEvent> Collection of timed events contained in trackChunks ordered by time.
    Exceptions
    Type Condition
    ArgumentNullException trackChunks is null.
    See Also
    ProcessTimedEvents(IEnumerable<TrackChunk>, Action<TimedEvent>, Predicate<TimedEvent>, TimedEventDetectionSettings)
    ProcessTimedEvents(IEnumerable<TrackChunk>, Action<TimedEvent>, TimedEventDetectionSettings)
    RemoveTimedEvents(IEnumerable<TrackChunk>)
    RemoveTimedEvents(IEnumerable<TrackChunk>, Predicate<TimedEvent>, TimedEventDetectionSettings)
    GetObjectsUtilities

    ManageTimedEvents(EventsCollection, TimedEventDetectionSettings, TimedObjectsComparer)

    Creates an instance of the TimedObjectsManager<TObject> initializing it with the specified events collection. More info in the Objects managers article.
    Declaration
    public static TimedObjectsManager<TimedEvent> ManageTimedEvents(this EventsCollection eventsCollection, TimedEventDetectionSettings settings = null, TimedObjectsComparer comparer = null)
    Parameters
    Type Name Description
    EventsCollection eventsCollection EventsCollection that holds events to manage.
    TimedEventDetectionSettings settings Settings accoridng to which timed events should be detected and built.
    TimedObjectsComparer comparer Comparer that will be used to order objects on enumerating and saving objects back to the eventsCollection via SaveChanges() or Dispose().
    Returns
    Type Description
    TimedObjectsManager<TimedEvent> An instance of the TimedObjectsManager<TObject> that can be used to manage events represented by the eventsCollection.
    Exceptions
    Type Condition
    ArgumentNullException eventsCollection is null.

    ManageTimedEvents(TrackChunk, TimedEventDetectionSettings, TimedObjectsComparer)

    Creates an instance of the TimedObjectsManager<TObject> initializing it with the events collection of the specified track chunk. More info in the Objects managers article.
    Declaration
    public static TimedObjectsManager<TimedEvent> ManageTimedEvents(this TrackChunk trackChunk, TimedEventDetectionSettings settings = null, TimedObjectsComparer comparer = null)
    Parameters
    Type Name Description
    TrackChunk trackChunk TrackChunk that holds events to manage.
    TimedEventDetectionSettings settings Settings accoridng to which timed events should be detected and built.
    TimedObjectsComparer comparer Comparer that will be used to order objects on enumerating and saving objects back to the trackChunk via SaveChanges() or Dispose().
    Returns
    Type Description
    TimedObjectsManager<TimedEvent> An instance of the TimedObjectsManager<TObject> that can be used to manage events represented by the trackChunk.
    Exceptions
    Type Condition
    ArgumentNullException trackChunk is null.

    ProcessTimedEvents(EventsCollection, Action<TimedEvent>, TimedEventDetectionSettings)

    Performs the specified action on each TimedEvent contained in the EventsCollection.
    Declaration
    public static int ProcessTimedEvents(this EventsCollection eventsCollection, Action<TimedEvent> action, TimedEventDetectionSettings settings = null)
    Parameters
    Type Name Description
    EventsCollection eventsCollection EventsCollection to search for events to process.
    Action<TimedEvent> action The action to perform on each TimedEvent contained in the eventsCollection.
    TimedEventDetectionSettings settings Settings accoridng to which timed events should be detected and built.
    Returns
    Type Description
    Int32 Count of processed timed events.
    Exceptions
    Type Condition
    ArgumentNullException

    One of the following errors occured:

    • eventsCollection is null.
    • action is null.

    ProcessTimedEvents(EventsCollection, Action<TimedEvent>, Predicate<TimedEvent>, TimedEventDetectionSettings)

    Performs the specified action on each TimedEvent contained in the EventsCollection.
    Declaration
    public static int ProcessTimedEvents(this EventsCollection eventsCollection, Action<TimedEvent> action, Predicate<TimedEvent> match, TimedEventDetectionSettings settings = null)
    Parameters
    Type Name Description
    EventsCollection eventsCollection EventsCollection to search for events to process.
    Action<TimedEvent> action The action to perform on each TimedEvent contained in the eventsCollection.
    Predicate<TimedEvent> match The predicate that defines the conditions of the TimedEvent to process.
    TimedEventDetectionSettings settings Settings accoridng to which timed events should be detected and built.
    Returns
    Type Description
    Int32 Count of processed timed events.
    Exceptions
    Type Condition
    ArgumentNullException

    One of the following errors occured:

    • eventsCollection is null.
    • action is null.
    • match is null.

    ProcessTimedEvents(MidiFile, Action<TimedEvent>, TimedEventDetectionSettings)

    Performs the specified action on each TimedEvent contained in the MidiFile.
    Declaration
    public static int ProcessTimedEvents(this MidiFile file, Action<TimedEvent> action, TimedEventDetectionSettings settings = null)
    Parameters
    Type Name Description
    MidiFile file MidiFile to search for events to process.
    Action<TimedEvent> action The action to perform on each TimedEvent contained in the file.
    TimedEventDetectionSettings settings Settings accoridng to which timed events should be detected and built.
    Returns
    Type Description
    Int32 Count of processed timed events.
    Exceptions
    Type Condition
    ArgumentNullException

    One of the following errors occured:

    • file is null.
    • action is null.

    ProcessTimedEvents(MidiFile, Action<TimedEvent>, Predicate<TimedEvent>, TimedEventDetectionSettings)

    Performs the specified action on each TimedEvent contained in the MidiFile.
    Declaration
    public static int ProcessTimedEvents(this MidiFile file, Action<TimedEvent> action, Predicate<TimedEvent> match, TimedEventDetectionSettings settings = null)
    Parameters
    Type Name Description
    MidiFile file MidiFile to search for events to process.
    Action<TimedEvent> action The action to perform on each TimedEvent contained in the file.
    Predicate<TimedEvent> match The predicate that defines the conditions of the TimedEvent to process.
    TimedEventDetectionSettings settings Settings accoridng to which timed events should be detected and built.
    Returns
    Type Description
    Int32 Count of processed timed events.
    Exceptions
    Type Condition
    ArgumentNullException

    One of the following errors occured:

    • file is null.
    • action is null.
    • match is null.

    ProcessTimedEvents(TrackChunk, Action<TimedEvent>, TimedEventDetectionSettings)

    Performs the specified action on each TimedEvent contained in the TrackChunk.
    Declaration
    public static int ProcessTimedEvents(this TrackChunk trackChunk, Action<TimedEvent> action, TimedEventDetectionSettings settings = null)
    Parameters
    Type Name Description
    TrackChunk trackChunk TrackChunk to search for events to process.
    Action<TimedEvent> action The action to perform on each TimedEvent contained in the trackChunk.
    TimedEventDetectionSettings settings Settings accoridng to which timed events should be detected and built.
    Returns
    Type Description
    Int32 Count of processed timed events.
    Exceptions
    Type Condition
    ArgumentNullException

    One of the following errors occured:

    • trackChunk is null.
    • action is null.

    ProcessTimedEvents(TrackChunk, Action<TimedEvent>, Predicate<TimedEvent>, TimedEventDetectionSettings)

    Performs the specified action on each TimedEvent contained in the TrackChunk.
    Declaration
    public static int ProcessTimedEvents(this TrackChunk trackChunk, Action<TimedEvent> action, Predicate<TimedEvent> match, TimedEventDetectionSettings settings = null)
    Parameters
    Type Name Description
    TrackChunk trackChunk TrackChunk to search for events to process.
    Action<TimedEvent> action The action to perform on each TimedEvent contained in the trackChunk.
    Predicate<TimedEvent> match The predicate that defines the conditions of the TimedEvent to process.
    TimedEventDetectionSettings settings Settings accoridng to which timed events should be detected and built.
    Returns
    Type Description
    Int32 Count of processed timed events.
    Exceptions
    Type Condition
    ArgumentNullException

    One of the following errors occured:

    • trackChunk is null.
    • action is null.
    • match is null.

    ProcessTimedEvents(IEnumerable<TrackChunk>, Action<TimedEvent>, TimedEventDetectionSettings)

    Performs the specified action on each TimedEvent contained in the collection of TrackChunk.
    Declaration
    public static int ProcessTimedEvents(this IEnumerable<TrackChunk> trackChunks, Action<TimedEvent> action, TimedEventDetectionSettings settings = null)
    Parameters
    Type Name Description
    IEnumerable<TrackChunk> trackChunks Collection of TrackChunk to search for events to process.
    Action<TimedEvent> action The action to perform on each TimedEvent contained in the trackChunks.
    TimedEventDetectionSettings settings Settings accoridng to which timed events should be detected and built.
    Returns
    Type Description
    Int32 Count of processed timed events.
    Exceptions
    Type Condition
    ArgumentNullException

    One of the following errors occured:

    • trackChunks is null.
    • action is null.

    ProcessTimedEvents(IEnumerable<TrackChunk>, Action<TimedEvent>, Predicate<TimedEvent>, TimedEventDetectionSettings)

    Performs the specified action on each TimedEvent contained in the collection of TrackChunk.
    Declaration
    public static int ProcessTimedEvents(this IEnumerable<TrackChunk> trackChunks, Action<TimedEvent> action, Predicate<TimedEvent> match, TimedEventDetectionSettings settings = null)
    Parameters
    Type Name Description
    IEnumerable<TrackChunk> trackChunks Collection of TrackChunk to search for events to process.
    Action<TimedEvent> action The action to perform on each TimedEvent contained in the trackChunks.
    Predicate<TimedEvent> match The predicate that defines the conditions of the TimedEvent to process.
    TimedEventDetectionSettings settings Settings accoridng to which timed events should be detected and built.
    Returns
    Type Description
    Int32 Count of processed timed events.
    Exceptions
    Type Condition
    ArgumentNullException

    One of the following errors occured:

    • trackChunks is null.
    • action is null.
    • match is null.

    RemoveTimedEvents(EventsCollection)

    Removes all the TimedEvent that match the conditions defined by the specified predicate.
    Declaration
    public static int RemoveTimedEvents(this EventsCollection eventsCollection)
    Parameters
    Type Name Description
    EventsCollection eventsCollection EventsCollection to search for events to remove.
    Returns
    Type Description
    Int32 Count of removed timed events.
    Exceptions
    Type Condition
    ArgumentNullException eventsCollection is null.

    RemoveTimedEvents(EventsCollection, Predicate<TimedEvent>, TimedEventDetectionSettings)

    Removes all the TimedEvent that match the conditions defined by the specified predicate.
    Declaration
    public static int RemoveTimedEvents(this EventsCollection eventsCollection, Predicate<TimedEvent> match, TimedEventDetectionSettings settings = null)
    Parameters
    Type Name Description
    EventsCollection eventsCollection EventsCollection to search for events to remove.
    Predicate<TimedEvent> match The predicate that defines the conditions of the TimedEvent to remove.
    TimedEventDetectionSettings settings Settings accoridng to which timed events should be detected and built.
    Returns
    Type Description
    Int32 Count of removed timed events.
    Exceptions
    Type Condition
    ArgumentNullException

    One of the following errors occured:

    • eventsCollection is null.
    • match is null.

    RemoveTimedEvents(MidiFile)

    Removes all the TimedEvent that match the conditions defined by the specified predicate.
    Declaration
    public static int RemoveTimedEvents(this MidiFile file)
    Parameters
    Type Name Description
    MidiFile file MidiFile to search for events to remove.
    Returns
    Type Description
    Int32 Count of removed timed events.
    Exceptions
    Type Condition
    ArgumentNullException file is null.

    RemoveTimedEvents(MidiFile, Predicate<TimedEvent>, TimedEventDetectionSettings)

    Removes all the TimedEvent that match the conditions defined by the specified predicate.
    Declaration
    public static int RemoveTimedEvents(this MidiFile file, Predicate<TimedEvent> match, TimedEventDetectionSettings settings = null)
    Parameters
    Type Name Description
    MidiFile file MidiFile to search for events to remove.
    Predicate<TimedEvent> match The predicate that defines the conditions of the TimedEvent to remove.
    TimedEventDetectionSettings settings Settings accoridng to which timed events should be detected and built.
    Returns
    Type Description
    Int32 Count of removed timed events.
    Exceptions
    Type Condition
    ArgumentNullException

    One of the following errors occured:

    • file is null.
    • match is null.

    RemoveTimedEvents(TrackChunk)

    Removes all the TimedEvent that match the conditions defined by the specified predicate.
    Declaration
    public static int RemoveTimedEvents(this TrackChunk trackChunk)
    Parameters
    Type Name Description
    TrackChunk trackChunk TrackChunk to search for events to remove.
    Returns
    Type Description
    Int32 Count of removed timed events.
    Exceptions
    Type Condition
    ArgumentNullException trackChunk is null.

    RemoveTimedEvents(TrackChunk, Predicate<TimedEvent>, TimedEventDetectionSettings)

    Removes all the TimedEvent that match the conditions defined by the specified predicate.
    Declaration
    public static int RemoveTimedEvents(this TrackChunk trackChunk, Predicate<TimedEvent> match, TimedEventDetectionSettings settings = null)
    Parameters
    Type Name Description
    TrackChunk trackChunk TrackChunk to search for events to remove.
    Predicate<TimedEvent> match The predicate that defines the conditions of the TimedEvent to remove.
    TimedEventDetectionSettings settings Settings accoridng to which timed events should be detected and built.
    Returns
    Type Description
    Int32 Count of removed timed events.
    Exceptions
    Type Condition
    ArgumentNullException

    One of the following errors occured:

    • trackChunk is null.
    • match is null.

    RemoveTimedEvents(IEnumerable<TrackChunk>)

    Removes all the TimedEvent that match the conditions defined by the specified predicate.
    Declaration
    public static int RemoveTimedEvents(this IEnumerable<TrackChunk> trackChunks)
    Parameters
    Type Name Description
    IEnumerable<TrackChunk> trackChunks Collection of TrackChunk to search for events to remove.
    Returns
    Type Description
    Int32 Count of removed timed events.
    Exceptions
    Type Condition
    ArgumentNullException trackChunks is null.

    RemoveTimedEvents(IEnumerable<TrackChunk>, Predicate<TimedEvent>, TimedEventDetectionSettings)

    Removes all the TimedEvent that match the conditions defined by the specified predicate.
    Declaration
    public static int RemoveTimedEvents(this IEnumerable<TrackChunk> trackChunks, Predicate<TimedEvent> match, TimedEventDetectionSettings settings = null)
    Parameters
    Type Name Description
    IEnumerable<TrackChunk> trackChunks Collection of TrackChunk to search for events to remove.
    Predicate<TimedEvent> match The predicate that defines the conditions of the TimedEvent to remove.
    TimedEventDetectionSettings settings Settings accoridng to which timed events should be detected and built.
    Returns
    Type Description
    Int32 Count of removed timed events.
    Exceptions
    Type Condition
    ArgumentNullException

    One of the following errors occured:

    • trackChunks is null.
    • match is null.

    SetTime(TimedEvent, ITimeSpan, TempoMap)

    Sets time of the specified timed event.
    Declaration
    [Obsolete("OBS14: Use SetTime method from TimedObjectUtilities. More info: https://melanchall.github.io/drywetmidi/obsolete/obsolete.html#obs14.")]
    public static TimedEvent SetTime(this TimedEvent timedEvent, ITimeSpan time, TempoMap tempoMap)
    Parameters
    Type Name Description
    TimedEvent timedEvent Timed event to set time to.
    ITimeSpan time Time to set to timedEvent.
    TempoMap tempoMap Tempo map that will be used for time conversion.
    Returns
    Type Description
    TimedEvent An input timedEvent with new time.
    Exceptions
    Type Condition
    ArgumentNullException

    One of the following errors occured:

    • timedEvent is null.
    • time is null.
    • tempoMap is null.
    In This Article
    Back to top 2022 / Generated by DocFX