Class Chord
Represents a musical chord.
Inherited Members
Namespace: Melanchall.DryWetMidi.Interaction
Assembly: Melanchall.DryWetMidi.dll
Syntax
public class Chord : ILengthedObject, ITimedObject, IMusicalObject, INotifyTimeChanged, INotifyLengthChanged
Constructors
Chord()
Initializes a new instance of the Chord.
Declaration
public Chord()
Chord(params Note[])
Initializes a new instance of the Chord with the specified
collection of notes.
Declaration
public Chord(params Note[] notes)
Parameters
| Type | Name | Description |
|---|---|---|
| Note[] | notes | Notes to combine into a chord. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | notes is null. |
Chord(IEnumerable<Note>)
Initializes a new instance of the Chord with the specified
collection of notes.
Declaration
public Chord(IEnumerable<Note> notes)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<Note> | notes | Notes to combine into a chord. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | notes is null. |
Chord(IEnumerable<Note>, long)
Initializes a new instance of the Chord with the specified
collection of notes and chord time.
Declaration
public Chord(IEnumerable<Note> notes, long time)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<Note> | notes | Notes to combine into a chord. |
| long | time | Time of the chord which is time of the earliest note of the notes. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | notes is null. |
| ArgumentOutOfRangeException | time is negative. |
Properties
Channel
Gets or sets channel to play the chord on.
Declaration
public FourBitNumber Channel { get; set; }
Property Value
| Type | Description |
|---|---|
| FourBitNumber |
Remarks
Channel is a zero-based number in DryWetMIDI, valid values are from
0 to 15.
Other libraries and software can use one-based channel numbers (i.e.from 1
to 16) so be aware about that: channel 10 in such software will be 9
in DryWetMIDI.Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | One of the following errors occurred:
|
EndTime
Gets the end time of an object.
Declaration
public long EndTime { get; }
Property Value
| Type | Description |
|---|---|
| long |
Length
Gets or sets the length of the chord in units defined by the time division of a MIDI file.
Declaration
public long Length { get; set; }
Property Value
| Type | Description |
|---|---|
| long |
Remarks
Note that the returned value will be in ticks (not seconds, not milliseconds and so on).
Please read Time and length article to learn how you can
get the length in different representations.
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | value is negative. |
Notes
Gets a TimedObjectsCollection<TObject> that contains notes of this chord.
Declaration
public TimedObjectsCollection<Note> Notes { get; }
Property Value
| Type | Description |
|---|---|
| TimedObjectsCollection<Note> |
OffVelocity
Gets or sets velocity of the underlying NoteOffEvent events of a chord's notes.
Declaration
public SevenBitNumber OffVelocity { get; set; }
Property Value
| Type | Description |
|---|---|
| SevenBitNumber |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | One of the following errors occurred:
|
Time
Gets or sets absolute time of the chord in units defined by the time division of a MIDI file.
Declaration
public long Time { get; set; }
Property Value
| Type | Description |
|---|---|
| long |
Remarks
Note that the returned value will be in ticks (not seconds, not milliseconds and so on).
Please read Time and length article to learn how you can
get the time in different representations.
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | value is negative. |
Velocity
Gets or sets velocity of the underlying NoteOnEvent events of a chord's notes.
Declaration
public SevenBitNumber Velocity { get; set; }
Property Value
| Type | Description |
|---|---|
| SevenBitNumber |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | One of the following errors occurred:
|
Methods
Clone()
Clones object by creating a copy of it.
Declaration
public virtual ITimedObject Clone()
Returns
| Type | Description |
|---|---|
| ITimedObject | Copy of the object. |
Split(long)
Splits the current object by the specified time.
Declaration
public SplitLengthedObject Split(long time)
Parameters
| Type | Name | Description |
|---|---|---|
| long | time | Time to split the object at. |
Returns
| Type | Description |
|---|---|
| SplitLengthedObject | An object containing left and right parts of the split object. Both parts have the same type as the original object. |
Remarks
If time is less than or equal to time of the object, the left part will
be null. If time is greater than or equal to end time of the object,
the right part will be null.
Let's see a simple example. Suppose we have an object with time of 10 and length of 50.
The table below shows what left and right parts will be in case of different values of
time:
| Time to split at | Left part | Right part |
|---|---|---|
5
|
null
| Copy of the object |
10
|
null
| Copy of the object |
30
| Copy of the object with time of 10 and length of 20 | Copy of the object with time of 30 and length of 30 |
60
| Copy of the object |
null
|
70
| Copy of the object |
null
|
To learn about other ways to split an object please read Objects splitting article.
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException | time is negative. |
ToString()
Returns a string that represents the current object.
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| string | A string that represents the current object. |
Overrides
Events
LengthChanged
Occurs when the length of an object has been changed.
Declaration
public event EventHandler<LengthChangedEventArgs> LengthChanged
Event Type
| Type | Description |
|---|---|
| EventHandler<LengthChangedEventArgs> |
NotesCollectionChanged
Occurs when notes collection changes.
Declaration
public event TimedObjectsCollectionChangedEventHandler<Note> NotesCollectionChanged
Event Type
| Type | Description |
|---|---|
| TimedObjectsCollectionChangedEventHandler<Note> |
TimeChanged
Occurs when the time of an object has been changed.
Declaration
public event EventHandler<TimeChangedEventArgs> TimeChanged
Event Type
| Type | Description |
|---|---|
| EventHandler<TimeChangedEventArgs> |