Search Results for

    Show / Hide Table of Contents

    Class Pattern

    Represents a musical pattern represented as a sequence of actions to create a musical composition.
    Inheritance
    object
    Pattern
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Melanchall.DryWetMidi.Composing
    Assembly: Melanchall.DryWetMidi.dll
    Syntax
    public sealed class Pattern
    Remarks

    Pattern allows to represent musical composition as a set of actions like 'note' or 'program change'. In other words, it allows to create MIDI file in more musical manner.

    There are two ways to get an instance of the Pattern:

    • Build a pattern from scratch with fluent API provided by PatternBuilder.
    • Use one of extension methods within PatternUtilities to create pattern by processing existing one.
    You can see examples of building musical compositions in the corresponding article.

    Methods

    Clone()

    Clones pattern by creating a copy of it.
    Declaration
    public Pattern Clone()
    Returns
    Type Description
    Pattern Copy of the pattern containing all actions from original one.

    ToFile(TempoMap)

    Exports the current Pattern to MIDI file using zero channel.
    Declaration
    public MidiFile ToFile(TempoMap tempoMap)
    Parameters
    Type Name Description
    TempoMap tempoMap Tempo map to process pattern data according with.
    Returns
    Type Description
    MidiFile The MidiFile containing notes events generated by the current Pattern.
    Exceptions
    Type Condition
    ArgumentNullException tempoMap is null.

    ToFile(TempoMap, FourBitNumber)

    Exports the current Pattern to MIDI file.
    Declaration
    public MidiFile ToFile(TempoMap tempoMap, FourBitNumber channel)
    Parameters
    Type Name Description
    TempoMap tempoMap Tempo map to process pattern data according with.
    FourBitNumber channel Channel of notes that will be generated by pattern.
    Returns
    Type Description
    MidiFile The MidiFile containing notes events generated by the current Pattern.
    Exceptions
    Type Condition
    ArgumentNullException tempoMap is null.

    ToTrackChunk(TempoMap)

    Exports the current Pattern to track chunk using zero channel.
    Declaration
    public TrackChunk ToTrackChunk(TempoMap tempoMap)
    Parameters
    Type Name Description
    TempoMap tempoMap Tempo map to process pattern data according with.
    Returns
    Type Description
    TrackChunk The TrackChunk containing notes events generated by the current Pattern.
    Exceptions
    Type Condition
    ArgumentNullException tempoMap is null.

    ToTrackChunk(TempoMap, FourBitNumber)

    Exports the current Pattern to track chunk.
    Declaration
    public TrackChunk ToTrackChunk(TempoMap tempoMap, FourBitNumber channel)
    Parameters
    Type Name Description
    TempoMap tempoMap Tempo map to process pattern data according with.
    FourBitNumber channel Channel of notes that will be generated by pattern.
    Returns
    Type Description
    TrackChunk The TrackChunk containing notes events generated by the current Pattern.
    Exceptions
    Type Condition
    ArgumentNullException tempoMap is null.

    Extension Methods

    PatternUtilities.SetChordsState(Pattern, ChordSelection, PatternActionState, bool)
    PatternUtilities.SetNotesState(Pattern, NoteSelection, PatternActionState, bool)
    PatternUtilities.SplitAtAllAnchors(Pattern, bool)
    PatternUtilities.SplitAtAllMarkers(Pattern, bool)
    PatternUtilities.SplitAtAnchor(Pattern, object, bool)
    PatternUtilities.SplitAtMarker(Pattern, string, bool, StringComparison)
    PatternUtilities.TransformChords(Pattern, ChordSelection, ChordTransformation, bool)
    PatternUtilities.TransformChords(Pattern, ChordTransformation, bool)
    PatternUtilities.TransformNotes(Pattern, NoteSelection, NoteTransformation, bool)
    PatternUtilities.TransformNotes(Pattern, NoteTransformation, bool)
    PlaybackUtilities.GetPlayback(Pattern, TempoMap, FourBitNumber, IOutputDevice, PlaybackSettings)
    PlaybackUtilities.GetPlayback(Pattern, TempoMap, FourBitNumber, PlaybackSettings)
    PlaybackUtilities.Play(Pattern, TempoMap, FourBitNumber, IOutputDevice, PlaybackSettings)
    In this article
    Back to top 2024 / Generated by DocFX