Class Splitter
Provides methods to split MIDI data in many different ways. More info in the
Splitter article.
Assembly: Melanchall.DryWetMidi.dll
public static class Splitter
Methods
Cuts a part of the specified length from a MIDI file (starting at the specified time within the file)
and returns a new instance of
MidiFile which is the original one without the part. More info
in the
MIDI file splitting: CutPart article.
Declaration
public static MidiFile CutPart(this MidiFile midiFile, ITimeSpan partStart, ITimeSpan partLength, SliceMidiFileSettings settings = null)
Parameters
Returns
Type |
Description |
MidiFile |
MidiFile which is the midiFile without a part defined by
partStart and partLength . |
Exceptions
Type |
Condition |
ArgumentNullException |
One of the following errors occurred:
-
midiFile is null . -
partStart is null . -
partLength is null .
|
Declaration
public static MidiFile SkipPart(this MidiFile midiFile, ITimeSpan partLength, SliceMidiFileSettings settings = null)
Parameters
Returns
Type |
Description |
MidiFile |
MidiFile which is result of skipping a part of the midiFile . |
Exceptions
Type |
Condition |
ArgumentNullException |
One of the following errors occurred:
-
midiFile is null . -
partLength is null .
|
Declaration
public static IEnumerable<MidiFile> SplitByChannel(this MidiFile midiFile, SplitFileByChannelSettings settings = null)
Parameters
Returns
Type |
Description |
IEnumerable<MidiFile> |
Collection of MidiFile where each file contains events for single channel
and meta and sysex ones as defined by settings . |
Exceptions
Declaration
public static IEnumerable<MidiFile> SplitByChunks(this MidiFile midiFile, SplitFileByChunksSettings settings = null)
Parameters
Returns
Exceptions
Declaration
public static IEnumerable<MidiFile> SplitByGrid(this MidiFile midiFile, IGrid grid, SliceMidiFileSettings settings = null)
Parameters
Returns
Exceptions
Type |
Condition |
ArgumentNullException |
One of the following errors occurred:
-
midiFile is null . -
grid is null .
|
Declaration
public static IEnumerable<MidiFile> SplitByObjects(this MidiFile midiFile, ObjectType objectType, SplitByObjectsSettings settings = null, ObjectDetectionSettings objectDetectionSettings = null)
Parameters
Returns
Exceptions
Declaration
public static void SplitObjectsAtDistance(this MidiFile midiFile, ObjectType objectType, ITimeSpan distance, LengthedObjectTarget from, ObjectDetectionSettings objectDetectionSettings = null, Predicate<ITimedObject> filter = null)
Parameters
Type |
Name |
Description |
MidiFile |
midiFile |
MidiFile to split objects within. |
ObjectType |
objectType |
The type of objects to split. |
ITimeSpan |
distance |
Distance to split objects at. |
LengthedObjectTarget |
from |
Point of an object distance should be measured from. |
ObjectDetectionSettings |
objectDetectionSettings |
Settings according to which objects should be
detected and built. |
Predicate<ITimedObject> |
filter |
Predicate used to determine whether an object should be split or not.
true as a return value of the predicate means an object should be split; false
means don't split it. null (the default value) can be passed to the parameter
to process all objects. |
Exceptions
Splits objects within a
MidiFile by the specified ratio of an object's length measuring
it from the object's start or end. For example, 0.5 means splitting at the center of an object. More info
in the
Objects splitting: SplitObjectsAtDistance
article.
Declaration
public static void SplitObjectsAtDistance(this MidiFile midiFile, ObjectType objectType, double ratio, TimeSpanType lengthType, LengthedObjectTarget from, ObjectDetectionSettings objectDetectionSettings = null, Predicate<ITimedObject> filter = null)
Parameters
Type |
Name |
Description |
MidiFile |
midiFile |
MidiFile to split objects within. |
ObjectType |
objectType |
The type of objects to split. |
double |
ratio |
Ratio of an object's length to split by. Valid values are from 0 to 1. |
TimeSpanType |
lengthType |
The type an object's length should be processed according to. |
LengthedObjectTarget |
from |
Point of an object distance should be measured from. |
ObjectDetectionSettings |
objectDetectionSettings |
Settings according to which objects should be
detected and built. |
Predicate<ITimedObject> |
filter |
Predicate used to determine whether an object should be split or not.
true as a return value of the predicate means an object should be split; false
means don't split it. null (the default value) can be passed to the parameter
to process all objects. |
Exceptions
Declaration
public static void SplitObjectsAtDistance(this TrackChunk trackChunk, ObjectType objectType, ITimeSpan distance, LengthedObjectTarget from, TempoMap tempoMap, ObjectDetectionSettings objectDetectionSettings = null, Predicate<ITimedObject> filter = null)
Parameters
Type |
Name |
Description |
TrackChunk |
trackChunk |
TrackChunk to split objects within. |
ObjectType |
objectType |
The type of objects to split. |
ITimeSpan |
distance |
Distance to split objects at. |
LengthedObjectTarget |
from |
Point of an object distance should be measured from. |
TempoMap |
tempoMap |
Tempo map used for distances calculations. |
ObjectDetectionSettings |
objectDetectionSettings |
Settings according to which objects should be
detected and built. |
Predicate<ITimedObject> |
filter |
Predicate used to determine whether an object should be split or not.
true as a return value of the predicate means an object should be split; false
means don't split it. null (the default value) can be passed to the parameter
to process all objects. |
Exceptions
Declaration
public static void SplitObjectsAtDistance(this TrackChunk trackChunk, ObjectType objectType, double ratio, TimeSpanType lengthType, LengthedObjectTarget from, TempoMap tempoMap, ObjectDetectionSettings objectDetectionSettings = null, Predicate<ITimedObject> filter = null)
Parameters
Type |
Name |
Description |
TrackChunk |
trackChunk |
TrackChunk to split objects within. |
ObjectType |
objectType |
The type of objects to split. |
double |
ratio |
Ratio of an object's length to split by. Valid values are from 0 to 1. |
TimeSpanType |
lengthType |
The type an object's length should be processed according to. |
LengthedObjectTarget |
from |
Point of an object distance should be measured from. |
TempoMap |
tempoMap |
Tempo map used for distances calculations. |
ObjectDetectionSettings |
objectDetectionSettings |
Settings according to which objects should be
detected and built. |
Predicate<ITimedObject> |
filter |
Predicate used to determine whether an object should be split or not.
true as a return value of the predicate means an object should be split; false
means don't split it. null (the default value) can be passed to the parameter
to process all objects. |
Exceptions
Declaration
public static void SplitObjectsAtDistance(this IEnumerable<TrackChunk> trackChunks, ObjectType objectType, ITimeSpan distance, LengthedObjectTarget from, TempoMap tempoMap, ObjectDetectionSettings objectDetectionSettings = null, Predicate<ITimedObject> filter = null)
Parameters
Type |
Name |
Description |
IEnumerable<TrackChunk> |
trackChunks |
A collection of TrackChunk to split objects within. |
ObjectType |
objectType |
The type of objects to split. |
ITimeSpan |
distance |
Distance to split objects at. |
LengthedObjectTarget |
from |
Point of an object distance should be measured from. |
TempoMap |
tempoMap |
Tempo map used for distances calculations. |
ObjectDetectionSettings |
objectDetectionSettings |
Settings according to which objects should be
detected and built. |
Predicate<ITimedObject> |
filter |
Predicate used to determine whether an object should be split or not.
true as a return value of the predicate means an object should be split; false
means don't split it. null (the default value) can be passed to the parameter
to process all objects. |
Exceptions
Splits objects within a collection of
TrackChunk by the specified ratio of an object's
length measuring it from the object's start or end. For example, 0.5 means splitting at the center of an object.
More info in the
Objects splitting: SplitObjectsAtDistance
article.
Declaration
public static void SplitObjectsAtDistance(this IEnumerable<TrackChunk> trackChunks, ObjectType objectType, double ratio, TimeSpanType lengthType, LengthedObjectTarget from, TempoMap tempoMap, ObjectDetectionSettings objectDetectionSettings = null, Predicate<ITimedObject> filter = null)
Parameters
Type |
Name |
Description |
IEnumerable<TrackChunk> |
trackChunks |
A collection of TrackChunk to split objects within. |
ObjectType |
objectType |
The type of objects to split. |
double |
ratio |
Ratio of an object's length to split by. Valid values are from 0 to 1. |
TimeSpanType |
lengthType |
The type an object's length should be processed according to. |
LengthedObjectTarget |
from |
Point of an object distance should be measured from. |
TempoMap |
tempoMap |
Tempo map used for distances calculations. |
ObjectDetectionSettings |
objectDetectionSettings |
Settings according to which objects should be
detected and built. |
Predicate<ITimedObject> |
filter |
Predicate used to determine whether an object should be split or not.
true as a return value of the predicate means an object should be split; false
means don't split it. null (the default value) can be passed to the parameter
to process all objects. |
Exceptions
Declaration
public static IEnumerable<ITimedObject> SplitObjectsAtDistance(this IEnumerable<ITimedObject> objects, ITimeSpan distance, LengthedObjectTarget from, TempoMap tempoMap, Predicate<ITimedObject> filter = null)
Parameters
Type |
Name |
Description |
IEnumerable<ITimedObject> |
objects |
Objects to split. |
ITimeSpan |
distance |
Distance to split objects at. |
LengthedObjectTarget |
from |
Point of an object distance should be measured from. |
TempoMap |
tempoMap |
Tempo map used for distances calculations. |
Predicate<ITimedObject> |
filter |
Predicate used to determine whether an object should be split or not.
true as a return value of the predicate means an object should be split; false
means don't split it. null (the default value) can be passed to the parameter
to process all objects. |
Returns
Type |
Description |
IEnumerable<ITimedObject> |
Objects that are result of splitting objects going in the same
order as elements of objects . |
Exceptions
Splits objects by the specified ratio of an object's length measuring it from
the object's start or end. For example, 0.5 means splitting at the center of an object. More info in the
Objects splitting: SplitObjectsAtDistance
article.
Declaration
public static IEnumerable<ITimedObject> SplitObjectsAtDistance(this IEnumerable<ITimedObject> objects, double ratio, TimeSpanType lengthType, LengthedObjectTarget from, TempoMap tempoMap, Predicate<ITimedObject> filter = null)
Parameters
Type |
Name |
Description |
IEnumerable<ITimedObject> |
objects |
Objects to split. |
double |
ratio |
Ratio of an object's length to split by. Valid values are from 0 to 1. |
TimeSpanType |
lengthType |
The type an object's length should be processed according to. |
LengthedObjectTarget |
from |
Point of an object distance should be measured from. |
TempoMap |
tempoMap |
Tempo map used for distances calculations. |
Predicate<ITimedObject> |
filter |
Predicate used to determine whether an object should be split or not.
true as a return value of the predicate means an object should be split; false
means don't split it. null (the default value) can be passed to the parameter
to process all objects. |
Returns
Type |
Description |
IEnumerable<ITimedObject> |
Objects that are result of splitting objects going in the same
order as elements of objects . |
Exceptions
Declaration
public static void SplitObjectsByGrid(this MidiFile midiFile, ObjectType objectType, IGrid grid, ObjectDetectionSettings objectDetectionSettings = null, Predicate<ITimedObject> filter = null)
Parameters
Type |
Name |
Description |
MidiFile |
midiFile |
MidiFile to split objects within. |
ObjectType |
objectType |
The type of objects to split. |
IGrid |
grid |
Grid to split objects by. |
ObjectDetectionSettings |
objectDetectionSettings |
Settings according to which objects should be
detected and built. |
Predicate<ITimedObject> |
filter |
Predicate used to determine whether an object should be split or not.
true as a return value of the predicate means an object should be split; false
means don't split it. null (the default value) can be passed to the parameter
to process all objects. |
Exceptions
Type |
Condition |
ArgumentNullException |
One of the following errors occurred:
-
midiFile is null . -
grid is null .
|
Declaration
public static void SplitObjectsByGrid(this TrackChunk trackChunk, ObjectType objectType, IGrid grid, TempoMap tempoMap, ObjectDetectionSettings objectDetectionSettings = null, Predicate<ITimedObject> filter = null)
Parameters
Type |
Name |
Description |
TrackChunk |
trackChunk |
TrackChunk to split objects within. |
ObjectType |
objectType |
The type of objects to split. |
IGrid |
grid |
Grid to split objects by. |
TempoMap |
tempoMap |
Tempo map used to calculate times to split by. |
ObjectDetectionSettings |
objectDetectionSettings |
Settings according to which objects should be
detected and built. |
Predicate<ITimedObject> |
filter |
Predicate used to determine whether an object should be split or not.
true as a return value of the predicate means an object should be split; false
means don't split it. null (the default value) can be passed to the parameter
to process all objects. |
Exceptions
Type |
Condition |
ArgumentNullException |
One of the following errors occurred:
-
trackChunk is null . -
grid is null . -
tempoMap is null .
|
Declaration
public static void SplitObjectsByGrid(this IEnumerable<TrackChunk> trackChunks, ObjectType objectType, IGrid grid, TempoMap tempoMap, ObjectDetectionSettings objectDetectionSettings = null, Predicate<ITimedObject> filter = null)
Parameters
Type |
Name |
Description |
IEnumerable<TrackChunk> |
trackChunks |
A collection of TrackChunk to split objects within. |
ObjectType |
objectType |
The type of objects to split. |
IGrid |
grid |
Grid to split objects by. |
TempoMap |
tempoMap |
Tempo map used to calculate times to split by. |
ObjectDetectionSettings |
objectDetectionSettings |
Settings according to which objects should be
detected and built. |
Predicate<ITimedObject> |
filter |
Predicate used to determine whether an object should be split or not.
true as a return value of the predicate means an object should be split; false
means don't split it. null (the default value) can be passed to the parameter
to process all objects. |
Exceptions
Type |
Condition |
ArgumentNullException |
One of the following errors occurred:
-
trackChunks is null . -
grid is null . -
tempoMap is null .
|
Declaration
public static IEnumerable<ITimedObject> SplitObjectsByGrid(this IEnumerable<ITimedObject> objects, IGrid grid, TempoMap tempoMap, Predicate<ITimedObject> filter = null)
Parameters
Type |
Name |
Description |
IEnumerable<ITimedObject> |
objects |
Objects to split. |
IGrid |
grid |
Grid to split objects by. |
TempoMap |
tempoMap |
Tempo map used to calculate times to split by. |
Predicate<ITimedObject> |
filter |
Predicate used to determine whether an object should be split or not.
true as a return value of the predicate means an object should be split; false
means don't split it. null (the default value) can be passed to the parameter
to process all objects. |
Returns
Type |
Description |
IEnumerable<ITimedObject> |
Objects that are result of splitting objects going in the same
order as elements of objects . |
Exceptions
Type |
Condition |
ArgumentNullException |
One of the following errors occurred:
-
objects is null . -
grid is null . -
tempoMap is null .
|
Declaration
public static void SplitObjectsByPartsNumber(this MidiFile midiFile, ObjectType objectType, int partsNumber, TimeSpanType lengthType, ObjectDetectionSettings objectDetectionSettings = null, Predicate<ITimedObject> filter = null)
Parameters
Type |
Name |
Description |
MidiFile |
midiFile |
MidiFile to split objects within. |
ObjectType |
objectType |
The type of objects to split. |
int |
partsNumber |
The number of parts to split objects into. |
TimeSpanType |
lengthType |
Type of a part's length. |
ObjectDetectionSettings |
objectDetectionSettings |
Settings according to which objects should be
detected and built. |
Predicate<ITimedObject> |
filter |
Predicate used to determine whether an object should be split or not.
true as a return value of the predicate means an object should be split; false
means don't split it. null (the default value) can be passed to the parameter
to process all objects. |
Exceptions
Declaration
public static void SplitObjectsByPartsNumber(this TrackChunk trackChunk, ObjectType objectType, int partsNumber, TimeSpanType lengthType, TempoMap tempoMap, ObjectDetectionSettings objectDetectionSettings = null, Predicate<ITimedObject> filter = null)
Parameters
Type |
Name |
Description |
TrackChunk |
trackChunk |
TrackChunk to split objects within. |
ObjectType |
objectType |
The type of objects to split. |
int |
partsNumber |
The number of parts to split objects into. |
TimeSpanType |
lengthType |
Type of a part's length. |
TempoMap |
tempoMap |
Tempo map used to calculate times to split by. |
ObjectDetectionSettings |
objectDetectionSettings |
Settings according to which objects should be
detected and built. |
Predicate<ITimedObject> |
filter |
Predicate used to determine whether an object should be split or not.
true as a return value of the predicate means an object should be split; false
means don't split it. null (the default value) can be passed to the parameter
to process all objects. |
Exceptions
Declaration
public static void SplitObjectsByPartsNumber(this IEnumerable<TrackChunk> trackChunks, ObjectType objectType, int partsNumber, TimeSpanType lengthType, TempoMap tempoMap, ObjectDetectionSettings objectDetectionSettings = null, Predicate<ITimedObject> filter = null)
Parameters
Type |
Name |
Description |
IEnumerable<TrackChunk> |
trackChunks |
A collection of TrackChunk to split objects within. |
ObjectType |
objectType |
The type of objects to split. |
int |
partsNumber |
The number of parts to split objects into. |
TimeSpanType |
lengthType |
Type of a part's length. |
TempoMap |
tempoMap |
Tempo map used to calculate times to split by. |
ObjectDetectionSettings |
objectDetectionSettings |
Settings according to which objects should be
detected and built. |
Predicate<ITimedObject> |
filter |
Predicate used to determine whether an object should be split or not.
true as a return value of the predicate means an object should be split; false
means don't split it. null (the default value) can be passed to the parameter
to process all objects. |
Exceptions
Declaration
public static IEnumerable<ITimedObject> SplitObjectsByPartsNumber(this IEnumerable<ITimedObject> objects, int partsNumber, TimeSpanType lengthType, TempoMap tempoMap, Predicate<ITimedObject> filter = null)
Parameters
Type |
Name |
Description |
IEnumerable<ITimedObject> |
objects |
Objects to split. |
int |
partsNumber |
The number of parts to split objects into. |
TimeSpanType |
lengthType |
Type of a part's length. |
TempoMap |
tempoMap |
Tempo map used to calculate times to split by. |
Predicate<ITimedObject> |
filter |
Predicate used to determine whether an object should be split or not.
true as a return value of the predicate means an object should be split; false
means don't split it. null (the default value) can be passed to the parameter
to process all objects. |
Returns
Type |
Description |
IEnumerable<ITimedObject> |
Objects that are result of splitting objects going in the same
order as elements of objects . |
Exceptions
Splits objects within a
MidiFile by the specified step so every object will be split
at points equally distanced from each other starting from the object's start time. More info in the
Objects splitting: SplitObjectsByStep article.
Declaration
public static void SplitObjectsByStep(this MidiFile midiFile, ObjectType objectType, ITimeSpan step, ObjectDetectionSettings objectDetectionSettings = null, Predicate<ITimedObject> filter = null)
Parameters
Type |
Name |
Description |
MidiFile |
midiFile |
MidiFile to split objects within. |
ObjectType |
objectType |
The type of objects to split. |
ITimeSpan |
step |
Step to split objects by. |
ObjectDetectionSettings |
objectDetectionSettings |
Settings according to which objects should be
detected and built. |
Predicate<ITimedObject> |
filter |
Predicate used to determine whether an object should be split or not.
true as a return value of the predicate means an object should be split; false
means don't split it. null (the default value) can be passed to the parameter
to process all objects. |
Exceptions
Type |
Condition |
ArgumentNullException |
One of the following errors occurred:
-
midiFile is null . -
step is null .
|
Declaration
public static void SplitObjectsByStep(this TrackChunk trackChunk, ObjectType objectType, ITimeSpan step, TempoMap tempoMap, ObjectDetectionSettings objectDetectionSettings = null, Predicate<ITimedObject> filter = null)
Parameters
Type |
Name |
Description |
TrackChunk |
trackChunk |
TrackChunk to split objects within. |
ObjectType |
objectType |
The type of objects to split. |
ITimeSpan |
step |
Step to split objects by. |
TempoMap |
tempoMap |
Tempo map used to calculate times to split by. |
ObjectDetectionSettings |
objectDetectionSettings |
Settings according to which objects should be
detected and built. |
Predicate<ITimedObject> |
filter |
Predicate used to determine whether an object should be split or not.
true as a return value of the predicate means an object should be split; false
means don't split it. null (the default value) can be passed to the parameter
to process all objects. |
Exceptions
Type |
Condition |
ArgumentNullException |
One of the following errors occurred:
-
trackChunk is null . -
step is null . -
tempoMap is null .
|
Splits objects within a collection of
TrackChunk by the specified step so every object
will be split at points equally distanced from each other starting from the object's start time. More info
in the
Objects splitting: SplitObjectsByStep article.
Declaration
public static void SplitObjectsByStep(this IEnumerable<TrackChunk> trackChunks, ObjectType objectType, ITimeSpan step, TempoMap tempoMap, ObjectDetectionSettings objectDetectionSettings = null, Predicate<ITimedObject> filter = null)
Parameters
Type |
Name |
Description |
IEnumerable<TrackChunk> |
trackChunks |
A collection of TrackChunk to split objects within. |
ObjectType |
objectType |
The type of objects to split. |
ITimeSpan |
step |
Step to split objects by. |
TempoMap |
tempoMap |
Tempo map used to calculate times to split by. |
ObjectDetectionSettings |
objectDetectionSettings |
Settings according to which objects should be
detected and built. |
Predicate<ITimedObject> |
filter |
Predicate used to determine whether an object should be split or not.
true as a return value of the predicate means an object should be split; false
means don't split it. null (the default value) can be passed to the parameter
to process all objects. |
Exceptions
Type |
Condition |
ArgumentNullException |
One of the following errors occurred:
-
trackChunks is null . -
step is null . -
tempoMap is null .
|
Splits objects by the specified step so every object will be split at points
equally distanced from each other starting from the object's start time. More info in the
Objects splitting: SplitObjectsByStep article.
Declaration
public static IEnumerable<ITimedObject> SplitObjectsByStep(this IEnumerable<ITimedObject> objects, ITimeSpan step, TempoMap tempoMap, Predicate<ITimedObject> filter = null)
Parameters
Type |
Name |
Description |
IEnumerable<ITimedObject> |
objects |
Objects to split. |
ITimeSpan |
step |
Step to split objects by. |
TempoMap |
tempoMap |
Tempo map used to calculate times to split by. |
Predicate<ITimedObject> |
filter |
Predicate used to determine whether an object should be split or not.
true as a return value of the predicate means an object should be split; false
means don't split it. null (the default value) can be passed to the parameter
to process all objects. |
Returns
Type |
Description |
IEnumerable<ITimedObject> |
Objects that are result of splitting objects going in the same
order as elements of objects . |
Exceptions
Type |
Condition |
ArgumentNullException |
One of the following errors occurred:
-
objects is null . -
step is null . -
tempoMap is null .
|
Takes a part of the specified length of a MIDI file (starting at the specified time within the file)
and returns it as an instance of
MidiFile. More info in the
MIDI file splitting: TakePart article.
Declaration
public static MidiFile TakePart(this MidiFile midiFile, ITimeSpan partStart, ITimeSpan partLength, SliceMidiFileSettings settings = null)
Parameters
Returns
Exceptions
Type |
Condition |
ArgumentNullException |
One of the following errors occurred:
-
midiFile is null . -
partStart is null . -
partLength is null .
|
Takes part of the specified length of a MIDI file (starting at the beginning of the file)
and returns it as an instance of
MidiFile. More info in the
MIDI file splitting: TakePart article.
Declaration
public static MidiFile TakePart(this MidiFile midiFile, ITimeSpan partLength, SliceMidiFileSettings settings = null)
Parameters
Returns
Exceptions
Type |
Condition |
ArgumentNullException |
One of the following errors occurred:
-
midiFile is null . -
partLength is null .
|