Search Results for

    Show / Hide Table of Contents

    Class PatternBuilder

    Provides a fluent API to build an instance of the Pattern.
    Inheritance
    object
    PatternBuilder
    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 PatternBuilder
    Examples

    Following example shows how to create first four bars of Beethoven's 'Moonlight Sonata':

    // Define a chord for bass part which is just an octave
    var bassChord = new[] { Interval.Twelve };
    
    // Build the composition
    var pattern = new PatternBuilder()
    
        // The length of all main theme's notes within four first bars is
        // triplet eight so set it which will free us from necessity to specify
        // the length of each note explicitly
        .SetNoteLength(MusicalTimeSpan.Eighth.Triplet())
    
        // Anchor current time (start of the pattern) to jump to it
        // when we'll start to program bass part
        .Anchor()
    
        // We will add notes relative to G#3.
        // Instead of Octave.Get(3).GSharp it is possible to use Note.Get(NoteName.GSharp, 3)
        .SetRootNote(Octave.Get(3).GSharp)
    
        // Add first three notes and repeat them seven times which will
        // give us two bars of the main theme
                              // G#3
        .Note(Interval.Zero)  // +0  (G#3)
        .Note(Interval.Five)  // +5  (C#4)
        .Note(Interval.Eight) // +8  (E4)
        .Repeat(3, 7)         // repeat three previous notes seven times
    
        // Add notes of the next two bars
                              // G#3
        .Note(Interval.One)   // +1  (A3)
        .Note(Interval.Five)  // +5  (C#4)
        .Note(Interval.Eight) // +8  (E4)
        .Repeat(3, 1)         // repeat three previous notes
        .Note(Interval.One)   // +1  (A3)
        .Note(Interval.Six)   // +6  (D4)
        .Note(Interval.Ten)   // +10 (F#4)
        .Repeat(3, 1)         // repeat three previous notes
                              // reaching the end of third bar
        .Note(Interval.Zero)  // +0  (G#3)
        .Note(Interval.Four)  // +4  (C4)
        .Note(Interval.Ten)   // +10 (F#4)
        .Note(Interval.Zero)  // +0  (G#3)
        .Note(Interval.Five)  // +5  (C#4)
        .Note(Interval.Eight) // +8  (E4)
        .Note(Interval.Zero)  // +0  (G#3)
        .Note(Interval.Five)  // +5  (C#4)
        .Note(Interval.Seven) // +7  (D#4)
        .Note(-Interval.Two)  // -2  (F#3)
        .Note(Interval.Four)  // +4  (C4)
        .Note(Interval.Seven) // +7  (D#4)
    
        // Now we will program bass part. To start adding notes from the
        // beginning of the pattern we need to move to the anchor we set
        // above
        .MoveToFirstAnchor()
    
        // First two chords have whole length
        .SetNoteLength(MusicalTimeSpan.Whole)
    
                                                // insert a chord relative to
        .Chord(bassChord, Octave.Get(2).CSharp) // C#2 (C#2, C#3)
        .Chord(bassChord, Octave.Get(1).B)      // B1  (B1, B2)
    
        // Remaining four chords has half length
        .SetNoteLength(MusicalTimeSpan.Half)
    
        .Chord(bassChord, Octave.Get(1).A)      // A1  (A1, A2)
        .Chord(bassChord, Octave.Get(1).FSharp) // F#1 (F#1, F#2)
        .Chord(bassChord, Octave.Get(1).GSharp) // G#1 (G#1, G#2)
        .Repeat()                               // repeat the previous chord
    
        // Build a pattern that can be then saved to a MIDI file
        .Build();

    Constructors

    PatternBuilder()

    Initializes a new instance of the PatternBuilder.
    Declaration
    public PatternBuilder()

    PatternBuilder(Pattern)

    Initializes a new instance of the PatternBuilder with the specified pattern.
    Declaration
    public PatternBuilder(Pattern pattern)
    Parameters
    Type Name Description
    Pattern pattern Pattern to initialize builder with.
    Remarks

    This constructor is equivalent to calling default one followed by ReplayPattern(Pattern) call. Using this constructor pattern builder's current position will be placed right after pattern so all further actions will be relative to the end of pattern rather than zero.

    To start with fresh pattern and place data starting from zero use PatternBuilder() constructor.

    Exceptions
    Type Condition
    ArgumentNullException pattern is null.

    Fields

    DefaultNoteLength

    Default length that will be applied to all further notes and chords if it's not specified explicitly. The length can be altered with SetNoteLength(ITimeSpan).
    Declaration
    public static readonly ITimeSpan DefaultNoteLength
    Field Value
    Type Description
    ITimeSpan

    DefaultOctave

    Default octave further notes and chords will be relative to if it's not specified explicitly. Octave can be altered with SetOctave(Octave).
    Declaration
    public static readonly Octave DefaultOctave
    Field Value
    Type Description
    Octave

    DefaultRootNote

    Default root note further notes will be based on if it's not specified explicitly. Root note can be altered with SetRootNote(Note).
    Declaration
    public static readonly Note DefaultRootNote
    Field Value
    Type Description
    Note

    DefaultStep

    Default step size that will be applied to all further move operations if it's not specified explicitly. Step size can be altered with SetStep(ITimeSpan).
    Declaration
    public static readonly ITimeSpan DefaultStep
    Field Value
    Type Description
    ITimeSpan

    DefaultVelocity

    Default velocity that will be applied to all further notes and chords if it's not specified explicitly. Velocity can be altered with SetVelocity(SevenBitNumber).
    Declaration
    public static readonly SevenBitNumber DefaultVelocity
    Field Value
    Type Description
    SevenBitNumber

    Properties

    NoteLength

    Gets the length that will be applied to all further notes and chords if it's not specified explicitly. The length can be altered with SetNoteLength(ITimeSpan).
    Declaration
    public ITimeSpan NoteLength { get; }
    Property Value
    Type Description
    ITimeSpan
    Remarks

    There are methods to add notes and chords that don't take length as an argument. In these cases the value of the NoteLength property will be used. For example, Note(Note, ITimeSpan, SevenBitNumber?) or Chord(IEnumerable<Interval>, Note, ITimeSpan, SevenBitNumber?).

    Octave

    Gets the octave further notes and chords will be relative to if it's not specified explicitly. Octave can be altered with SetOctave(Octave).
    Declaration
    public Octave Octave { get; }
    Property Value
    Type Description
    Octave
    Remarks

    There are methods to add notes and chords where octave is not specified explicitly. In these cases the value of the Octave property will be used. For example, Note(NoteName, ITimeSpan, SevenBitNumber?) or Chord(IEnumerable<Interval>, NoteName, ITimeSpan, SevenBitNumber?).

    RootNote

    Gets the root note further notes will be based on if it's not specified explicitly. Root note can be altered with SetRootNote(Note).
    Declaration
    public Note RootNote { get; }
    Property Value
    Type Description
    Note
    Remarks

    There are methods to add notes by interval where root note is not specified explicitly. In these cases the value of the RootNote property will be used. For example, Note(Interval, ITimeSpan, SevenBitNumber?).

    Step

    Gets the step size that will be applied to all further move operations if it's not specified explicitly. Step size can be altered with SetStep(ITimeSpan).
    Declaration
    public ITimeSpan Step { get; }
    Property Value
    Type Description
    ITimeSpan
    Remarks

    There are methods to move current builder's position that don't take step as an argument. In these cases the value of the Step property will be used. For example, StepForward() or StepBack().

    Velocity

    Gets the velocity that will be applied to all further notes and chords if it's not specified explicitly. Velocity can be altered with SetVelocity(SevenBitNumber).
    Declaration
    public SevenBitNumber Velocity { get; }
    Property Value
    Type Description
    SevenBitNumber
    Remarks

    There are methods to add notes and chords that don't take velocity as an argument. In these cases the value of the Velocity property will be used. For example, Note(Note, ITimeSpan, SevenBitNumber?) or Chord(IEnumerable<Interval>, Note, ITimeSpan, SevenBitNumber?).

    Methods

    Anchor()

    Places an anchor at the current time.
    Declaration
    public PatternBuilder Anchor()
    Returns
    Type Description
    PatternBuilder The current PatternBuilder.

    Anchor(object)

    Places the specified anchor at the current time.
    Declaration
    public PatternBuilder Anchor(object anchor)
    Parameters
    Type Name Description
    object anchor Anchor to place.
    Returns
    Type Description
    PatternBuilder The current PatternBuilder.
    Exceptions
    Type Condition
    ArgumentNullException anchor is null.

    Build()

    Build an instance of the Pattern holding all actions defined via builder.
    Declaration
    public Pattern Build()
    Returns
    Type Description
    Pattern An instance of the Pattern that holds all actions defined by the current PatternBuilder.

    Chord(Chord, Octave, ITimeSpan, SevenBitNumber?)

    Adds a chord using the specified octave, length and velocity.
    Declaration
    public PatternBuilder Chord(Chord chord, Octave octave = null, ITimeSpan length = null, SevenBitNumber? velocity = null)
    Parameters
    Type Name Description
    Chord chord Chord to add.
    Octave octave Octave to resolve chord's notes. null can be passed to use the Octave property value (see SetOctave(Octave)).
    ITimeSpan length Chord's notes length. null can be passed to use the NoteLength property value (see SetNoteLength(ITimeSpan)).
    SevenBitNumber? velocity Chord's notes velocity. null can be passed to use the Velocity property value (see SetVelocity(SevenBitNumber)).
    Returns
    Type Description
    PatternBuilder The current PatternBuilder.
    Exceptions
    Type Condition
    ArgumentNullException chord is null.

    Chord(IEnumerable<Interval>, Note, ITimeSpan, SevenBitNumber?)

    Adds a chord by the specified intervals relative to the root note using specified length and velocity.
    Declaration
    public PatternBuilder Chord(IEnumerable<Interval> intervals, Note rootNote = null, ITimeSpan length = null, SevenBitNumber? velocity = null)
    Parameters
    Type Name Description
    IEnumerable<Interval> intervals The Interval objects which define a numbers of half steps from the rootNote.
    Note rootNote The chord's root note. null can be passed to use the RootNote property value (see SetRootNote(Note)).
    ITimeSpan length Chord's notes length. null can be passed to use the NoteLength property value (see SetNoteLength(ITimeSpan)).
    SevenBitNumber? velocity Chord's notes velocity. null can be passed to use the Velocity property value (see SetVelocity(SevenBitNumber)).
    Returns
    Type Description
    PatternBuilder The current PatternBuilder.
    Remarks
    The result chord will contain the specified root note and notes produced by transposing the rootNote by the intervals.
    Exceptions
    Type Condition
    ArgumentNullException intervals is null.
    ArgumentOutOfRangeException The number of result chord's note is out of valid range.

    Chord(IEnumerable<Interval>, NoteName, ITimeSpan, SevenBitNumber?)

    Adds a chord by the specified intervals, root note's name, length and velocity.
    Declaration
    public PatternBuilder Chord(IEnumerable<Interval> intervals, NoteName rootNoteName, ITimeSpan length = null, SevenBitNumber? velocity = null)
    Parameters
    Type Name Description
    IEnumerable<Interval> intervals Intervals that represent the chord.
    NoteName rootNoteName The root note's name of the chord. The note will be resolved using the current octave (see SetOctave(Octave)).
    ITimeSpan length Chord's notes length. null can be passed to use the NoteLength property value (see SetNoteLength(ITimeSpan)).
    SevenBitNumber? velocity Chord's notes velocity. null can be passed to use the Velocity property value (see SetVelocity(SevenBitNumber)).
    Returns
    Type Description
    PatternBuilder The current PatternBuilder.
    Exceptions
    Type Condition
    ArgumentNullException intervals is null.
    InvalidEnumArgumentException rootNoteName specified an invalid value.

    Chord(IEnumerable<NoteName>, ITimeSpan, SevenBitNumber?)

    Adds a chord by the specified notes names using specified velocity and length, and default octave.
    Declaration
    public PatternBuilder Chord(IEnumerable<NoteName> noteNames, ITimeSpan length = null, SevenBitNumber? velocity = null)
    Parameters
    Type Name Description
    IEnumerable<NoteName> noteNames Names of notes that represent a chord. The notes will be resolved using the current octave (see SetOctave(Octave)).
    ITimeSpan length Chord's notes length. null can be passed to use the NoteLength property value (see SetNoteLength(ITimeSpan)).
    SevenBitNumber? velocity Chord's notes velocity. null can be passed to use the Velocity property value (see SetVelocity(SevenBitNumber)).
    Returns
    Type Description
    PatternBuilder The current PatternBuilder.
    Remarks
    To set default octave use SetOctave(Octave) method. By default the octave number is 4.
    Exceptions
    Type Condition
    ArgumentNullException noteNames is null.

    Chord(IEnumerable<Note>, ITimeSpan, SevenBitNumber?)

    Adds a chord by the specified notes using specified velocity and length.
    Declaration
    public PatternBuilder Chord(IEnumerable<Note> notes, ITimeSpan length = null, SevenBitNumber? velocity = null)
    Parameters
    Type Name Description
    IEnumerable<Note> notes Notes that represent a chord.
    ITimeSpan length Chord's notes length. null can be passed to use the NoteLength property value (see SetNoteLength(ITimeSpan)).
    SevenBitNumber? velocity Chord's notes velocity. null can be passed to use the Velocity property value (see SetVelocity(SevenBitNumber)).
    Returns
    Type Description
    PatternBuilder The current PatternBuilder.
    Exceptions
    Type Condition
    ArgumentNullException notes is null.

    Chord(string, Octave, ITimeSpan, SevenBitNumber?)

    Adds a chord using the specified octave, length and velocity.
    Declaration
    public PatternBuilder Chord(string chord, Octave octave = null, ITimeSpan length = null, SevenBitNumber? velocity = null)
    Parameters
    Type Name Description
    string chord A chord as a string (see the corresponding article to learn more).
    Octave octave Octave to resolve chord's notes. null can be passed to use the Octave property value (see SetOctave(Octave)).
    ITimeSpan length Chord's notes length. null can be passed to use the NoteLength property value (see SetNoteLength(ITimeSpan)).
    SevenBitNumber? velocity Chord's notes velocity. null can be passed to use the Velocity property value (see SetVelocity(SevenBitNumber)).
    Returns
    Type Description
    PatternBuilder The current PatternBuilder.
    Exceptions
    Type Condition
    ArgumentException chord is null or contains white-spaces only.
    FormatException chord has invalid format.

    ControlChange(SevenBitNumber, SevenBitNumber)

    Inserts ControlChangeEvent to specify a change of a controller that will be used by following notes.
    Declaration
    public PatternBuilder ControlChange(SevenBitNumber controlNumber, SevenBitNumber controlValue)
    Parameters
    Type Name Description
    SevenBitNumber controlNumber Controller number.
    SevenBitNumber controlValue Controller value.
    Returns
    Type Description
    PatternBuilder The current PatternBuilder.

    Lyrics(string)

    Adds lyrics.
    Declaration
    public PatternBuilder Lyrics(string text)
    Parameters
    Type Name Description
    string text Text of lyrics.
    Returns
    Type Description
    PatternBuilder The current PatternBuilder.
    Exceptions
    Type Condition
    ArgumentNullException text is null.

    Marker(string)

    Adds a marker.
    Declaration
    public PatternBuilder Marker(string marker)
    Parameters
    Type Name Description
    string marker The text of marker.
    Returns
    Type Description
    PatternBuilder The current PatternBuilder.
    Exceptions
    Type Condition
    ArgumentNullException marker is null.

    MoveToFirstAnchor()

    Move to the first anchor.
    Declaration
    public PatternBuilder MoveToFirstAnchor()
    Returns
    Type Description
    PatternBuilder The current PatternBuilder.
    Exceptions
    Type Condition
    InvalidOperationException There are no anchors.

    MoveToFirstAnchor(object)

    Moves to the first specified anchor.
    Declaration
    public PatternBuilder MoveToFirstAnchor(object anchor)
    Parameters
    Type Name Description
    object anchor Anchor to move to.
    Returns
    Type Description
    PatternBuilder The current PatternBuilder.
    Exceptions
    Type Condition
    ArgumentNullException anchor is null.
    ArgumentException There are no anchors with the anchor key.

    MoveToLastAnchor()

    Moves to the last anchor.
    Declaration
    public PatternBuilder MoveToLastAnchor()
    Returns
    Type Description
    PatternBuilder The current PatternBuilder.
    Exceptions
    Type Condition
    InvalidOperationException The are no anchors.

    MoveToLastAnchor(object)

    Moves to the last specified anchor.
    Declaration
    public PatternBuilder MoveToLastAnchor(object anchor)
    Parameters
    Type Name Description
    object anchor Anchor to move to.
    Returns
    Type Description
    PatternBuilder The current PatternBuilder.
    Exceptions
    Type Condition
    ArgumentNullException anchor is null.
    ArgumentException There are no anchors with the anchor key.

    MoveToNthAnchor(int)

    Moves to the nth anchor.
    Declaration
    public PatternBuilder MoveToNthAnchor(int index)
    Parameters
    Type Name Description
    int index Index of an anchor to move to.
    Returns
    Type Description
    PatternBuilder The current PatternBuilder.
    Exceptions
    Type Condition
    ArgumentOutOfRangeException index is out of range.

    MoveToNthAnchor(object, int)

    Moves to the nth specified anchor.
    Declaration
    public PatternBuilder MoveToNthAnchor(object anchor, int index)
    Parameters
    Type Name Description
    object anchor Anchor to move to.
    int index Index of an anchor to move to.
    Returns
    Type Description
    PatternBuilder The current PatternBuilder.
    Exceptions
    Type Condition
    ArgumentNullException anchor is null.
    ArgumentOutOfRangeException index is out of range.

    MoveToPreviousTime()

    Moves the current time to the previous one.
    Declaration
    public PatternBuilder MoveToPreviousTime()
    Returns
    Type Description
    PatternBuilder The current PatternBuilder.
    Remarks
    On every action current time is stored in the time history. To return to the last saved time you can call the MoveToPreviousTime().

    MoveToStart()

    Moves the current time to the start (zero time) of a pattern.
    Declaration
    public PatternBuilder MoveToStart()
    Returns
    Type Description
    PatternBuilder The current PatternBuilder.

    MoveToTime(ITimeSpan)

    Moves the current time to the specified one.
    Declaration
    public PatternBuilder MoveToTime(ITimeSpan time)
    Parameters
    Type Name Description
    ITimeSpan time Time to move to.
    Returns
    Type Description
    PatternBuilder The current PatternBuilder.
    Exceptions
    Type Condition
    ArgumentNullException time is null.

    Note(Interval, ITimeSpan, SevenBitNumber?)

    Adds a note by the specified interval relative to the current root note using specified length and velocity.
    Declaration
    public PatternBuilder Note(Interval interval, ITimeSpan length = null, SevenBitNumber? velocity = null)
    Parameters
    Type Name Description
    Interval interval The Interval which defines a number of half steps from the current root note (see SetRootNote(Note)).
    ITimeSpan length The length of a note. null can be passed to use the NoteLength property value (see SetNoteLength(ITimeSpan)).
    SevenBitNumber? velocity The velocity of a note. null can be passed to use the Velocity property value (see SetVelocity(SevenBitNumber)).
    Returns
    Type Description
    PatternBuilder The current PatternBuilder.
    Exceptions
    Type Condition
    ArgumentNullException interval is null.
    ArgumentOutOfRangeException The number of result note is out of valid range.

    Note(Note, ITimeSpan, SevenBitNumber?)

    Adds a note using specified velocity and length.
    Declaration
    public PatternBuilder Note(Note note, ITimeSpan length = null, SevenBitNumber? velocity = null)
    Parameters
    Type Name Description
    Note note A note.
    ITimeSpan length The length of a note. null can be passed to use the NoteLength property value (see SetNoteLength(ITimeSpan)).
    SevenBitNumber? velocity The velocity of a note. null can be passed to use the Velocity property value (see SetVelocity(SevenBitNumber)).
    Returns
    Type Description
    PatternBuilder The current PatternBuilder.
    Exceptions
    Type Condition
    ArgumentNullException note is null.

    Note(NoteName, ITimeSpan, SevenBitNumber?)

    Adds a note by the specified note name using specified velocity and length, and default octave.
    Declaration
    public PatternBuilder Note(NoteName noteName, ITimeSpan length = null, SevenBitNumber? velocity = null)
    Parameters
    Type Name Description
    NoteName noteName The name of a note to resolve using the current octave (see SetOctave(Octave)).
    ITimeSpan length The length of a note. null can be passed to use the NoteLength property value (see SetNoteLength(ITimeSpan)).
    SevenBitNumber? velocity The velocity of a note. null can be passed to use the Velocity property value (see SetVelocity(SevenBitNumber)).
    Returns
    Type Description
    PatternBuilder The current PatternBuilder.
    Remarks
    To set default octave use SetOctave(Octave) method. By default the octave number is DefaultOctave.
    Exceptions
    Type Condition
    InvalidEnumArgumentException noteName specified an invalid value.

    Note(string, ITimeSpan, SevenBitNumber?)

    Adds a note using specified velocity and length.
    Declaration
    public PatternBuilder Note(string note, ITimeSpan length = null, SevenBitNumber? velocity = null)
    Parameters
    Type Name Description
    string note A note as a string (see the corresponding article to learn more).
    ITimeSpan length The length of a note. null can be passed to use the NoteLength property value (see SetNoteLength(ITimeSpan)).
    SevenBitNumber? velocity The velocity of a note. null can be passed to use the Velocity property value (see SetVelocity(SevenBitNumber)).
    Returns
    Type Description
    PatternBuilder The current PatternBuilder.
    Exceptions
    Type Condition
    ArgumentException note is null or contains white-spaces only.
    FormatException note has invalid format.

    Pattern(Pattern)

    Adds a pattern.
    Declaration
    public PatternBuilder Pattern(Pattern pattern)
    Parameters
    Type Name Description
    Pattern pattern Pattern to add.
    Returns
    Type Description
    PatternBuilder The current PatternBuilder.
    Exceptions
    Type Condition
    ArgumentNullException pattern is null.

    PianoRoll(string, PianoRollSettings)

    Inserts notes data by the specified piano roll string. More info in the Pattern: Piano roll article.
    Declaration
    public PatternBuilder PianoRoll(string pianoRoll, PianoRollSettings settings = null)
    Parameters
    Type Name Description
    string pianoRoll String that represents notes data as a piano roll.
    PianoRollSettings settings Settings according to which a piano roll should be handled.
    Returns
    Type Description
    PatternBuilder The current PatternBuilder.
    Exceptions
    Type Condition
    ArgumentException pianoRoll is null, a zero-length string, contains only white space, or contains one or more invalid characters as defined by InvalidPathChars.
    InvalidOperationException One of the following errors occurred:
    • Failed to parse a note.
    • Single-cell note can't be placed inside a multi-cell one.
    • Note can't be started while a previous one is not ended.
    • Note is not started.

    PitchBend(ushort)

    Inserts PitchBendEvent to specify a pitch bend that will be used by following notes.
    Declaration
    public PatternBuilder PitchBend(ushort pitchValue)
    Parameters
    Type Name Description
    ushort pitchValue Pitch value.
    Returns
    Type Description
    PatternBuilder The current PatternBuilder.
    Exceptions
    Type Condition
    ArgumentOutOfRangeException pitchValue is out of [MinPitchValue; MaxPitchValue] range.

    ProgramChange(SevenBitNumber)

    Inserts ProgramChangeEvent to specify an instrument that will be used by following notes.
    Declaration
    public PatternBuilder ProgramChange(SevenBitNumber programNumber)
    Parameters
    Type Name Description
    SevenBitNumber programNumber The number of a MIDI program.
    Returns
    Type Description
    PatternBuilder The current PatternBuilder.

    ProgramChange(GeneralMidi2Program)

    Inserts ProgramChangeEvent to specify an instrument that will be used by following notes.
    Declaration
    public PatternBuilder ProgramChange(GeneralMidi2Program program)
    Parameters
    Type Name Description
    GeneralMidi2Program program The General MIDI Level 2 program.
    Returns
    Type Description
    PatternBuilder The current PatternBuilder.
    Exceptions
    Type Condition
    InvalidEnumArgumentException program specified an invalid value.

    ProgramChange(GeneralMidiProgram)

    Inserts ProgramChangeEvent to specify an instrument that will be used by following notes.
    Declaration
    public PatternBuilder ProgramChange(GeneralMidiProgram program)
    Parameters
    Type Name Description
    GeneralMidiProgram program The General MIDI Level 1 program.
    Returns
    Type Description
    PatternBuilder The current PatternBuilder.
    Exceptions
    Type Condition
    InvalidEnumArgumentException program specified an invalid value.

    Repeat(RepeatSettings)

    Repeats the previous action one time.
    Declaration
    public PatternBuilder Repeat(RepeatSettings settings = null)
    Parameters
    Type Name Description
    RepeatSettings settings Settings according to which actions should be repeated.
    Returns
    Type Description
    PatternBuilder The current PatternBuilder.
    Remarks
    Note that SetNoteLength(ITimeSpan), SetOctave(Octave), SetStep(ITimeSpan) and SetVelocity(SevenBitNumber) are not actions and will not be repeated since default values applies immediately on next actions.
    Exceptions
    Type Condition
    InvalidOperationException There are no actions to repeat.

    Repeat(int, RepeatSettings)

    Repeats the previous action the specified number of times.
    Declaration
    public PatternBuilder Repeat(int repeatsNumber, RepeatSettings settings = null)
    Parameters
    Type Name Description
    int repeatsNumber Count of repetitions.
    RepeatSettings settings Settings according to which actions should be repeated.
    Returns
    Type Description
    PatternBuilder The current PatternBuilder.
    Remarks
    Note that SetNoteLength(ITimeSpan), SetOctave(Octave), SetStep(ITimeSpan) and SetVelocity(SevenBitNumber) are not actions and will not be repeated since default values applies immediately on next actions.
    Exceptions
    Type Condition
    ArgumentOutOfRangeException repeatsNumber is negative.
    InvalidOperationException There are no actions to repeat.

    Repeat(int, int, RepeatSettings)

    Repeats the specified number of previous actions.
    Declaration
    public PatternBuilder Repeat(int actionsCount, int repeatsNumber, RepeatSettings settings = null)
    Parameters
    Type Name Description
    int actionsCount Number of previous actions to repeat.
    int repeatsNumber Count of repetitions.
    RepeatSettings settings Settings according to which actions should be repeated.
    Returns
    Type Description
    PatternBuilder The current PatternBuilder.
    Remarks
    Note that SetNoteLength(ITimeSpan), SetOctave(Octave), SetStep(ITimeSpan) and SetVelocity(SevenBitNumber) are not actions and will not be repeated since default values applies immediately on next actions.
    Exceptions
    Type Condition
    ArgumentOutOfRangeException

    One of the following errors occurred:

    • actionsCount is negative.
    • actionsCount is greater than count of existing actions.
    • repeatsNumber is negative.

    ReplayPattern(Pattern)

    Replays all actions contained in the specified pattern.
    Declaration
    public PatternBuilder ReplayPattern(Pattern pattern)
    Parameters
    Type Name Description
    Pattern pattern Pattern to replay actions of.
    Returns
    Type Description
    PatternBuilder The current PatternBuilder.
    Remarks

    ReplayPattern(Pattern) inserts all actions from pattern that were added by using methods of PatternBuilder to produce the specified pattern. These actions will be added as separate ones unlike Pattern(Pattern) which adds pattern as one single action.

    Exceptions
    Type Condition
    ArgumentNullException pattern is null.

    SetNoteLength(ITimeSpan)

    Sets default note length that will be used by next actions of the builder.
    Declaration
    public PatternBuilder SetNoteLength(ITimeSpan length)
    Parameters
    Type Name Description
    ITimeSpan length New default note length.
    Returns
    Type Description
    PatternBuilder The current PatternBuilder.
    Remarks
    Setting default note length is not an action and thus will not be stored in a pattern.
    Exceptions
    Type Condition
    ArgumentNullException length is null.

    SetOctave(Octave)

    Sets default note octave that will be used by next actions of the builder.
    Declaration
    public PatternBuilder SetOctave(Octave octave)
    Parameters
    Type Name Description
    Octave octave New default octave.
    Returns
    Type Description
    PatternBuilder The current PatternBuilder.
    Remarks
    Setting default octave is not an action and thus will not be stored in a pattern.
    Exceptions
    Type Condition
    ArgumentNullException octave is null.

    SetRootNote(Note)

    Sets a root note that will be used by next actions of the builder using Interval objects.
    Declaration
    public PatternBuilder SetRootNote(Note rootNote)
    Parameters
    Type Name Description
    Note rootNote The root note.
    Returns
    Type Description
    PatternBuilder The current PatternBuilder.
    Remarks
    Setting a root note is not an action and thus will not be stored in a pattern.
    Exceptions
    Type Condition
    ArgumentNullException rootNote is null.

    SetStep(ITimeSpan)

    Sets default step for step back and step forward actions of the builder.
    Declaration
    public PatternBuilder SetStep(ITimeSpan step)
    Parameters
    Type Name Description
    ITimeSpan step New default step.
    Returns
    Type Description
    PatternBuilder The current PatternBuilder.
    Remarks
    Setting default step is not an action and thus will not be stored in a pattern.
    Exceptions
    Type Condition
    ArgumentNullException step is null.

    SetVelocity(SevenBitNumber)

    Sets default velocity that will be used by next actions of the builder.
    Declaration
    public PatternBuilder SetVelocity(SevenBitNumber velocity)
    Parameters
    Type Name Description
    SevenBitNumber velocity New default velocity of a note.
    Returns
    Type Description
    PatternBuilder The current PatternBuilder.
    Remarks
    Setting default velocity is not an action and thus will not be stored in a pattern.

    StepBack()

    Moves the current time by the default step back.
    Declaration
    public PatternBuilder StepBack()
    Returns
    Type Description
    PatternBuilder The current PatternBuilder.
    Remarks
    To set default step use SetStep(ITimeSpan) method. By default the step is 1/4.

    StepBack(ITimeSpan)

    Moves the current time by the specified step back.
    Declaration
    public PatternBuilder StepBack(ITimeSpan step)
    Parameters
    Type Name Description
    ITimeSpan step Step to move by.
    Returns
    Type Description
    PatternBuilder The current PatternBuilder.
    Exceptions
    Type Condition
    ArgumentNullException step is null.

    StepForward()

    Moves the current time by the default step forward.
    Declaration
    public PatternBuilder StepForward()
    Returns
    Type Description
    PatternBuilder The current PatternBuilder.
    Remarks
    To set default step use SetStep(ITimeSpan) method. By default the step is 1/4.

    StepForward(ITimeSpan)

    Moves the current time by the specified step forward.
    Declaration
    public PatternBuilder StepForward(ITimeSpan step)
    Parameters
    Type Name Description
    ITimeSpan step Step to move by.
    Returns
    Type Description
    PatternBuilder The current PatternBuilder.
    Exceptions
    Type Condition
    ArgumentNullException step is null.
    In this article
    Back to top 2024 / Generated by DocFX