Class Merger
Provides methods to merge nearby objects. More info in the Merger article.
Inherited Members
Namespace: Melanchall.DryWetMidi.Tools
Assembly: Melanchall.DryWetMidi.dll
Syntax
public static class Merger
Methods
MergeObjects(MidiFile, ObjectType, ObjectsMergingSettings, ObjectDetectionSettings)
Merges nearby objects within the specified MidiFile.
Declaration
public static void MergeObjects(this MidiFile midiFile, ObjectType objectType, ObjectsMergingSettings settings = null, ObjectDetectionSettings objectDetectionSettings = null)
Parameters
Type | Name | Description |
---|---|---|
MidiFile | midiFile | MidiFile to merge objects within. |
ObjectType | objectType | Combination of desired types of objects to merge. |
ObjectsMergingSettings | settings | Settings according to which merging process should be done. |
ObjectDetectionSettings | objectDetectionSettings | Settings according to which objects should be detected and built. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | midiFile is null . |
MergeObjects(TrackChunk, ObjectType, TempoMap, ObjectsMergingSettings, ObjectDetectionSettings)
Merges nearby objects within the specified TrackChunk.
Declaration
public static void MergeObjects(this TrackChunk trackChunk, ObjectType objectType, TempoMap tempoMap, ObjectsMergingSettings settings = null, ObjectDetectionSettings objectDetectionSettings = null)
Parameters
Type | Name | Description |
---|---|---|
TrackChunk | trackChunk | TrackChunk to merge objects within. |
ObjectType | objectType | Combination of desired types of objects to merge. |
TempoMap | tempoMap | Tempo map used to calculate distances between objects. |
ObjectsMergingSettings | settings | Settings according to which merging process should be done. |
ObjectDetectionSettings | objectDetectionSettings | Settings according to which objects should be detected and built. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | One of the following errors occurred:
|
MergeObjects(IEnumerable<TrackChunk>, ObjectType, TempoMap, ObjectsMergingSettings, ObjectDetectionSettings)
Merges nearby objects within the specified collection of TrackChunk.
Declaration
public static void MergeObjects(this IEnumerable<TrackChunk> trackChunks, ObjectType objectType, TempoMap tempoMap, ObjectsMergingSettings settings = null, ObjectDetectionSettings objectDetectionSettings = null)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<TrackChunk> | trackChunks | Collection of TrackChunk to merge objects within. |
ObjectType | objectType | Combination of desired types of objects to merge. |
TempoMap | tempoMap | Tempo map used to calculate distances between objects. |
ObjectsMergingSettings | settings | Settings according to which merging process should be done. |
ObjectDetectionSettings | objectDetectionSettings | Settings according to which objects should be detected and built. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | One of the following errors occurred:
|
MergeObjects(IEnumerable<ITimedObject>, TempoMap, ObjectsMergingSettings)
Merges nearby objects.
Declaration
public static IEnumerable<ITimedObject> MergeObjects(this IEnumerable<ITimedObject> objects, TempoMap tempoMap, ObjectsMergingSettings settings = null)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<ITimedObject> | objects | Objects that should be merged. |
TempoMap | tempoMap | Tempo map used to calculate distances between objects. |
ObjectsMergingSettings | settings | Settings according to which merging process should be done. |
Returns
Type | Description |
---|---|
IEnumerable<ITimedObject> | Collection of new objects that are result of merging of objects . |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | One of the following errors occurred:
|
MergeSequentially(IEnumerable<MidiFile>, SequentialMergingSettings)
Merges the specified MIDI files sequentially so they are placed one after other in the result file.
More info in the MIDI files merging: MergeSequentially article.
Declaration
public static MidiFile MergeSequentially(this IEnumerable<MidiFile> midiFiles, SequentialMergingSettings settings = null)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<MidiFile> | midiFiles | MIDI files to merge. |
SequentialMergingSettings | settings | Settings that control how midiFiles should be merged. |
Returns
Type | Description |
---|---|
MidiFile | An instance of the MidiFile which represents midiFiles
that are merged sequentially. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | midiFiles is null . |
ArgumentException | One of the following errors occurred:
|
InvalidOperationException | One of the following errors occurred:
|
MergeSimultaneously(IEnumerable<MidiFile>, SimultaneousMergingSettings)
Merges the specified MIDI files "simultaneously" so they are placed "one below other" in the result file.
More info in the MIDI files merging: MergeSimultaneously article.
Declaration
public static MidiFile MergeSimultaneously(this IEnumerable<MidiFile> midiFiles, SimultaneousMergingSettings settings = null)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<MidiFile> | midiFiles | MIDI files to merge. |
SimultaneousMergingSettings | settings | Settings that control how midiFiles should be merged. |
Returns
Type | Description |
---|---|
MidiFile | An instance of the MidiFile which represents midiFiles
that are merged sequentially. |
Remarks
The method has a limitation: it can process only the files which have the same tempo maps, i.e.
the same changes of tempo and time signature,and the same time divisions. You can disable the
exception throwing by setting IgnoreDifferentTempoMaps of
the
settings
to true
, but proper structure (in terms of correct playing for example)
of the result MIDI file is not guaranteed in this case.Exceptions
Type | Condition |
---|---|
ArgumentNullException | midiFiles is null . |
ArgumentException | One of the following errors occurred:
|
InvalidOperationException | One of the following errors occurred:
|