Search Results for

    Show / Hide Table of Contents

    Objects splitting

    With DryWetMIDI you can use methods of the Splitter class to split objects:

    • SplitObjectsByStep
    • SplitObjectsByPartsNumber
    • SplitObjectsByGrid
    • SplitObjectsAtDistance

    Each method takes a collection of timed objects or MIDI containers (like file or track chunk) and splits objects within by the specified strategy. These methods are discussed in detail below.

    Also please note that every class that implements ILengthedObject has Split method allowing to split an object at the specified time.

    SplitObjectsByStep

    SplitObjectsByStep methods split each object by the specified step starting at the start of an object. For example, if step is 1 second, an object will be split at 1 second from its start, at 1 second from previous point of splitting (2 seconds from the object's start), at 1 second from previous point of splitting (3 seconds from the object's start) and so on. If an object's length is less than the specified step, the object will not be split and a copy of it will be returned.

    The image below illustrates splitting notes and chord by the same step:

    Split by step

    SplitObjectsByPartsNumber

    SplitObjectsByPartsNumber methods split each object into the specified number of parts of equal length. It is necessary to specify the lengthType argument to meet your expectations. For example, with metric type each part of an input object will last the same number of microseconds, while with musical type each part's length will represent the same fraction of the whole note's length. But the length of parts can be different in terms of MIDI ticks using different length types depending on the tempo map passed to the method.

    The image below illustrates splitting notes and chord into 4 parts:

    Split by parts number

    SplitObjectsByGrid

    SplitObjectsByGrid methods split each object by the specified grid. Objects will be split at points of crossing the grid.

    The image below illustrates splitting notes and chord by the same grid:

    Split by grid

    SplitObjectsAtDistance

    SplitObjectsAtDistance methods split each object at the specified distance or by the specified ratio from start or end of an object (which is defined by from parameter). It is necessary to specify the lengthType argument for splitting by ratio to meet your expectations.

    The image below illustrates splitting notes and chord at the same distance from the start of an object:

    Split at distance by step from start

    Next image illustrates splitting notes and chord by the ratio of 0.25 from the end of an object:

    Split at distance by ratio from end

    In this article
    Back to top 2024 / Generated by DocFX